[PATCH 3 of 3] localrepo: have branchtags function retrieve closed state from the cache
Steven Brown
stevengbrown at gmail.com
Tue Feb 7 14:48:35 UTC 2012
# HG changeset patch
# User Steven Brown <StevenGBrown at gmail.com>
# Date 1328545201 -28800
# Node ID 65c9ec797bc4ed44df5e70db6d75428a899e1230
# Parent 6f4515fea72870ab2d3938af7f6abb3b0839b727
localrepo: have branchtags function retrieve closed state from the cache
Average time in seconds over 10 runs of ‘hg branches’ with and without an
existing branchheads file. Repo has 10,000 named branches (bitbucket.org/mg/10k)
no existing branchheads file
before: 6.90
after: 5.93
with existing branchheads file
before: 1.53
after: 0.57
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -512,14 +512,12 @@
def branchtags(self):
'''return a dict where branch names map to the tipmost head of
the branch, open heads come before closed'''
+ self.updatebranchcache()
bt = {}
- for bn, heads in self.branchmap().iteritems():
- tip = heads[-1]
- for h in reversed(heads):
- if 'close' not in self.changelog.read(h)[5]:
- tip = h
- break
- bt[bn] = tip
+ for bn, heads in self._branchcache.openheads.iteritems():
+ if not heads:
+ heads = self._branchcache.heads[bn]
+ bt[bn] = heads[-1]
return bt
def _readbranchcache(self):
More information about the Mercurial-devel
mailing list