diff mercurial/localrepo.py @ 33302:36a415b5a4b2

localrepo: add sparse caches The sparse extension maintains caches for the sparse files to a signature and a signature to a matcher. This allows the sparse matchers to be resolved quickly, which is apparently something that can occur in loops. This patch ports the sparse caches to the localrepo class pretty much as-is. There is potentially room to improve the caching mechanism. But that can be done as a follow-up. The default invalidatecaches() now clears the relevant sparse cache. invalidatesignaturecache() has been moved to sparse.py.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 06 Jul 2017 12:20:53 -0700
parents 87bca10a06ed
children 4672db164c98
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu Jul 06 12:26:04 2017 -0700
+++ b/mercurial/localrepo.py	Thu Jul 06 12:20:53 2017 -0700
@@ -422,6 +422,11 @@
         # generic mapping between names and nodes
         self.names = namespaces.namespaces()
 
+        # Key to signature value.
+        self._sparsesignaturecache = {}
+        # Signature to cached matcher instance.
+        self._sparsematchercache = {}
+
     def close(self):
         self._writecaches()
 
@@ -1300,6 +1305,7 @@
 
         self.unfiltered()._branchcaches.clear()
         self.invalidatevolatilesets()
+        self._sparsesignaturecache.clear()
 
     def invalidatevolatilesets(self):
         self.filteredrevcache.clear()