[PATCH 1 of 2] cmdutil: use a small initial window with --limit
Bryan O'Sullivan
bos at serpentine.com
Tue Feb 19 17:47:06 CST 2013
# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1361317585 28800
# Node ID 77b02f572b752fcbec87f576564880ec1dc9023b
# Parent aeca36ccd9a5c9dc5894fdd5456c3eb29a65b672
cmdutil: use a small initial window with --limit
In a large repo, running a command like "log -l1 -p" was expensive because
it would always traverse 8 commits, as 8 was the initial window size.
We now choose the lesser of 8 or the limit, speeding up the "log -l1 -p"
case by a factor of 5.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1210,6 +1210,13 @@ def walkchangerevs(repo, match, opts, pr
if ff.match(x):
wanted.discard(x)
+ # Choose a small initial window if we will probably only visit a
+ # few commits.
+ limit = loglimit(opts)
+ windowsize = 8
+ if limit:
+ windowsize = min(limit, windowsize)
+
# Now that wanted is correctly initialized, we can iterate over the
# revision range, yielding only revisions in wanted.
def iterate():
@@ -1221,7 +1228,7 @@ def walkchangerevs(repo, match, opts, pr
def want(rev):
return rev in wanted
- for i, window in increasingwindows(0, len(revs)):
+ for i, window in increasingwindows(0, len(revs), windowsize):
nrevs = [rev for rev in revs[i:i + window] if want(rev)]
for rev in sorted(nrevs):
fns = fncache.get(rev)
More information about the Mercurial-devel
mailing list