# HG changeset patch # User Martin von Zweigbergk # Date 1483553232 28800 # Node ID 2e4862646f02261bc8ad5198c33ef36f88947678 # Parent 06b17f6c6559ccbb5d71551435fada215dbf06a6 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. diff -r 06b17f6c6559 -r 2e4862646f02 mercurial/repair.py --- 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)