[PATCH 2 of 3] localrepo: have branchheads function retrieve closed state from the cache
Steven Brown
stevengbrown at gmail.com
Tue Feb 7 14:48:34 UTC 2012
# HG changeset patch
# User Steven Brown <StevenGBrown at gmail.com>
# Date 1328545174 -28800
# Node ID 6f4515fea72870ab2d3938af7f6abb3b0839b727
# Parent 0a5cacc501b4c680832c5ab9c775321611a6015c
localrepo: have branchheads 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
8af9e08a094f: 8.07
before: 9.12
after: 6.90
with existing branchheads file
8af9e08a094f: 3.79
before: 3.81
after: 1.53
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1494,18 +1494,19 @@
'''
if branch is None:
branch = self[None].branch()
- branches = self.branchmap()
- if branch not in branches:
+ self.updatebranchcache()
+ if closed:
+ branches = self._branchcache.heads
+ else:
+ branches = self._branchcache.openheads
+ # the cache returns heads ordered lowest to highest
+ bheads = list(reversed(branches.get(branch, [])))
+ if not bheads:
return []
- # the cache returns heads ordered lowest to highest
- bheads = list(reversed(branches[branch]))
if start is not None:
# filter out the heads that cannot be reached from startrev
fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
bheads = [h for h in bheads if h in fbheads]
- if not closed:
- bheads = [h for h in bheads if
- ('close' not in self.changelog.read(h)[5])]
return bheads
def branches(self, nodes):
More information about the Mercurial-devel
mailing list