D6022: grep: reuse getrenamedfn() from scmutil
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Sun Feb 24 06:11:49 UTC 2019
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D6022
AFFECTED FILES
mercurial/commands.py
CHANGE DETAILS
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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:
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list