diff --git a/mercurial/templater.py b/mercurial/templater.py index 5bc506ee87d261269f4c173f607f0e08efce2fab_bWVyY3VyaWFsL3RlbXBsYXRlci5weQ==..db7463aa080f5d0548c18949db11d8c7258fd38e_bWVyY3VyaWFsL3RlbXBsYXRlci5weQ== 100644 --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -618,8 +618,7 @@ yield j def parsestring(s, quoted=True): - '''parse a string using simple c-like syntax. - string must be in quotes if quoted is True.''' + '''unwrap quotes if quoted is True''' if quoted: if len(s) < 2 or s[0] != s[-1]: raise SyntaxError(_('unmatched quotes')) @@ -623,5 +622,5 @@ if quoted: if len(s) < 2 or s[0] != s[-1]: raise SyntaxError(_('unmatched quotes')) - return s[1:-1].decode('string_escape') + return s[1:-1] @@ -627,5 +626,5 @@ - return s.decode('string_escape') + return s class engine(object): '''template expansion engine. diff --git a/tests/test-command-template.t b/tests/test-command-template.t index 5bc506ee87d261269f4c173f607f0e08efce2fab_dGVzdHMvdGVzdC1jb21tYW5kLXRlbXBsYXRlLnQ=..db7463aa080f5d0548c18949db11d8c7258fd38e_dGVzdHMvdGVzdC1jb21tYW5kLXRlbXBsYXRlLnQ= 100644 --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -2250,6 +2250,29 @@ <>\n<]> <>\n< + $ hg log -R latesttag -r 0 \ + > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' + > + <>\n<[> + <>\n<]> + <>\n< + + $ hg log -R latesttag -r 0 -T esc \ + > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' + > + <>\n<[> + <>\n<]> + <>\n< + + $ cat <<'EOF' > esctmpl + > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' + > EOF + $ hg log -R latesttag -r 0 --style ./esctmpl + > + <>\n<[> + <>\n<]> + <>\n< + "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice) $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'