grep: reuse getrenamedfn() from scmutil
My motivation is to reduce uses of filectx.renamed(). Reusing
scmutil.getrenamedfn() also means that we get some caching of copy
information per file and revision. I don't think that matters for `hg
grep` (I doubt it speeds up significantly, and I doubt it wastes
significant memory), but I'm not sure.
Differential Revision: https://phab.mercurial-scm.org/D6022
--- a/mercurial/commands.py Thu Feb 21 10:54:29 2019 -0800
+++ b/mercurial/commands.py Fri Jan 18 11:07:46 2019 -0800
@@ -2940,6 +2940,7 @@
found = False
follow = opts.get('follow')
+ getrenamed = scmutil.getrenamedfn(repo)
def prep(ctx, fns):
rev = ctx.rev()
pctx = ctx.p1()
@@ -2953,13 +2954,10 @@
fnode = ctx.filenode(fn)
except error.LookupError:
continue
+
copy = None
if follow:
- try:
- copied = flog.renamed(fnode)
- except error.WdirUnsupported:
- copied = ctx[fn].renamed()
- copy = copied and copied[0]
+ copy = getrenamed(fn, rev)
if copy:
copies.setdefault(rev, {})[fn] = copy
if fn in skip: