D8305: phabricator: eliminate a couple of duplicate filectx lookups

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Fri Mar 20 21:24:05 UTC 2020


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

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:



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


More information about the Mercurial-devel mailing list