# HG changeset patch # User Adrian Buehlmann # Date 2012-10-12 08:40:09 # Node ID 8095306c1fb2f90e5c41486a0e9569d5a69010ea # Parent 8ce535745500da217e1cc3cebe1f2b2ac1ffc622 store: move __contains__() implementation from class fncache into fncachestore This restores the previous semantics of fncache.__contains__(). (a followup to b9a56b816ff2) diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -426,19 +426,10 @@ class fncache(object): self._dirty = True self.entries.add(fn) - def __contains__(self, path): + def __contains__(self, fn): if self.entries is None: self._load() - # Check for files (exact match) - if path + ".i" in self.entries: - return True - # Now check for directories (prefix match) - if not path.endswith('/'): - path += '/' - for e in self.entries: - if e.startswith(path): - return True - return False + return fn in self.entries def __iter__(self): if self.entries is None: @@ -524,7 +515,16 @@ class fncachestore(basicstore): def __contains__(self, path): '''Checks if the store contains path''' path = "/".join(("data", path)) - return path in self.fncache + # check for files (exact match) + if path + '.i' in self.fncache: + return True + # now check for directories (prefix match) + if not path.endswith('/'): + path += '/' + for e in self.fncache: + if e.startswith(path): + return True + return False def store(requirements, path, vfstype): if 'store' in requirements: