changeset 30706:2e4862646f02

repair: speed up stripping of many roots repair.strip() expects a set of root revisions to strip. It then builds the full set of descedants by walking the descandants of each. It is rare that more than a few roots get passed in, but if that happens, it will wastefully walk the changelog for each root. So let's just walk it once. I noticed this because the narrowhg extension was passing not only roots, but all the commits to strip. When there were tens of thousands of commits to strip, this resulted in quadratic behavior with that extension.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 04 Jan 2017 10:07:12 -0800
parents 06b17f6c6559
children 987dbe87aad6
files mercurial/repair.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repair.py	Fri Jan 06 09:56:40 2017 +0800
+++ b/mercurial/repair.py	Wed Jan 04 10:07:12 2017 -0800
@@ -99,9 +99,9 @@
     # (head = revision in the set that has no descendant in the set;
     #  base = revision in the set that has no ancestor in the set)
     tostrip = set(striplist)
-    for rev in striplist:
-        for desc in cl.descendants([rev]):
-            tostrip.add(desc)
+    for r in cl.revs(start=striprev + 1):
+        if any(p in tostrip for p in cl.parentrevs(r)):
+            tostrip.add(r)
 
     files = _collectfiles(repo, striprev)
     saverevs = _collectbrokencsets(repo, files, striprev)