##// END OF EJS Templates
walkchangerevs: pull out matchfn...
Matt Mackall -
r9652:2cb0cab1 default
parent child Browse files
Show More
@@ -54,8 +54,8 b' def countrate(ui, repo, amap, *pats, **o'
54 54 df = util.matchdate(opts['date'])
55 55
56 56 get = util.cachefunc(lambda r: repo[r])
57 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
58 for st, rev, fns in changeiter:
57 m = cmdutil.match(repo, pats, opts)
58 for st, rev, fns in cmdutil.walkchangerevs(ui, repo, m, get, opts):
59 59
60 60 if not st == 'add':
61 61 continue
@@ -1024,9 +1024,9 b' def finddate(ui, repo, date):'
1024 1024 """Find the tipmost changeset that matches the given date spec"""
1025 1025 df = util.matchdate(date)
1026 1026 get = util.cachefunc(lambda r: repo[r])
1027 changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None})
1027 m = matchall(repo)
1028 1028 results = {}
1029 for st, rev, fns in changeiter:
1029 for st, rev, fns in walkchangerevs(ui, repo, m, get, {'rev':None}):
1030 1030 if st == 'add':
1031 1031 d = get(rev).date()
1032 1032 if df(d[0]):
@@ -1039,7 +1039,7 b' def finddate(ui, repo, date):'
1039 1039
1040 1040 raise util.Abort(_("revision matching date not found"))
1041 1041
1042 def walkchangerevs(ui, repo, pats, change, opts):
1042 def walkchangerevs(ui, repo, match, change, opts):
1043 1043 '''Iterate over files and the revs in which they changed.
1044 1044
1045 1045 Callers most commonly need to iterate backwards over the history
@@ -1050,8 +1050,8 b' def walkchangerevs(ui, repo, pats, chang'
1050 1050 window, we first walk forwards to gather data, then in the desired
1051 1051 order (usually backwards) to display it.
1052 1052
1053 This function returns an (iterator, matchfn) tuple. The iterator
1054 yields 3-tuples. They will be of one of the following forms:
1053 This function returns an iterator. The iterator yields 3-tuples.
1054 They will be of one of the following forms:
1055 1055
1056 1056 "window", incrementing, lastrev: stepping through a window,
1057 1057 positive if walking forwards through revs, last rev in the
@@ -1078,11 +1078,10 b' def walkchangerevs(ui, repo, pats, chang'
1078 1078 if windowsize < sizelimit:
1079 1079 windowsize *= 2
1080 1080
1081 m = match(repo, pats, opts)
1082 1081 follow = opts.get('follow') or opts.get('follow_first')
1083 1082
1084 1083 if not len(repo):
1085 return [], m
1084 return []
1086 1085
1087 1086 if follow:
1088 1087 defrange = '%s:0' % repo['.'].rev()
@@ -1090,10 +1089,10 b' def walkchangerevs(ui, repo, pats, chang'
1090 1089 defrange = '-1:0'
1091 1090 revs = revrange(repo, opts['rev'] or [defrange])
1092 1091 wanted = set()
1093 slowpath = m.anypats() or (m.files() and opts.get('removed'))
1092 slowpath = match.anypats() or (match.files() and opts.get('removed'))
1094 1093 fncache = {}
1095 1094
1096 if not slowpath and not m.files():
1095 if not slowpath and not match.files():
1097 1096 # No files, no patterns. Display all revs.
1098 1097 wanted = set(revs)
1099 1098 copies = []
@@ -1117,7 +1116,7 b' def walkchangerevs(ui, repo, pats, chang'
1117 1116 if rev[0] < cl_count:
1118 1117 yield rev
1119 1118 def iterfiles():
1120 for filename in m.files():
1119 for filename in match.files():
1121 1120 yield filename, None
1122 1121 for filename_node in copies:
1123 1122 yield filename_node
@@ -1157,7 +1156,7 b' def walkchangerevs(ui, repo, pats, chang'
1157 1156 yield change(j)
1158 1157
1159 1158 for ctx in changerevgen():
1160 matches = filter(m, ctx.files())
1159 matches = filter(match, ctx.files())
1161 1160 if matches:
1162 1161 fncache[ctx.rev()] = matches
1163 1162 wanted.add(ctx.rev())
@@ -1210,7 +1209,7 b' def walkchangerevs(ui, repo, pats, chang'
1210 1209 wanted.discard(x)
1211 1210
1212 1211 def iterate():
1213 if follow and not m.files():
1212 if follow and not match.files():
1214 1213 ff = followfilter(onlyfirst=opts.get('follow_first'))
1215 1214 def want(rev):
1216 1215 return ff.match(rev) and rev in wanted
@@ -1226,13 +1225,13 b' def walkchangerevs(ui, repo, pats, chang'
1226 1225 if not fns:
1227 1226 def fns_generator():
1228 1227 for f in change(rev).files():
1229 if m(f):
1228 if match(f):
1230 1229 yield f
1231 1230 fns = fns_generator()
1232 1231 yield 'add', rev, fns
1233 1232 for rev in nrevs:
1234 1233 yield 'iter', rev, None
1235 return iterate(), m
1234 return iterate()
1236 1235
1237 1236 def commit(ui, repo, commitfunc, pats, opts):
1238 1237 '''commit the specified files or all outstanding changes'''
@@ -1289,10 +1289,10 b' def grep(ui, repo, pattern, *pats, **opt'
1289 1289 skip = {}
1290 1290 revfiles = {}
1291 1291 get = util.cachefunc(lambda r: repo[r])
1292 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1292 matchfn = cmdutil.match(repo, pats, opts)
1293 1293 found = False
1294 1294 follow = opts.get('follow')
1295 for st, rev, fns in changeiter:
1295 for st, rev, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts):
1296 1296 if st == 'window':
1297 1297 matches.clear()
1298 1298 revfiles.clear()
@@ -1980,8 +1980,7 b' def log(ui, repo, *pats, **opts):'
1980 1980 """
1981 1981
1982 1982 get = util.cachefunc(lambda r: repo[r])
1983 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1984
1983 matchfn = cmdutil.match(repo, pats, opts)
1985 1984 limit = cmdutil.loglimit(opts)
1986 1985 count = 0
1987 1986
@@ -2028,7 +2027,7 b' def log(ui, repo, *pats, **opts):'
2028 2027 only_branches = opts.get('only_branch')
2029 2028
2030 2029 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
2031 for st, rev, fns in changeiter:
2030 for st, rev, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts):
2032 2031 if st == 'add':
2033 2032 parents = [p for p in repo.changelog.parentrevs(rev)
2034 2033 if p != nullrev]
General Comments 0
You need to be logged in to leave comments. Login now