[PATCH] patch: accept non-node arguments to diff()
Gregory Szorc
gregory.szorc at gmail.com
Mon Jun 23 00:26:20 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1403501129 25200
# Sun Jun 22 22:25:29 2014 -0700
# Node ID f420697523a0ae7140e86ccc013e31682bcf4ee3
# Parent cd3c79392056a0d965236e4986a7a4b5d580f3e5
patch: accept non-node arguments to diff()
patch.diff() appears to work with non-bin argument values to node1
and node2 because it feeds them into repo[]. However, this breaks
the actual generated patch because the arguments are always
hex-encoded. This may result in double hex encoding.
I discovered this as part of implementing an extension. I have no
clue if anything in the core is impacted. I doubt it. One less
footgun for extension authors.
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1620,9 +1620,9 @@ def diff(repo, node1=None, node2=None, m
return []
revs = None
hexfunc = repo.ui.debugflag and hex or short
- revs = [hexfunc(node) for node in [node1, node2] if node]
+ revs = [hexfunc(ctx.node()) for ctx in [ctx1, ctx2] if ctx.node()]
copy = {}
if opts.git or opts.upgrade:
copy = copies.pathcopies(ctx1, ctx2)
More information about the Mercurial-devel
mailing list