[PATCH 2 of 5] branchmap: stop membership test in update logic
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Mon Jan 6 19:38:24 CST 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1358276652 -3600
# Tue Jan 15 20:04:12 2013 +0100
# Node ID 96ce837f46741b94641452b48fec41c540a59231
# Parent 4dcd2535942b73c76560a8be6b679dedbc0f2cb7
branchmap: stop membership test in update logic
Now that no user try to update the cache on a truncated repo we can drop the
extra lookup. Give an handfull percent speedup on big branchmap update.
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -232,18 +232,12 @@ class branchcache(dict):
# if older branchheads are reachable from new ones, they aren't
# really branchheads. Note checking parents is insufficient:
# 1 (branch a) -> 2 (branch b) -> 3 (branch a)
for branch, newnodes in newbranches.iteritems():
bheads = self.setdefault(branch, [])
- # Remove candidate heads that no longer are in the repo (e.g., as
- # the result of a strip that just happened). Avoid using 'node in
- # self' here because that dives down into branchcache code somewhat
- # recursively.
- bheadrevs = [cl.rev(node) for node in bheads
- if cl.hasnode(node)]
- newheadrevs = [cl.rev(node) for node in newnodes
- if cl.hasnode(node)]
+ bheadrevs = [cl.rev(node) for node in bheads]
+ newheadrevs = [cl.rev(node) for node in newnodes]
ctxisnew = bheadrevs and min(newheadrevs) > max(bheadrevs)
# Remove duplicates - nodes that are in newheadrevs and are already
# in bheadrevs. This can happen if you strip a node whose parent
# was already a head (because they're on different branches).
bheadrevs = sorted(set(bheadrevs).union(newheadrevs))
More information about the Mercurial-devel
mailing list