Patchwork D8305: phabricator: eliminate a couple of duplicate filectx lookups

login
register
mail settings
Submitter phabricator
Date March 20, 2020, 9:24 p.m.
Message ID <differential-rev-PHID-DREV-w5qssghe5ytp5aiygkgp-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45842/
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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -819,8 +819,8 @@ 
         pchange = phabchange(
             currentPath=fname, oldPath=fname, type=DiffChangeType.DELETE
         )
-        pchange.addoldmode(gitmode[ctx.p1()[fname].flags()])
         oldfctx = ctx.p1()[fname]
+        pchange.addoldmode(gitmode[oldfctx.flags()])
         if not (oldfctx.isbinary() or notutf8(oldfctx)):
             maketext(pchange, ctx, fname)
 
@@ -831,10 +831,10 @@ 
     """add modified files to the phabdiff"""
     for fname in modified:
         fctx = ctx[fname]
-        oldfctx = fctx.p1()
+        oldfctx = ctx.p1()[fname]
         pchange = phabchange(currentPath=fname, oldPath=fname)
-        filemode = gitmode[ctx[fname].flags()]
-        originalmode = gitmode[ctx.p1()[fname].flags()]
+        filemode = gitmode[fctx.flags()]
+        originalmode = gitmode[oldfctx.flags()]
         if filemode != originalmode:
             pchange.addoldmode(originalmode)
             pchange.addnewmode(filemode)
@@ -846,7 +846,7 @@ 
             or notutf8(oldfctx)
         ):
             makebinary(pchange, fctx)
-            addoldbinary(pchange, fctx.p1(), fctx)
+            addoldbinary(pchange, oldfctx, fctx)
         else:
             maketext(pchange, ctx, fname)
 
@@ -864,7 +864,7 @@ 
         oldfctx = None
         pchange = phabchange(currentPath=fname)
 
-        filemode = gitmode[ctx[fname].flags()]
+        filemode = gitmode[fctx.flags()]
         renamed = fctx.renamed()
 
         if renamed: