Patchwork D8503: diff: avoid going from contexts to nodes and back

login
register
mail settings
Submitter phabricator
Date May 7, 2020, 9:26 p.m.
Message ID <differential-rev-PHID-DREV-mzr3agurfcj4y7hxmcek-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46285/
State Superseded
Headers show

Comments

phabricator - May 7, 2020, 9:26 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will allow us to pass in-memory contexts that may not have a
  valid node to the diffing logic.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2494,7 +2494,11 @@ 
     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)
@@ -2504,8 +2508,8 @@ 
         ui,
         repo,
         diffopts,
-        repo[node1],
-        repo[node2],
+        ctxleft,
+        ctxright,
         m,
         stat=stat,
         listsubrepos=opts.get(b'subrepos'),