Mercurial > public > mercurial-scm > hg-stable
diff mercurial/repair.py @ 20074:5fc2ae1c631b
strip: add faster revlog strip computation
The previous revlog strip computation would walk every rev in the revlog, from
the bottom to the top. Since we're usually stripping only the top few revs of
the revlog, this was needlessly expensive on large repos.
The new algorithm walks the exact number of revs that will be stripped, thus
making the operation not dependent on the number of revs in the repo.
This makes amend on a large repo go from 8.7 seconds to 6 seconds.
author | Durham Goode <durham@fb.com> |
---|---|
date | Mon, 11 Nov 2013 16:42:49 -0800 |
parents | 64b5562550e2 |
children | f49d60fa40a5 |
line wrap: on
line diff
--- a/mercurial/repair.py Mon Nov 11 16:40:02 2013 -0800 +++ b/mercurial/repair.py Mon Nov 11 16:42:49 2013 -0800 @@ -38,16 +38,8 @@ """return the changesets which will be broken by the truncation""" s = set() def collectone(revlog): - linkgen = (revlog.linkrev(i) for i in revlog) - # find the truncation point of the revlog - for lrev in linkgen: - if lrev >= striprev: - break - # see if any revision after this point has a linkrev - # less than striprev (those will be broken by strip) - for lrev in linkgen: - if lrev < striprev: - s.add(lrev) + _, brokenset = revlog.getstrippoint(striprev) + s.update([revlog.linkrev(r) for r in brokenset]) collectone(repo.manifest) for fname in files: