##// END OF EJS Templates
cmdutil: make walkchangerevs() call prepare with matcher instead of filenames...
Yuya Nishihara -
r46225:3a024d7c default
parent child Browse files
Show More
@@ -36,9 +36,8 b' command = registrar.command(cmdtable)'
36 testedwith = b'ships-with-hg-core'
36 testedwith = b'ships-with-hg-core'
37
37
38
38
39 def changedlines(ui, repo, ctx1, ctx2, fns):
39 def changedlines(ui, repo, ctx1, ctx2, fmatch):
40 added, removed = 0, 0
40 added, removed = 0, 0
41 fmatch = scmutil.matchfiles(repo, fns)
42 diff = b''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
41 diff = b''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
43 for l in diff.split(b'\n'):
42 for l in diff.split(b'\n'):
44 if l.startswith(b"+") and not l.startswith(b"+++ "):
43 if l.startswith(b"+") and not l.startswith(b"+++ "):
@@ -79,7 +78,7 b' def countrate(ui, repo, amap, *pats, **o'
79
78
80 m = scmutil.match(repo[None], pats, opts)
79 m = scmutil.match(repo[None], pats, opts)
81
80
82 def prep(ctx, fns):
81 def prep(ctx, fmatch):
83 rev = ctx.rev()
82 rev = ctx.rev()
84 if df and not df(ctx.date()[0]): # doesn't match date format
83 if df and not df(ctx.date()[0]): # doesn't match date format
85 return
84 return
@@ -95,7 +94,7 b' def countrate(ui, repo, amap, *pats, **o'
95 return
94 return
96
95
97 ctx1 = parents[0]
96 ctx1 = parents[0]
98 lines = changedlines(ui, repo, ctx1, ctx, fns)
97 lines = changedlines(ui, repo, ctx1, ctx, fmatch)
99 rate[key] = [r + l for r, l in zip(rate.get(key, (0, 0)), lines)]
98 rate[key] = [r + l for r, l in zip(rate.get(key, (0, 0)), lines)]
100
99
101 progress.increment()
100 progress.increment()
@@ -2574,7 +2574,7 b' def walkchangerevs(repo, match, opts, pr'
2574 yield f
2574 yield f
2575
2575
2576 fns = fns_generator()
2576 fns = fns_generator()
2577 prepare(ctx, fns)
2577 prepare(ctx, scmutil.matchfiles(repo, fns))
2578 for rev in nrevs:
2578 for rev in nrevs:
2579 yield change(rev)
2579 yield change(rev)
2580
2580
@@ -3606,7 +3606,7 b' def grep(ui, repo, pattern, *pats, **opt'
3606 % {b'filename': fn, b'revnum': pycompat.bytestr(rev),}
3606 % {b'filename': fn, b'revnum': pycompat.bytestr(rev),}
3607 )
3607 )
3608
3608
3609 def prep(ctx, fns):
3609 def prep(ctx, fmatch):
3610 rev = ctx.rev()
3610 rev = ctx.rev()
3611 pctx = ctx.p1()
3611 pctx = ctx.p1()
3612 matches.setdefault(rev, {})
3612 matches.setdefault(rev, {})
@@ -3621,7 +3621,8 b' def grep(ui, repo, pattern, *pats, **opt'
3621 else:
3621 else:
3622 contextmanager = util.nullcontextmanager
3622 contextmanager = util.nullcontextmanager
3623 with contextmanager():
3623 with contextmanager():
3624 for fn in fns:
3624 assert fmatch.isexact()
3625 for fn in fmatch.files():
3625 # fn might not exist in the revision (could be a file removed by
3626 # fn might not exist in the revision (could be a file removed by
3626 # the revision). We could check `fn not in ctx` even when rev is
3627 # the revision). We could check `fn not in ctx` even when rev is
3627 # None, but it's less racy to protect againt that in readfile.
3628 # None, but it's less racy to protect againt that in readfile.
General Comments 0
You need to be logged in to leave comments. Login now