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

login
register
mail settings
Submitter phabricator
Date March 20, 2020, 9:24 p.m.
Message ID <differential-rev-PHID-DREV-ytp3doggk6vra2ddlqr3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45844/
State Superseded
Headers show

Comments

phabricator - March 20, 2020, 9:24 p.m.
mharbison72 created this revision.
Herald added subscribers: mercurial-devel, Kwan.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  No functional changes here because the two are the currently same, but they
  won't be with a `--fold` option.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
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