diff mercurial/branchmap.py @ 18189:b9026ba002f6

branchmap: enable caching for filtered version too The `_branchcache` attribute is turned into a dictionary. Key are filter name and value is a `branchcache` object. Unfiltered version is cached as `None` filter. The attribute is renamed to `_branchcaches` to avoid confusion with the previous one. Both old and new contents are dictionary even if their contents are different. I prefer possible extension code to crash right away instead of just messing the wrong dictionary. As all different caches work isolated to each other, this code keeps the previous behavior of using the unfiltered cache we nothing is filtered. This is a cheap way to have cache collaborate and nullify potential impact in the default case.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 24 Dec 2012 03:21:15 +0100
parents 46ed5226503a
children 493778b5fe9f
line wrap: on
line diff
--- a/mercurial/branchmap.py	Tue Jan 01 21:27:13 2013 +0100
+++ b/mercurial/branchmap.py	Mon Dec 24 03:21:15 2012 +0100
@@ -59,9 +59,9 @@
 
 
 def updatecache(repo):
-    repo = repo.unfiltered()  # Until we get a smarter cache management
     cl = repo.changelog
-    partial = repo._branchcache
+    filtername = repo.filtername
+    partial = repo._branchcaches.get(filtername)
 
     if partial is None or not partial.validfor(repo):
         partial = read(repo)
@@ -81,7 +81,7 @@
     if partial.tiprev < tiprev:
         ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, tiprev))
         partial.update(repo, ctxgen)
-    repo._branchcache = partial
+    repo._branchcaches[repo.filtername] = partial
 
 class branchcache(dict):
     """A dict like object that hold branches heads cache"""