--- a/mercurial/templater.py Thu May 07 23:18:48 2015 -0700
+++ b/mercurial/templater.py Fri May 08 18:11:26 2015 +0900
@@ -623,7 +623,21 @@
if quoted:
if len(s) < 2 or s[0] != s[-1]:
raise SyntaxError(_('unmatched quotes'))
- return s[1:-1]
+ # 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