store: move __contains__() implementation from class fncache into fncachestore
authorAdrian Buehlmann <adrian@cadifra.com>
Fri, 12 Oct 2012 10:40:09 +0200
changeset 17782 8095306c1fb2
parent 17781 8ce535745500
child 17783 df55ce6854c3
store: move __contains__() implementation from class fncache into fncachestore This restores the previous semantics of fncache.__contains__(). (a followup to b9a56b816ff2)
mercurial/store.py
--- 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: