Mercurial > hg-stable
changeset 51577:03247e37ccf7
branchcache: move the processing of the new data in a dedicated method
In a future changeset, this will allow the V3 of the branch cache to use a fast
path when possible.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 06 Mar 2024 16:18:03 +0100 |
parents | 767b62cb728e |
children | 718f28ea3af4 |
files | mercurial/branchmap.py |
diffstat | 1 files changed, 34 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/branchmap.py Wed Mar 06 16:10:44 2024 +0100 +++ b/mercurial/branchmap.py Wed Mar 06 16:18:03 2024 +0100 @@ -307,13 +307,46 @@ msg = "running branchcache.update without revision to update" raise error.ProgrammingError(msg) + self._process_new( + repo, + newbranches, + new_closed, + obs_ignored, + max_rev, + ) + + self._closednodes.update(cl.node(rev) for rev in new_closed) + + duration = util.timer() - starttime + repo.ui.log( + b'branchcache', + b'updated %s in %.4f seconds\n', + _branchcachedesc(repo), + duration, + ) + return max_rev + + def _process_new( + self, + repo, + newbranches, + new_closed, + obs_ignored, + max_rev, + ): + """update the branchmap from a set of new information""" # Delay fetching the topological heads until they are needed. # A repository without non-continous branches can skip this part. topoheads = None + cl = repo.changelog + getbranchinfo = repo.revbranchcache().branchinfo + # Faster than using ctx.obsolete() + obsrevs = obsolete.getrevs(repo, b'obsolete') + # If a changeset is visible, its parents must be visible too, so # use the faster unfiltered parent accessor. - parentrevs = repo.unfiltered().changelog.parentrevs + parentrevs = cl._uncheckedparentrevs for branch, newheadrevs in newbranches.items(): # For every branch, compute the new branchheads. @@ -392,17 +425,6 @@ if bheadset: self[branch] = [cl.node(rev) for rev in sorted(bheadset)] - self._closednodes.update(cl.node(rev) for rev in new_closed) - - duration = util.timer() - starttime - repo.ui.log( - b'branchcache', - b'updated %s in %.4f seconds\n', - _branchcachedesc(repo), - duration, - ) - return max_rev - STATE_CLEAN = 1 STATE_INHERITED = 2