# HG changeset patch # User Nicolas Dumazet # Date 2010-07-03 09:11:15 # Node ID 183e63112698586e73ff7772470c65b78ee3ee22 # Parent cc784ad8b3da99bf7240fabfa2986c86df908f46 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. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1055,22 +1055,21 @@ def walkchangerevs(repo, match, opts, pr # 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