comparison mercurial/cmdutil.py @ 11632:f418d2570920

log: document the different phases in walkchangerevs
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Tue, 20 Jul 2010 14:32:33 +0900
parents dbb98d8fbcaf
children 09147c065711
comparison
equal deleted inserted replaced
11631:dbb98d8fbcaf 11632:f418d2570920
1043 wanted = set() 1043 wanted = set()
1044 slowpath = match.anypats() or (match.files() and opts.get('removed')) 1044 slowpath = match.anypats() or (match.files() and opts.get('removed'))
1045 fncache = {} 1045 fncache = {}
1046 change = util.cachefunc(repo.changectx) 1046 change = util.cachefunc(repo.changectx)
1047 1047
1048 # First step is to fill wanted, the set of revisions that we want to yield.
1049 # When it does not induce extra cost, we also fill fncache for revisions in
1050 # wanted: a cache of filenames that were changed (ctx.files()) and that
1051 # match the file filtering conditions.
1052
1048 if not slowpath and not match.files(): 1053 if not slowpath and not match.files():
1049 # No files, no patterns. Display all revs. 1054 # No files, no patterns. Display all revs.
1050 wanted = set(revs) 1055 wanted = set(revs)
1051 copies = [] 1056 copies = []
1052 1057
1053 if not slowpath: 1058 if not slowpath:
1059 # We only have to read through the filelog to find wanted revisions
1060
1054 minrev, maxrev = min(revs), max(revs) 1061 minrev, maxrev = min(revs), max(revs)
1055 # Only files, no patterns. Check the history of each file. 1062 # Only files, no patterns. Check the history of each file.
1056 def filerevgen(filelog, last): 1063 def filerevgen(filelog, last):
1057 cl_count = len(repo) 1064 cl_count = len(repo)
1058 revs = [] 1065 revs = []
1099 fncache[rev].append(file_) 1106 fncache[rev].append(file_)
1100 wanted.add(rev) 1107 wanted.add(rev)
1101 if copied: 1108 if copied:
1102 copies.append(copied) 1109 copies.append(copied)
1103 if slowpath: 1110 if slowpath:
1111 # We have to read the changelog to match filenames against
1112 # changed files
1113
1104 if follow: 1114 if follow:
1105 raise util.Abort(_('can only follow copies/renames for explicit ' 1115 raise util.Abort(_('can only follow copies/renames for explicit '
1106 'filenames')) 1116 'filenames'))
1107 1117
1108 # The slow path checks files modified in every changeset. 1118 # The slow path checks files modified in every changeset.
1158 stop = min(revs[0], revs[-1]) 1168 stop = min(revs[0], revs[-1])
1159 for x in xrange(rev, stop - 1, -1): 1169 for x in xrange(rev, stop - 1, -1):
1160 if ff.match(x): 1170 if ff.match(x):
1161 wanted.discard(x) 1171 wanted.discard(x)
1162 1172
1173 # Now that wanted is correctly initialized, we can iterate over the
1174 # revision range, yielding only revisions in wanted.
1163 def iterate(): 1175 def iterate():
1164 if follow and not match.files(): 1176 if follow and not match.files():
1165 ff = followfilter(onlyfirst=opts.get('follow_first')) 1177 ff = followfilter(onlyfirst=opts.get('follow_first'))
1166 def want(rev): 1178 def want(rev):
1167 return ff.match(rev) and rev in wanted 1179 return ff.match(rev) and rev in wanted