[PATCH 3 of 4] store: add new _exists helper function on fncachestore

Adrian Buehlmann adrian at cadifra.com
Fri Oct 12 04:02:04 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1350031952 -7200
# Node ID 23f54761eb31c5ab52f939bea98f78d396c7997c
# Parent  8d4e09b55f7a5e7a38113d51661ffd9a67a8731c
store: add new _exists helper function on fncachestore

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -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))


More information about the Mercurial-devel mailing list