Patchwork D5890: diffordiffstat: avoid looking up contexts twice

login
register
mail settings
Submitter phabricator
Date Feb. 8, 2019, 12:44 p.m.
Message ID <c71de0541b06081859c824de0073af39@localhost.localdomain>
Download mbox | patch
Permalink /patch/38547/
State Not Applicable
Headers show

Comments

phabricator - Feb. 8, 2019, 12:44 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd683aca738cd: diffordiffstat: avoid looking up contexts twice (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5890?vs=13904&id=13911

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

AFFECTED FILES
  mercurial/logcmdutil.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -58,6 +58,8 @@ 
                    changes=None, stat=False, fp=None, graphwidth=0,
                    prefix='', root='', listsubrepos=False, hunksfilterfn=None):
     '''show diff or diffstat.'''
+    ctx1 = repo[node1]
+    ctx2 = repo[node2]
     if root:
         relroot = pathutil.canonpath(repo.root, repo.getcwd(), root)
     else:
@@ -78,9 +80,8 @@ 
         if not ui.plain():
             width = ui.termwidth() - graphwidth
 
-    chunks = repo[node2].diff(repo[node1], match, changes, opts=diffopts,
-                              prefix=prefix, relroot=relroot,
-                              hunksfilterfn=hunksfilterfn)
+    chunks = ctx2.diff(ctx1, match, changes, opts=diffopts, prefix=prefix,
+                       relroot=relroot, hunksfilterfn=hunksfilterfn)
 
     if fp is not None or ui.canwritewithoutlabels():
         out = fp or ui
@@ -105,8 +106,6 @@ 
                 ui.write(chunk, label=label)
 
     if listsubrepos:
-        ctx1 = repo[node1]
-        ctx2 = repo[node2]
         for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
             tempnode2 = node2
             try: