# HG changeset patch # User Pierre-Yves David # Date 1709738283 -3600 # Node ID 03247e37ccf77022575bae9cf4fe68979a1f3979 # Parent 767b62cb728e1af79ab5a23dce643529a35fe547 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. diff -r 767b62cb728e -r 03247e37ccf7 mercurial/branchmap.py --- 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