changeset 35595:91201737d07a

revsetlang: fix quoting of %ls string Before, "'" wasn't escaped appropriately. This also changes the separator '\0' to '\\0', but that's okay as a string token is unescaped.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 01 Apr 2017 17:51:56 +0900
parents 468d7a1f6633
children a57acea31b3b
files mercurial/revsetlang.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revsetlang.py	Sat Apr 01 17:44:07 2017 +0900
+++ b/mercurial/revsetlang.py	Sat Apr 01 17:51:56 2017 +0900
@@ -585,7 +585,9 @@
     >>> formatspec(b'branch(%b)', b)
     "branch('default')"
     >>> formatspec(b'root(%ls)', [b'a', b'b', b'c', b'd'])
-    "root(_list('a\\x00b\\x00c\\x00d'))"
+    "root(_list('a\\\\x00b\\\\x00c\\\\x00d'))"
+    >>> formatspec('%ls', ['a', "'"])
+    "_list('a\\\\x00\\\\'')"
     '''
 
     def argtype(c, arg):
@@ -614,7 +616,7 @@
         elif t == 'd':
             return "_intlist('%s')" % "\0".join('%d' % int(a) for a in s)
         elif t == 's':
-            return "_list('%s')" % "\0".join(s)
+            return "_list(%s)" % _quote("\0".join(s))
         elif t == 'n':
             return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s)
         elif t == 'b':