Patchwork D8307: phabricator: account for `basectx != ctx` when calculating renames

login
register
mail settings
Submitter phabricator
Date March 26, 2020, 10:51 a.m.
Message ID <f11b6928a341894069d8faebb7e6dbab@localhost.localdomain>
Download mbox | patch
Permalink /patch/45912/
State Not Applicable
Headers show

Comments

phabricator - March 26, 2020, 10:51 a.m.
Closed by commit rHG022bf71515c9: phabricator: account for `basectx != ctx` when calculating renames (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8307?vs=20847&id=20895

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8307/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8307

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers, Alphare, pulkit
Cc: Kwan, mercurial-devel

Patch

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -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