From patchwork Fri Mar 20 21:24:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D8307: phabricator: account for `basectx != ctx` when calculating renames From: phabricator X-Patchwork-Id: 45844 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Fri, 20 Mar 2020 21:24:25 +0000 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 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