templatekw: make join() escape values of extras (BC) (issue5504)
authorYuya Nishihara <yuya@tcha.org>
Wed, 15 Mar 2017 23:21:30 +0900
changeset 31461 52dabcc49968
parent 31460 53865692a354
child 31462 3b7a6941a6ef
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.
mercurial/templatekw.py
tests/test-graft.t
tests/test-transplant.t
--- a/mercurial/templatekw.py	Wed Mar 15 23:06:50 2017 +0900
+++ b/mercurial/templatekw.py	Wed Mar 15 23:21:30 2017 +0900
@@ -336,7 +336,7 @@
     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):
--- a/tests/test-graft.t	Wed Mar 15 23:06:50 2017 +0900
+++ b/tests/test-graft.t	Wed Mar 15 23:21:30 2017 +0900
@@ -582,8 +582,7 @@
   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
--- a/tests/test-transplant.t	Wed Mar 15 23:06:50 2017 +0900
+++ b/tests/test-transplant.t	Wed Mar 15 23:21:30 2017 +0900
@@ -94,6 +94,15 @@
   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'