changeset 41389:b44f1703b28c

grep: don't look up copy info unless --follow is given If no --follow was given, then the "copy" variable will become None. In that case we would still look up the copy information from the filelog and then ignore it. Let's avoid even looking it up. Differential Revision: https://phab.mercurial-scm.org/D5620
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 06 Sep 2018 15:56:53 -0700
parents fabb0224a599
children 609d6d8646db
files mercurial/commands.py
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Jan 17 09:24:30 2019 -0800
+++ b/mercurial/commands.py	Thu Sep 06 15:56:53 2018 -0700
@@ -2944,16 +2944,18 @@
                 fnode = ctx.filenode(fn)
             except error.LookupError:
                 continue
-            try:
-                copied = flog.renamed(fnode)
-            except error.WdirUnsupported:
-                copied = ctx[fn].renamed()
-            copy = follow and copied and copied[0]
-            if copy:
-                copies.setdefault(rev, {})[fn] = copy
+            copy = None
+            if follow:
+                try:
+                    copied = flog.renamed(fnode)
+                except error.WdirUnsupported:
+                    copied = ctx[fn].renamed()
+                copy = copied and copied[0]
+                if copy:
+                    copies.setdefault(rev, {})[fn] = copy
+                    if fn in skip:
+                        skip[copy] = True
             if fn in skip:
-                if copy:
-                    skip[copy] = True
                 continue
             files.append(fn)