Commits

Anonymous committed 09d5b20

store: add a contains method to basicstore

Adds a __contains__ method to basicstore that checks if a file/dir is present in the store

Comments (0)

Files changed (1)

mercurial/store.py

     def write(self):
         pass
 
+    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, vfstype):
         vfs = vfstype(path + '/store')