store: add new _exists helper function on fncachestore
authorAdrian Buehlmann <adrian@cadifra.com>
Fri, 12 Oct 2012 10:52:32 +0200
changeset 17783 df55ce6854c3
parent 17782 8095306c1fb2
child 17784 73e1ab39792c
store: add new _exists helper function on fncachestore
mercurial/store.py
--- a/mercurial/store.py	Fri Oct 12 10:40:09 2012 +0200
+++ b/mercurial/store.py	Fri Oct 12 10:52:32 2012 +0200
@@ -512,6 +512,17 @@
     def write(self):
         self.fncache.write()
 
+    def _exists(self, f):
+        ef = self.encode(f)
+        try:
+            self.getsize(ef)
+            return True
+        except OSError, err:
+            if err.errno != errno.ENOENT:
+                raise
+            # nonexistent entry
+            return False
+
     def __contains__(self, path):
         '''Checks if the store contains path'''
         path = "/".join(("data", path))