# HG changeset patch # User Pierre-Yves David # Date 1709736862 -3600 # Node ID a0ef462cf1a4f4ab92e88260c0c19bd73f8a7547 # Parent f85f23f1479bd47684aee0e8b747e1aba81ab7a9 branchcache: filter obsolete revisions sooner Since we won't do anything with the obsolete revisions, we can just ignore them sooner. diff -r f85f23f1479b -r a0ef462cf1a4 mercurial/branchmap.py --- a/mercurial/branchmap.py Thu Mar 07 10:55:22 2024 +0100 +++ b/mercurial/branchmap.py Wed Mar 06 15:54:22 2024 +0100 @@ -284,16 +284,22 @@ """ starttime = util.timer() cl = repo.changelog + # Faster than using ctx.obsolete() + obsrevs = obsolete.getrevs(repo, b'obsolete') # collect new branch entries newbranches = {} getbranchinfo = repo.revbranchcache().branchinfo max_rev = -1 for r in revgen: + max_rev = max(max_rev, r) + if r in obsrevs: + # We ignore obsolete changesets as they shouldn't be + # considered heads. + continue branch, closesbranch = getbranchinfo(r) newbranches.setdefault(branch, []).append(r) if closesbranch: self._closednodes.add(cl.node(r)) - max_rev = max(max_rev, r) if max_rev < 0: msg = "running branchcache.update without revision to update" raise error.ProgrammingError(msg) @@ -306,9 +312,6 @@ # use the faster unfiltered parent accessor. parentrevs = repo.unfiltered().changelog.parentrevs - # Faster than using ctx.obsolete() - obsrevs = obsolete.getrevs(repo, b'obsolete') - for branch, newheadrevs in newbranches.items(): # For every branch, compute the new branchheads. # A branchhead is a revision such that no descendant is on @@ -349,11 +352,6 @@ bheadset = {cl.rev(node) for node in bheads} uncertain = set() for newrev in sorted(newheadrevs): - if newrev in obsrevs: - # We ignore obsolete changesets as they shouldn't be - # considered heads. - continue - if not bheadset: bheadset.add(newrev) continue