changeset 44831:6d3768b11241

diff: avoid going from contexts to nodes and back This will allow us to pass in-memory contexts that may not have a valid node to the diffing logic. Differential Revision: https://phab.mercurial-scm.org/D8503
author Augie Fackler <augie@google.com>
date Thu, 07 May 2020 16:56:03 -0400
parents 3b7aabd02e11
children ad1ec40975aa
files mercurial/commands.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu May 07 16:54:17 2020 -0400
+++ b/mercurial/commands.py	Thu May 07 16:56:03 2020 -0400
@@ -2489,10 +2489,13 @@
     else:
         repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
         ctx1, ctx2 = scmutil.revpair(repo, revs)
-    node1, node2 = ctx1.node(), ctx2.node()
 
     if reverse:
-        node1, node2 = node2, node1
+        ctxleft = ctx2
+        ctxright = ctx1
+    else:
+        ctxleft = ctx1
+        ctxright = ctx2
 
     diffopts = patch.diffallopts(ui, opts)
     m = scmutil.match(ctx2, pats, opts)
@@ -2502,8 +2505,8 @@
         ui,
         repo,
         diffopts,
-        repo[node1],
-        repo[node2],
+        ctxleft,
+        ctxright,
         m,
         stat=stat,
         listsubrepos=opts.get(b'subrepos'),