Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 20262:cf450ee3f8f7
branchmap: stop useless rev -> node -> rev round trip
We never use the node of new revisions unless in the very specific case of
closed heads. So we can just use the revision number.
So give another handfull of percent speedup.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Fri, 03 Jan 2014 16:44:23 -0800 |
parents | 3fee302a48e6 |
children | ea4996754d91 |
comparison
equal
deleted
inserted
replaced
20261:3fee302a48e6 | 20262:cf450ee3f8f7 |
---|---|
228 # collect new branch entries | 228 # collect new branch entries |
229 newbranches = {} | 229 newbranches = {} |
230 getbranchinfo = cl.branchinfo | 230 getbranchinfo = cl.branchinfo |
231 for r in revgen: | 231 for r in revgen: |
232 branch, closesbranch = getbranchinfo(r) | 232 branch, closesbranch = getbranchinfo(r) |
233 node = cl.node(r) | 233 newbranches.setdefault(branch, []).append(r) |
234 newbranches.setdefault(branch, []).append(node) | |
235 if closesbranch: | 234 if closesbranch: |
236 self._closednodes.add(node) | 235 self._closednodes.add(cl.node(r)) |
237 # if older branchheads are reachable from new ones, they aren't | 236 # if older branchheads are reachable from new ones, they aren't |
238 # really branchheads. Note checking parents is insufficient: | 237 # really branchheads. Note checking parents is insufficient: |
239 # 1 (branch a) -> 2 (branch b) -> 3 (branch a) | 238 # 1 (branch a) -> 2 (branch b) -> 3 (branch a) |
240 for branch, newnodes in newbranches.iteritems(): | 239 for branch, newheadrevs in newbranches.iteritems(): |
241 bheads = self.setdefault(branch, []) | 240 bheads = self.setdefault(branch, []) |
242 bheadrevs = [cl.rev(node) for node in bheads] | 241 bheadrevs = [cl.rev(node) for node in bheads] |
243 newheadrevs = [cl.rev(node) for node in newnodes] | |
244 ctxisnew = bheadrevs and min(newheadrevs) > max(bheadrevs) | 242 ctxisnew = bheadrevs and min(newheadrevs) > max(bheadrevs) |
245 # Remove duplicates - nodes that are in newheadrevs and are already | 243 # Remove duplicates - nodes that are in newheadrevs and are already |
246 # in bheadrevs. This can happen if you strip a node whose parent | 244 # in bheadrevs. This can happen if you strip a node whose parent |
247 # was already a head (because they're on different branches). | 245 # was already a head (because they're on different branches). |
248 bheadrevs = sorted(set(bheadrevs).union(newheadrevs)) | 246 bheadrevs = sorted(set(bheadrevs).union(newheadrevs)) |