comparison mercurial/branchmap.py @ 40375:76d4272bd57b

branchmap: avoid changelog and attribute lookups in replacecache() This should make things faster. I'm not sure which operations would benefit from it though. Maybe branchmap application on clone? Differential Revision: https://phab.mercurial-scm.org/D5162
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 19 Oct 2018 16:34:45 +0200
parents 47c03042cd1d
children 5e5c8f2a1eb5
comparison
equal deleted inserted replaced
40374:47c03042cd1d 40375:76d4272bd57b
128 def replacecache(repo, bm): 128 def replacecache(repo, bm):
129 """Replace the branchmap cache for a repo with a branch mapping. 129 """Replace the branchmap cache for a repo with a branch mapping.
130 130
131 This is likely only called during clone with a branch map from a remote. 131 This is likely only called during clone with a branch map from a remote.
132 """ 132 """
133 cl = repo.changelog
134 clrev = cl.rev
135 clbranchinfo = cl.branchinfo
133 rbheads = [] 136 rbheads = []
134 closed = [] 137 closed = []
135 for bheads in bm.itervalues(): 138 for bheads in bm.itervalues():
136 rbheads.extend(bheads) 139 rbheads.extend(bheads)
137 for h in bheads: 140 for h in bheads:
138 r = repo.changelog.rev(h) 141 r = clrev(h)
139 b, c = repo.changelog.branchinfo(r) 142 b, c = clbranchinfo(r)
140 if c: 143 if c:
141 closed.append(h) 144 closed.append(h)
142 145
143 if rbheads: 146 if rbheads:
144 rtiprev = max((int(repo.changelog.rev(node)) 147 rtiprev = max((int(clrev(node))
145 for node in rbheads)) 148 for node in rbheads))
146 cache = branchcache(bm, 149 cache = branchcache(bm,
147 repo[rtiprev].node(), 150 repo[rtiprev].node(),
148 rtiprev, 151 rtiprev,
149 closednodes=closed) 152 closednodes=closed)