comparison mercurial/templater.py @ 25696:c1cac25ad1a6

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.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 27 Jun 2015 15:28:46 +0900
parents ce3d4b858420
children 8b900b937e1c
comparison
equal deleted inserted replaced
25695:ce3d4b858420 25696:c1cac25ad1a6
696 696
697 def unquotestring(s): 697 def unquotestring(s):
698 '''unwrap quotes''' 698 '''unwrap quotes'''
699 if len(s) < 2 or s[0] != s[-1]: 699 if len(s) < 2 or s[0] != s[-1]:
700 raise SyntaxError(_('unmatched quotes')) 700 raise SyntaxError(_('unmatched quotes'))
701 # de-backslash-ify only <\">. it is invalid syntax in non-string part of 701 return s[1:-1]
702 # template, but we are likely to escape <"> in quoted string and it was
703 # accepted before, thanks to issue4290. <\\"> is unmodified because it
704 # is ambiguous and it was processed as such before 2.8.1.
705 #
706 # template result
707 # --------- ------------------------
708 # {\"\"} parse error
709 # "{""}" {""} -> <>
710 # "{\"\"}" {""} -> <>
711 # {"\""} {"\""} -> <">
712 # '{"\""}' {"\""} -> <">
713 # "{"\""}" parse error (don't care)
714 q = s[0]
715 return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q)
716 702
717 class engine(object): 703 class engine(object):
718 '''template expansion engine. 704 '''template expansion engine.
719 705
720 template expansion works like this. a map file contains key=value 706 template expansion works like this. a map file contains key=value