log: slowpath: do not read the full changelog
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sun, 04 Jul 2010 18:07:30 +0900
changeset 11609 890ad9d6a169
parent 11608 183e63112698
child 11610 26175823b9d4
log: slowpath: do not read the full changelog When in the slowpath, we are examining _all_ changesets in revs. We need to order reads so they happen increasingly for I/O performance. Increasing windows were used to read changelog backwards in a windowed manner, reading the changelog forward inside each window. But since no revision range was specified, it was equivalent to reading the full changelog, even if a single revision was passed to the commandline. When --removed is used, we _need_ to scan all changesets, but if we're only looking for file patterns, this is not necessary and we can stick to the revspec that was given to us.
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Sat Jul 03 18:11:15 2010 +0900
+++ b/mercurial/cmdutil.py	Sun Jul 04 18:07:30 2010 +0900
@@ -1106,16 +1106,20 @@
                                'filenames'))
 
         # The slow path checks files modified in every changeset.
-        def changerevgen():
-            for i, window in increasing_windows(len(repo) - 1, nullrev):
-                for j in xrange(i - window, i + 1):
-                    yield change(j)
-
-        for ctx in changerevgen():
+        if opts.get('removed'):
+            # --removed wants to yield the changes where the file
+            # was removed, this means that we have to explore all
+            # changesets, effectively ignoring the revisions that
+            # had been passed as arguments
+            revrange = xrange(nullrev, len(repo) - 1)
+        else:
+            revrange = sorted(revs)
+        for i in revrange:
+            ctx = change(i)
             matches = filter(match, ctx.files())
             if matches:
-                fncache[ctx.rev()] = matches
-                wanted.add(ctx.rev())
+                fncache[i] = matches
+                wanted.add(i)
 
     class followfilter(object):
         def __init__(self, onlyfirst=False):