[PATCH 2 of 3] templatekw: make join() escape values of extras (BC) (issue5504)
Yuya Nishihara
yuya at tcha.org
Wed Mar 15 11:09:49 EDT 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1489587690 -32400
# Wed Mar 15 23:21:30 2017 +0900
# Node ID 8b8d561c82ee5c11827674dfff2866067d034eea
# Parent 18ebbd7221440563c87db980c16e735457195f61
templatekw: make join() escape values of extras (BC) (issue5504)
Since extras may contain blob, the default template escapes its values:
'extra': '{key}={value|stringescape}'
join() should follow the output style of the default template.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -336,7 +336,7 @@ def showextras(**args):
c = [makemap(k) for k in extras]
f = _showlist('extra', c, plural='extras', **args)
return _hybrid(f, extras, makemap,
- lambda x: '%s=%s' % (x['key'], x['value']))
+ lambda x: '%s=%s' % (x['key'], util.escapestr(x['value'])))
@templatekeyword('file_adds')
def showfileadds(**args):
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -582,8 +582,7 @@ The transplant case
21: fbb6c5cc81002f2b4b49c9d731404688bcae5ade
branch=dev
convert_revision=7e61b508e709a11d28194a5359bc3532d910af21
- transplant_source=z\xe8F\xe9\x11\x1f\xc8\xf5wEcBP\xc7\xb9\xac (esc)
- `h\x9b (esc)
+ transplant_source=z\xe8F\xe9\x11\x1f\xc8\xf5wEcBP\xc7\xb9\xac\n`h\x9b
$ hg -R ../converted log -r 'origin(tip)'
changeset: 2:e0213322b2c1
user: test
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -94,6 +94,15 @@ rebase b onto r1
1 r2
0 r1
+test format of transplant_source
+
+ $ hg log -r7 --debug | grep transplant_source
+ extra: transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z
+ $ hg log -r7 -T '{extras}\n'
+ branch=defaulttransplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z
+ $ hg log -r7 -T '{join(extras, " ")}\n'
+ branch=default transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z
+
test transplanted revset
$ hg log -r 'transplanted()' --template '{rev} {parents} {desc}\n'
More information about the Mercurial-devel
mailing list