[PATCH] templater: remove workaround for escaped quoted string in quoted template

Yuya Nishihara yuya at tcha.org
Tue Jun 30 14:41:53 UTC 2015


This patch should fix the future test failure when "templater: parse \"...\"
as string for 2.9.2-3.4 compatibility (issue4733)" is merged to default.

# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1435386526 -32400
#      Sat Jun 27 15:28:46 2015 +0900
# Node ID bffa8e18149a1cb41b22bb36841d79d363e02b25
# Parent  ebd156b3faca120e7b009727f191504df9b8c50f
templater: remove workaround for escaped quoted string in quoted template

This patch backs out 554d6fcc3c84 which should no longer be needed.

The test for '{\"invalid\"}' is removed because the parser is permissive for
\"...\" literal.

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -698,21 +698,7 @@ def unquotestring(s):
     '''unwrap quotes'''
     if len(s) < 2 or s[0] != s[-1]:
         raise SyntaxError(_('unmatched quotes'))
-    # de-backslash-ify only <\">. it is invalid syntax in non-string part of
-    # template, but we are likely to escape <"> in quoted string and it was
-    # accepted before, thanks to issue4290. <\\"> is unmodified because it
-    # is ambiguous and it was processed as such before 2.8.1.
-    #
-    #  template  result
-    #  --------- ------------------------
-    #  {\"\"}    parse error
-    #  "{""}"    {""} -> <>
-    #  "{\"\"}"  {""} -> <>
-    #  {"\""}    {"\""} -> <">
-    #  '{"\""}'  {"\""} -> <">
-    #  "{"\""}"  parse error (don't care)
-    q = s[0]
-    return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q)
+    return s[1:-1]
 
 class engine(object):
     '''template expansion engine.
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -2870,9 +2870,6 @@ stripped before parsing:
   $ hg log -r 2 --style ../escquotetmpl
   " \" \" \\" head1
 
-  $ hg log -r 2 -T esc --config templates.esc='{\"invalid\"}\n'
-  hg: parse error at 1: syntax error
-  [255]
   $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"'
   valid
   $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'"



More information about the Mercurial-devel mailing list