comparison mercurial/branchmap.py @ 20261:3fee302a48e6

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.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 15 Jan 2013 20:04:12 +0100
parents 586ec8fe1c3c
children cf450ee3f8f7
comparison
equal deleted inserted replaced
20260:586ec8fe1c3c 20261:3fee302a48e6
237 # if older branchheads are reachable from new ones, they aren't 237 # if older branchheads are reachable from new ones, they aren't
238 # really branchheads. Note checking parents is insufficient: 238 # really branchheads. Note checking parents is insufficient:
239 # 1 (branch a) -> 2 (branch b) -> 3 (branch a) 239 # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
240 for branch, newnodes in newbranches.iteritems(): 240 for branch, newnodes in newbranches.iteritems():
241 bheads = self.setdefault(branch, []) 241 bheads = self.setdefault(branch, [])
242 # Remove candidate heads that no longer are in the repo (e.g., as 242 bheadrevs = [cl.rev(node) for node in bheads]
243 # the result of a strip that just happened). Avoid using 'node in 243 newheadrevs = [cl.rev(node) for node in newnodes]
244 # self' here because that dives down into branchcache code somewhat
245 # recursively.
246 bheadrevs = [cl.rev(node) for node in bheads
247 if cl.hasnode(node)]
248 newheadrevs = [cl.rev(node) for node in newnodes
249 if cl.hasnode(node)]
250 ctxisnew = bheadrevs and min(newheadrevs) > max(bheadrevs) 244 ctxisnew = bheadrevs and min(newheadrevs) > max(bheadrevs)
251 # Remove duplicates - nodes that are in newheadrevs and are already 245 # Remove duplicates - nodes that are in newheadrevs and are already
252 # in bheadrevs. This can happen if you strip a node whose parent 246 # in bheadrevs. This can happen if you strip a node whose parent
253 # was already a head (because they're on different branches). 247 # was already a head (because they're on different branches).
254 bheadrevs = sorted(set(bheadrevs).union(newheadrevs)) 248 bheadrevs = sorted(set(bheadrevs).union(newheadrevs))