mercurial/logcmdutil.py
changeset 41623 d683aca738cd
parent 41100 6a63ba61e71f
child 41630 035cae1d197f
--- a/mercurial/logcmdutil.py	Thu Feb 07 17:04:15 2019 +0100
+++ b/mercurial/logcmdutil.py	Wed Feb 06 22:32:50 2019 -0800
@@ -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: