##// END OF EJS Templates
walkchangerevs: internalize ctx caching
Matt Mackall -
r9655:6d7d3f84 default
parent child Browse files
Show More
@@ -53,9 +53,8 b' def countrate(ui, repo, amap, *pats, **o'
53 53 if opts.get('date'):
54 54 df = util.matchdate(opts['date'])
55 55
56 get = util.cachefunc(lambda r: repo[r])
57 56 m = cmdutil.match(repo, pats, opts)
58 for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, m, get, opts):
57 for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, m, opts):
59 58 if not st == 'add':
60 59 continue
61 60
@@ -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, match, change, opts):
1042 def walkchangerevs(ui, repo, match, 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
@@ -1087,6 +1087,7 b' def walkchangerevs(ui, repo, match, chan'
1087 1087 wanted = set()
1088 1088 slowpath = match.anypats() or (match.files() and opts.get('removed'))
1089 1089 fncache = {}
1090 change = util.cachefunc(repo.changectx)
1090 1091
1091 1092 if not slowpath and not match.files():
1092 1093 # No files, no patterns. Display all revs.
@@ -1257,7 +1257,8 b' def grep(ui, repo, pattern, *pats, **opt'
1257 1257 for i in xrange(blo, bhi):
1258 1258 yield ('+', b[i])
1259 1259
1260 def display(fn, r, pstates, states):
1260 def display(fn, ctx, pstates, states):
1261 rev = ctx.rev()
1261 1262 datefunc = ui.quiet and util.shortdate or util.datestr
1262 1263 found = False
1263 1264 filerevmatches = {}
@@ -1266,17 +1267,17 b' def grep(ui, repo, pattern, *pats, **opt'
1266 1267 else:
1267 1268 iter = [('', l) for l in states]
1268 1269 for change, l in iter:
1269 cols = [fn, str(r)]
1270 cols = [fn, str(rev)]
1270 1271 if opts.get('line_number'):
1271 1272 cols.append(str(l.linenum))
1272 1273 if opts.get('all'):
1273 1274 cols.append(change)
1274 1275 if opts.get('user'):
1275 cols.append(ui.shortuser(get(r).user()))
1276 cols.append(ui.shortuser(ctx.user()))
1276 1277 if opts.get('date'):
1277 cols.append(datefunc(get(r).date()))
1278 cols.append(datefunc(ctx.date()))
1278 1279 if opts.get('files_with_matches'):
1279 c = (fn, r)
1280 c = (fn, rev)
1280 1281 if c in filerevmatches:
1281 1282 continue
1282 1283 filerevmatches[c] = 1
@@ -1288,11 +1289,10 b' def grep(ui, repo, pattern, *pats, **opt'
1288 1289
1289 1290 skip = {}
1290 1291 revfiles = {}
1291 get = util.cachefunc(lambda r: repo[r])
1292 1292 matchfn = cmdutil.match(repo, pats, opts)
1293 1293 found = False
1294 1294 follow = opts.get('follow')
1295 for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts):
1295 for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, opts):
1296 1296 if st == 'add':
1297 1297 rev = ctx.rev()
1298 1298 pctx = ctx.parents()[0]
@@ -1329,7 +1329,7 b' def grep(ui, repo, pattern, *pats, **opt'
1329 1329 pass
1330 1330 elif st == 'iter':
1331 1331 rev = ctx.rev()
1332 parent = get(rev).parents()[0].rev()
1332 parent = ctx.parents()[0].rev()
1333 1333 for fn in sorted(revfiles.get(rev, [])):
1334 1334 states = matches[rev][fn]
1335 1335 copy = copies.get(rev, {}).get(fn)
@@ -1339,7 +1339,7 b' def grep(ui, repo, pattern, *pats, **opt'
1339 1339 continue
1340 1340 pstates = matches.get(parent, {}).get(copy or fn, [])
1341 1341 if pstates or states:
1342 r = display(fn, rev, pstates, states)
1342 r = display(fn, ctx, pstates, states)
1343 1343 found = found or r
1344 1344 if r and not opts.get('all'):
1345 1345 skip[fn] = True
@@ -1979,7 +1979,6 b' def log(ui, repo, *pats, **opts):'
1979 1979 will appear in files:.
1980 1980 """
1981 1981
1982 get = util.cachefunc(lambda r: repo[r])
1983 1982 matchfn = cmdutil.match(repo, pats, opts)
1984 1983 limit = cmdutil.loglimit(opts)
1985 1984 count = 0
@@ -2027,9 +2026,9 b' def log(ui, repo, *pats, **opts):'
2027 2026 only_branches = opts.get('only_branch')
2028 2027
2029 2028 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
2030 for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts):
2029 for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, opts):
2030 rev = ctx.rev()
2031 2031 if st == 'add':
2032 rev = ctx.rev()
2033 2032 parents = [p for p in repo.changelog.parentrevs(rev)
2034 2033 if p != nullrev]
2035 2034 if opts.get('no_merges') and len(parents) == 2:
@@ -2069,7 +2068,8 b' def log(ui, repo, *pats, **opts):'
2069 2068
2070 2069 elif st == 'iter':
2071 2070 if count == limit: break
2072 if displayer.flush(ctx.rev()):
2071
2072 if displayer.flush(rev):
2073 2073 count += 1
2074 2074
2075 2075 def manifest(ui, repo, node=None, rev=None):
General Comments 0
You need to be logged in to leave comments. Login now