phabricator: eliminate a couple of duplicate filectx lookups
Differential Revision: https://phab.mercurial-scm.org/D8305
--- a/hgext/phabricator.py Wed Mar 25 12:06:49 2020 -0400
+++ b/hgext/phabricator.py Tue Feb 18 09:57:26 2020 -0500
@@ -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: