[PATCH 09 of 17 RFC] clfilter: do not use branchmap cache if there are filtered changesets

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Sep 3 07:58:33 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1346675659 -7200
# Node ID 102543f9db9acd7309ee4d4de0bfa3c5cc67f2a2
# Parent  f4109d3aeff82a632b8ec13496a18a3b1b0c8574
clfilter: do not use branchmap cache if there are filtered changesets

If there are filtered changesets the cache is not valid. We'll have to cache
branchmap for filtered state too, but for now recomputing the branchmap is
enough.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -625,12 +625,19 @@ class localrepository(object):
         # this private cache holds all heads (not just the branch tips)
         self._branchcache = partial
 
     def branchmap(self):
         '''returns a dictionary {branch: [branchheads]}'''
-        self.updatebranchcache()
-        return self._branchcache
+        if self.changelog.filteredrevs:
+            # some changeset are excluded we can't use the cache
+            branchmap = {}
+            self._updatebranchcache(branchmap, (self[r] for r in self))
+            return branchmap
+        else:
+            self.updatebranchcache()
+            return self._branchcache
+
 
     def _branchtip(self, heads):
         '''return the tipmost branch head in heads'''
         tip = heads[-1]
         for h in reversed(heads):


More information about the Mercurial-devel mailing list