Patchwork [6,of,7,V3] caches: invalidate store caches when lock is taken

login
register
mail settings
Submitter Durham Goode
Date April 1, 2014, 10:24 p.m.
Message ID <a7b48af9ed3c28d20621.1396391056@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/4191/
State Accepted
Commit 2efdd186925d64b2c869c07ea27804a1c549ae20
Headers show

Comments

Durham Goode - April 1, 2014, 10:24 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1395700507 25200
#      Mon Mar 24 15:35:07 2014 -0700
# Node ID a7b48af9ed3c28d20621406f90e7dddf3c4a3561
# Parent  24b8c6cd26c12a817cc316d2709d83611b684972
caches: invalidate store caches when lock is taken

The fncache was not being properly invalidated each time the lock was taken, so
in theory it could contain old data from prior to the caller having the lock.
This changes it to be invalidated as soon as the lock is taken (same as all our
other caches).

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -996,6 +996,7 @@ 
             except AttributeError:
                 pass
         self.invalidatecaches()
+        self.store.invalidatecaches()
 
     def invalidateall(self):
         '''Fully invalidates both store and non-store parts, causing the
diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -340,6 +340,9 @@ 
     def write(self, tr):
         pass
 
+    def invalidatecaches(self):
+        pass
+
     def __contains__(self, path):
         '''Checks if the store contains path'''
         path = "/".join(("data", path))
@@ -489,6 +492,9 @@ 
     def write(self, tr):
         self.fncache.write(tr)
 
+    def invalidatecaches(self):
+        self.fncache.entries = None
+
     def _exists(self, f):
         ef = self.encode(f)
         try: