changeset 44615:022bf71515c9

phabricator: account for `basectx != ctx` when calculating renames No functional changes here because the two are the currently same, but they won't be with a `--fold` option. Differential Revision: https://phab.mercurial-scm.org/D8307
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 24 Feb 2020 13:22:15 -0500
parents 53d75fdeaaaa
children bc592059d04f
files hgext/phabricator.py
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/phabricator.py	Mon Feb 24 12:06:34 2020 -0500
+++ b/hgext/phabricator.py	Mon Feb 24 13:22:15 2020 -0500
@@ -61,6 +61,7 @@
 from mercurial import (
     cmdutil,
     context,
+    copies,
     encoding,
     error,
     exthelper,
@@ -859,16 +860,28 @@
     # additional copies we can mark them (moves get removed from removed)
     copiedchanges = {}
     movedchanges = {}
+
+    copy = {}
+    if basectx != ctx:
+        copy = copies.pathcopies(basectx.p1(), ctx)
+
     for fname in added:
         fctx = ctx[fname]
         oldfctx = None
         pchange = phabchange(currentPath=fname)
 
         filemode = gitmode[fctx.flags()]
-        renamed = fctx.renamed()
+
+        if copy:
+            originalfname = copy.get(fname, fname)
+        else:
+            originalfname = fname
+            if fctx.renamed():
+                originalfname = fctx.renamed()[0]
+
+        renamed = fname != originalfname
 
         if renamed:
-            originalfname = renamed[0]
             oldfctx = basectx.p1()[originalfname]
             originalmode = gitmode[oldfctx.flags()]
             pchange.oldPath = originalfname