changeset 17782:8095306c1fb2

store: move __contains__() implementation from class fncache into fncachestore This restores the previous semantics of fncache.__contains__(). (a followup to b9a56b816ff2)
author Adrian Buehlmann <adrian@cadifra.com>
date Fri, 12 Oct 2012 10:40:09 +0200
parents 8ce535745500
children df55ce6854c3
files mercurial/store.py
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Fri Oct 12 10:12:26 2012 +0200
+++ b/mercurial/store.py	Fri Oct 12 10:40:09 2012 +0200
@@ -426,19 +426,10 @@
             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 @@
     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: