templatekw: make getrenamed() return only filename, not nodeid
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 26 Mar 2018 10:49:01 -0700
changeset 38167 ec37df9042f9
parent 38166 cc9aa88792fe
child 38168 faa015417348
templatekw: make getrenamed() return only filename, not nodeid No callers cared about the nodeid and I want to make getrenamed() not look up the node (although it's currently free, I hope to store copy info in changesets and not include the nodeid). Differential Revision: https://phab.mercurial-scm.org/D3666
mercurial/logcmdutil.py
mercurial/templatekw.py
--- a/mercurial/logcmdutil.py	Sat May 26 12:38:07 2018 +0900
+++ b/mercurial/logcmdutil.py	Mon Mar 26 10:49:01 2018 -0700
@@ -865,7 +865,7 @@
             for fn in ctx.files():
                 rename = getrenamed(fn, ctx.rev())
                 if rename:
-                    copies.append((fn, rename[0]))
+                    copies.append((fn, rename))
         edges = edgefn(type, char, state, rev, parents)
         firstedge = next(edges)
         width = firstedge[2]
@@ -893,7 +893,7 @@
             for fn in ctx.files():
                 rename = getrenamed(fn, rev)
                 if rename:
-                    copies.append((fn, rename[0]))
+                    copies.append((fn, rename))
         displayer.show(ctx, copies=copies)
         displayer.flush(ctx)
     displayer.close()
--- a/mercurial/templatekw.py	Sat May 26 12:38:07 2018 +0900
+++ b/mercurial/templatekw.py	Mon Mar 26 10:49:01 2018 -0700
@@ -111,7 +111,7 @@
             for i in fl:
                 lr = fl.linkrev(i)
                 renamed = fl.renamed(fl.node(i))
-                rcache[fn][lr] = renamed
+                rcache[fn][lr] = renamed and renamed[0]
                 if lr >= endrev:
                     break
         if rev in rcache[fn]:
@@ -120,7 +120,8 @@
         # If linkrev != rev (i.e. rev not found in rcache) fallback to
         # filectx logic.
         try:
-            return repo[rev][fn].renamed()
+            renamed = repo[rev][fn].renamed()
+            return renamed and renamed[0]
         except error.LookupError:
             return None
 
@@ -318,7 +319,7 @@
         for fn in ctx.files():
             rename = getrenamed(fn, ctx.rev())
             if rename:
-                copies.append((fn, rename[0]))
+                copies.append((fn, rename))
 
     copies = util.sortdict(copies)
     return compatdict(context, mapping, 'file_copy', copies,