mercurial/cmdutil.py
changeset 18710 49ef9d0ca815
parent 18688 79107fad06aa
child 18852 300844cb1a56
--- a/mercurial/cmdutil.py	Wed Feb 20 11:31:34 2013 -0800
+++ b/mercurial/cmdutil.py	Wed Feb 20 11:31:38 2013 -0800
@@ -1210,6 +1210,13 @@
             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 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)