Mercurial > public > mercurial-scm > hg
comparison mercurial/branchmap.py @ 22356:3c8fb24334e9
branchmap: issue a single call to `ancestors` for all heads
There is no reason to make multiple calls. This provides a massive speedup for
repo with a lot of heads.
On a strongly headed repo this gives humble speedup in simple case:
from 8.1097 to 5.1051
And massive speedup in other case:
from 7.8787 to 0.1984
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 30 Aug 2014 12:20:50 +0200 |
parents | d5cef58d8ec8 |
children | 9c3c3dc14a65 |
comparison
equal
deleted
inserted
replaced
22355:731b2a90983b | 22356:3c8fb24334e9 |
---|---|
250 # run it again in case of doubt | 250 # run it again in case of doubt |
251 # assert not (set(bheadrevs) & set(newheadrevs)) | 251 # assert not (set(bheadrevs) & set(newheadrevs)) |
252 newheadrevs.sort() | 252 newheadrevs.sort() |
253 bheadset.update(newheadrevs) | 253 bheadset.update(newheadrevs) |
254 | 254 |
255 # This loop prunes out two kinds of heads - heads that are | 255 # This prunes out two kinds of heads - heads that are superseded by |
256 # superseded by a head in newheadrevs, and newheadrevs that are not | 256 # a head in newheadrevs, and newheadrevs that are not heads because |
257 # heads because an existing head is their descendant. | 257 # an existing head is their descendant. |
258 while newheadrevs: | 258 ancestors = set(cl.ancestors(newheadrevs, min(bheadset))) |
259 latest = newheadrevs.pop() | 259 bheadset -= ancestors |
260 if latest not in bheadset: | |
261 continue | |
262 ancestors = set(cl.ancestors([latest], min(bheadset))) | |
263 bheadset -= ancestors | |
264 bheadrevs = sorted(bheadset) | 260 bheadrevs = sorted(bheadset) |
265 self[branch] = [cl.node(rev) for rev in bheadrevs] | 261 self[branch] = [cl.node(rev) for rev in bheadrevs] |
266 tiprev = bheadrevs[-1] | 262 tiprev = bheadrevs[-1] |
267 if tiprev > self.tiprev: | 263 if tiprev > self.tiprev: |
268 self.tipnode = cl.node(tiprev) | 264 self.tipnode = cl.node(tiprev) |