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