Patchwork [05,of,14,RFC] patch: simple wrapping of diff to take two contexts

login
register
mail settings
Submitter Sean Farley
Date July 9, 2013, 9:54 p.m.
Message ID <cd81a482ec491eb3fefa.1373406876@laptop.local>
Download mbox | patch
Permalink /patch/1814/
State Changes Requested
Headers show

Comments

Sean Farley - July 9, 2013, 9:54 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1373324590 18000
#      Mon Jul 08 18:03:10 2013 -0500
# Node ID cd81a482ec491eb3fefa6c6772d3d1bfeb7e000b
# Parent  399c9dd59e118005e37d0cf22f82fc5f7d9d2ab8
patch: simple wrapping of diff to take two contexts

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1542,10 +1542,13 @@ 
         opts = mdiff.defaultopts
 
     if not node1 and not node2:
         node1 = repo.dirstate.p1()
 
+    ctx1 = context.nodeorctx(repo, node1)
+    ctx2 = context.nodeorctx(repo, node2)
+
     def lrugetfilectx():
         cache = {}
         order = util.deque()
         def getfilectx(f, ctx):
             fctx = ctx.filectx(f, filelog=cache.get(f))
@@ -1558,23 +1561,20 @@ 
             order.append(f)
             return fctx
         return getfilectx
     getfilectx = lrugetfilectx()
 
-    ctx1 = repo[node1]
-    ctx2 = repo[node2]
-
     if not changes:
         changes = repo.status(ctx1, ctx2, match=match)
     modified, added, removed = changes[:3]
 
     if not modified and not added and not removed:
         return []
 
     revs = None
     hexfunc = repo.ui.debugflag and hex or short
-    revs = [hexfunc(node) for node in [node1, node2] if node]
+    revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node]
 
     copy = {}
     if opts.git or opts.upgrade:
         copy = copies.pathcopies(ctx1, ctx2)