# HG changeset patch # User Martin von Zweigbergk # Date 1547838466 28800 # Node ID cecdf7418cf1198b37715b11aa1bdfa6b0472900 # Parent e9b9ee9af4a9b2069126e5b48bc9786441399686 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 diff -r e9b9ee9af4a9 -r cecdf7418cf1 mercurial/commands.py --- 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: