--- a/mercurial/hbisect.py Mon Jul 25 15:39:04 2022 +0200
+++ b/mercurial/hbisect.py Tue Aug 30 15:29:55 2022 -0400
@@ -115,11 +115,21 @@
poison.update(children.get(rev, []))
continue
+ unvisited = []
for c in children.get(rev, []):
if ancestors[c]:
ancestors[c] = list(set(ancestors[c] + a))
else:
+ unvisited.append(c)
+
+ # Reuse existing ancestor list for the first unvisited child to avoid
+ # excessive copying for linear portions of history.
+ if unvisited:
+ first = unvisited.pop(0)
+ for c in unvisited:
ancestors[c] = a + [c]
+ a.append(first)
+ ancestors[first] = a
assert best_rev is not None
best_node = changelog.node(best_rev)