Patchwork [2,of,4] localrepo: factor out invalidation of @filecache properties to reuse

mail settings
Submitter Katsunori FUJIWARA
Date Sept. 2, 2016, 6:34 p.m.
Message ID <32f53aaf63f8db0c1352.1472841251@feefifofum>
Download mbox | patch
Permalink /patch/16536/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show


Katsunori FUJIWARA - Sept. 2, 2016, 6:34 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <>
# Date 1472840248 -32400
#      Sat Sep 03 03:17:28 2016 +0900
# Node ID 32f53aaf63f8db0c1352a3b0afb290c425486704
# Parent  b9866cdaf302d52a7ddafa60a8a8e5155a764342
localrepo: factor out invalidation of @filecache properties to reuse

streamclone wants to clear @filecache properties just after directly
writing changes into files, to avoid inconsistency between in-memory
cached properties and streamclone-ed files on disk.

On the other hand, it doesn't want to clear fncache before closing
transaction, because in-memory changes of fncache should be written
out as a part of a transaction.

Therefore, invalidate() isn't suitable for such purpose.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -1245,19 +1245,27 @@  class localrepository(object):
             delattr(self.unfiltered(), 'dirstate')
-    def invalidate(self, clearfilecache=False):
+    def invalidatefilecaches(self, clearcache):
+        '''Invalidate @filecache properties except for dirstate
+        If clearcache is true, this completely discards already cached
+        properties.
+        '''
         unfiltered = self.unfiltered() # all file caches are stored unfiltered
         for k in self._filecache.keys():
             # dirstate is invalidated separately in invalidatedirstate()
             if k == 'dirstate':
-            if clearfilecache:
+            if clearcache:
                 del self._filecache[k]
                 delattr(unfiltered, k)
             except AttributeError:
+    def invalidate(self, clearfilecache=False):
+        self.invalidatefilecaches(clearfilecache)