[PATCH 1 of 3] store: add a __contains__ method to basicstore which checks if the supplied path exists in the store

S Muralidhar smuralid at yahoo.com
Thu Sep 13 17:01:21 CDT 2012


hmm. Let me go back and revisit this one. Thanks, Matt

Thanks
Murali


________________________________
 From: Matt Mackall <mpm at selenic.com>
To: S Muralidhar <smuralid at yahoo.com> 
Cc: mercurial-devel at selenic.com 
Sent: Thursday, September 13, 2012 1:16 PM
Subject: Re: [PATCH 1 of 3] store: add a __contains__ method to basicstore which checks if the supplied path exists in the store
 
On Thu, 2012-09-13 at 10:41 -0700, S Muralidhar wrote:
> # HG changeset patch
> # User smuralid
> # Date 1347510230 25200
> # Node ID d6d5af14c18dcc7f483d1fc069660255d16d034a
> # Parent  8fea378242e317d2311c86436ed45e95821513e4
> store: add a __contains__ method to basicstore which checks if the supplied path exists in the store
> 
> diff --git a/mercurial/store.py b/mercurial/store.py
> --- a/mercurial/store.py
> +++ b/mercurial/store.py
> @@ -286,6 +286,10 @@
>      def write(self):
>          pass
>  
> +    def __contains__(self, path):
> +        '''Checks if this path exists in the store'''
> +        return self.opener.exists(path)
> +
>  class encodedstore(basicstore):
>      def __init__(self, path, openertype):
>          self.path = path + '/store'

This doesn't actually work on non-fncache repos:

** Unknown exception encountered with possibly-broken third-party
extension perf
** which supports versions unknown of Mercurial.
** Please disable perf and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17) [GCC 4.6.3]
** Mercurial Distributed SCM (version 2.3-rc+22-ed92505a2dc9)
** Extensions loaded: hgk, record, mq, progress, pager, gpg, convert,
graphlog, rebase, share, perf, shrink, dbsh, extdiff, color, patchbomb,
transplant
Traceback (most recent call last):
  File "/home/mpm/bin/hg", line 38, in <module>
    mercurial.dispatch.run()
  File "/home/mpm/hg/mercurial/dispatch.py", line 28, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/home/mpm/hg/mercurial/dispatch.py", line 65, in dispatch
    return _runcatch(req)
  File "/home/mpm/hg/mercurial/dispatch.py", line 88, in _runcatch
    return _dispatch(req)
  File "/home/mpm/hg/mercurial/dispatch.py", line 740, in _dispatch
    cmdpats, cmdoptions)
  File "/home/mpm/hg/mercurial/dispatch.py", line 514, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/home/mpm/hg/mercurial/extensions.py", line 189, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/home/mpm/hg/hgext/color.py", line 364, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/home/mpm/hg/mercurial/extensions.py", line 189, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/home/mpm/hg/hgext/pager.py", line 130, in pagecmd
    return orig(ui, options, cmd, cmdfunc)
  File "/home/mpm/hg/mercurial/dispatch.py", line 830, in _runcommand
    return checkargs()
  File "/home/mpm/hg/mercurial/dispatch.py", line 801, in checkargs
    return cmdfunc()
  File "/home/mpm/hg/mercurial/dispatch.py", line 737, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/home/mpm/hg/mercurial/util.py", line 471, in check
    return func(*args, **kwargs)
  File "/home/mpm/hg/mercurial/extensions.py", line 144, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/home/mpm/hg/mercurial/util.py", line 471, in check
    return func(*args, **kwargs)
  File "/home/mpm/hg/hgext/mq.py", line 3528, in mqcommand
    return orig(ui, repo, *args, **kwargs)
  File "/home/mpm/hg/mercurial/util.py", line 471, in check
    return func(*args, **kwargs)
  File "/home/mpm/hg/mercurial/commands.py", line 4142, in log
    for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
  File "/home/mpm/hg/mercurial/cmdutil.py", line 1121, in walkchangerevs
    if path in repo.store:
  File "/home/mpm/hg/mercurial/store.py", line 291, in __contains__
    return self.opener.exists(path)
  File "/home/mpm/hg/mercurial/scmutil.py", line 211, in exists
    return os.path.exists(self.join(path))
AttributeError: 'filteropener' object has no attribute 'join'




-- 
Mathematics is the supreme nostalgia of our time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120913/bb08a9a2/attachment.html>


More information about the Mercurial-devel mailing list