smuralid  committed b9a56b8

store: add a contains method to fncachestore

Adds a __contains__ method to fncachestore to check for file/dir existence (using fncache.__contains__).
Also extends fncache.__contains__ to check for directories (by prefix matching)

  • Participants
  • Parent commits 09d5b20

Comments (0)

Files changed (1)

File mercurial/

             self._dirty = True
-    def __contains__(self, fn):
+    def __contains__(self, path):
         if self.entries is None:
-        return fn in self.entries
+        # 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
     def __iter__(self):
         if self.entries is None:
     def write(self):
+    def __contains__(self, path):
+        '''Checks if the store contains path'''
+        path = "/".join(("data", path))
+        return path in self.fncache
 def store(requirements, path, vfstype):
     if 'store' in requirements:
         if 'fncache' in requirements: