log: remove increasing windows usage in fastpath
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sat, 03 Jul 2010 18:11:15 +0900
changeset 11608 183e63112698
parent 11607 cc784ad8b3da
child 11609 890ad9d6a169
log: remove increasing windows usage in fastpath The purpose of increasing windows is to allow backwards iteration on the filelog at a reasonable cost. But is it needed? - if follow is False, we have no reason to iterate backwards. We basically just want to walk the complete filelog and yield all revisions within the revision range. We can do this forward or backwards, as it only reads the index. - when follow is True, we need to examine the contents of the filelog, and to do this efficiently we need to read the filelog forward. And on the other hand, to track ancestors and copies, we need to process revisions backwards. But is it necessary to use increasing windows for this? We can iterate over the complete filelog forward, stack the revisions, and read the reversed(pile), it does the same thing with a more readable code.
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Sat Jul 03 18:01:54 2010 +0900
+++ b/mercurial/cmdutil.py	Sat Jul 03 18:11:15 2010 +0900
@@ -1055,22 +1055,21 @@
         # Only files, no patterns.  Check the history of each file.
         def filerevgen(filelog, last):
             cl_count = len(repo)
-            for i, window in increasing_windows(last, nullrev):
-                revs = []
-                for j in xrange(i - window, i + 1):
-                    n = filelog.node(j)
-                    revs.append((filelog.linkrev(j),
-                                 follow and filelog.renamed(n)))
-                for rev in reversed(revs):
-                    linkrev = rev[0]
-                    if linkrev > maxrev:
-                        continue
-                    if linkrev < minrev:
-                        return
-                    # only yield rev for which we have the changelog, it can
-                    # happen while doing "hg log" during a pull or commit
-                    if linkrev < cl_count:
-                        yield rev
+            revs = []
+            for j in xrange(0, last+1):
+                linkrev = filelog.linkrev(j)
+                if linkrev < minrev:
+                    continue
+                # only yield rev for which we have the changelog, it can
+                # happen while doing "hg log" during a pull or commit
+                if linkrev > maxrev or linkrev >= cl_count:
+                    break
+                n = filelog.node(j)
+                revs.append((filelog.linkrev(j),
+                             follow and filelog.renamed(n)))
+
+            for rev in reversed(revs):
+                yield rev
         def iterfiles():
             for filename in match.files():
                 yield filename, None