Mercurial > hg
comparison mercurial/branchmap.py @ 51534:767b62cb728e
branchcache: gather newly closed head in a dedicated set
This is part of a series to more clearly split the update in two step. This
will allow us to introduce a fast path during update in a future changeset.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 06 Mar 2024 16:10:44 +0100 |
parents | 50850689d3c0 |
children | 03247e37ccf7 |
comparison
equal
deleted
inserted
replaced
51533:50850689d3c0 | 51534:767b62cb728e |
---|---|
286 cl = repo.changelog | 286 cl = repo.changelog |
287 # Faster than using ctx.obsolete() | 287 # Faster than using ctx.obsolete() |
288 obsrevs = obsolete.getrevs(repo, b'obsolete') | 288 obsrevs = obsolete.getrevs(repo, b'obsolete') |
289 # collect new branch entries | 289 # collect new branch entries |
290 newbranches = {} | 290 newbranches = {} |
291 new_closed = set() | |
291 obs_ignored = set() | 292 obs_ignored = set() |
292 getbranchinfo = repo.revbranchcache().branchinfo | 293 getbranchinfo = repo.revbranchcache().branchinfo |
293 max_rev = -1 | 294 max_rev = -1 |
294 for r in revgen: | 295 for r in revgen: |
295 max_rev = max(max_rev, r) | 296 max_rev = max(max_rev, r) |
299 obs_ignored.add(r) | 300 obs_ignored.add(r) |
300 continue | 301 continue |
301 branch, closesbranch = getbranchinfo(r) | 302 branch, closesbranch = getbranchinfo(r) |
302 newbranches.setdefault(branch, []).append(r) | 303 newbranches.setdefault(branch, []).append(r) |
303 if closesbranch: | 304 if closesbranch: |
304 self._closednodes.add(cl.node(r)) | 305 new_closed.add(r) |
305 if max_rev < 0: | 306 if max_rev < 0: |
306 msg = "running branchcache.update without revision to update" | 307 msg = "running branchcache.update without revision to update" |
307 raise error.ProgrammingError(msg) | 308 raise error.ProgrammingError(msg) |
308 | 309 |
309 # Delay fetching the topological heads until they are needed. | 310 # Delay fetching the topological heads until they are needed. |
389 ancestors = set(cl.ancestors(uncertain, floorrev)) | 390 ancestors = set(cl.ancestors(uncertain, floorrev)) |
390 bheadset -= ancestors | 391 bheadset -= ancestors |
391 if bheadset: | 392 if bheadset: |
392 self[branch] = [cl.node(rev) for rev in sorted(bheadset)] | 393 self[branch] = [cl.node(rev) for rev in sorted(bheadset)] |
393 | 394 |
395 self._closednodes.update(cl.node(rev) for rev in new_closed) | |
396 | |
394 duration = util.timer() - starttime | 397 duration = util.timer() - starttime |
395 repo.ui.log( | 398 repo.ui.log( |
396 b'branchcache', | 399 b'branchcache', |
397 b'updated %s in %.4f seconds\n', | 400 b'updated %s in %.4f seconds\n', |
398 _branchcachedesc(repo), | 401 _branchcachedesc(repo), |