[PATCH 1 of 3] store: add a contains method to basicstore
smuralid at yahoo.com
Thu Oct 11 17:51:49 CDT 2012
I'm traveling this week without access to a dev box. I'll be back in a couple of days and look at this (and the other issues you mentioned)
On Oct 11, 2012, at 2:37 AM, Adrian Buehlmann <adrian at cadifra.com> wrote:
> On 2012-09-14 09:01, S Muralidhar wrote:
>> # HG changeset patch
>> # User smuralid
>> # Date 1347580834 25200
>> # Node ID 293063ca7f0332f26e5278b341628d83f2ef37f8
>> # Parent fc1a5d0eb3bbb1116051b65dcd2873389f9d7ed4
>> store: add a contains method to basicstore
>> Adds a __contains__ method to basicstore that checks if a file/dir is present in the store
>> diff --git a/mercurial/store.py b/mercurial/store.py
>> --- a/mercurial/store.py
>> +++ b/mercurial/store.py
>> @@ -286,6 +286,17 @@
>> def write(self):
>> + def __contains__(self, path):
>> + '''Checks if the store contains path'''
>> + path = "/".join(("data", path))
>> + # file?
>> + if os.path.exists(self.join(path + ".i")):
>> + return True
>> + # dir?
>> + if not path.endswith("/"):
>> + path = path + "/"
>> + return os.path.exists(self.join(path))
>> class encodedstore(basicstore):
>> def __init__(self, path, openertype):
>> self.path = path + '/store'
> I think this doesn't work correctly for encodedstore objects
> (corresponds to repositories with no "fncache" entry in .hg/requires ).
> IIUC encodedstore inherits __contains__ from basicstore, but this looks
> unsuitable to me, as encodedstore has its file names encoded and
> __contains__ of basicstore queries the filesystem with unencoded path names.
> Adding testcases for all kinds of stores might be a good idea (albeit a
> painful exercise, but it would prevent or uncover such errors).
>  http://mercurial.selenic.com/wiki/RequiresFile
More information about the Mercurial-devel