fncache: remove the rewriting logic
authorDurham Goode <durham@fb.com>
Mon, 24 Mar 2014 15:31:47 -0700
changeset 20879 cd03854a2e06
parent 20878 09e7118715eb
child 20880 925c2d604389
fncache: remove the rewriting logic The fncache could rewrite itself during a read operation if it noticed any entries that were no longer on disk. This was problematic because it caused Mercurial to perform write operations outside the scope of a lock or transaction, which could interefere with any other pending writes. This will be replaced in a future patch by logic that cleans up the fncache as files are deleted during strips.
mercurial/store.py
--- a/mercurial/store.py	Wed Mar 26 15:55:32 2014 -0700
+++ b/mercurial/store.py	Mon Mar 24 15:31:47 2014 -0700
@@ -402,20 +402,13 @@
                     raise util.Abort(t)
         fp.close()
 
-    def _write(self, files, atomictemp):
-        fp = self.vfs('fncache', mode='wb', atomictemp=atomictemp)
-        if files:
-            fp.write(encodedir('\n'.join(files) + '\n'))
-        fp.close()
-        self._dirty = False
-
-    def rewrite(self, files):
-        self._write(files, False)
-        self.entries = set(files)
-
     def write(self):
         if self._dirty:
-            self._write(self.entries, True)
+            fp = self.vfs('fncache', mode='wb', atomictemp=True)
+            if self.entries:
+                fp.write(encodedir('\n'.join(self.entries) + '\n'))
+            fp.close()
+            self._dirty = False
 
     def add(self, fn):
         if self.entries is None:
@@ -476,7 +469,6 @@
         return self.rawvfs.stat(path).st_size
 
     def datafiles(self):
-        rewrite = False
         existing = []
         for f in sorted(self.fncache):
             ef = self.encode(f)
@@ -486,12 +478,6 @@
             except OSError, err:
                 if err.errno != errno.ENOENT:
                     raise
-                # nonexistent entry
-                rewrite = True
-        if rewrite:
-            # rewrite fncache to remove nonexistent entries
-            # (may be caused by rollback / strip)
-            self.fncache.rewrite(existing)
 
     def copylist(self):
         d = ('data dh fncache phaseroots obsstore'