Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templater.py @ 24987:fd7287f0b43c
templater: remove noop calls of parsestring(s, quoted=False) (API)
Since db7463aa080f, parsestring(s, quoted=False) just returns s.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 04 May 2015 10:01:03 +0900 |
parents | 554d6fcc3c84 |
children | e8ff0b09acac |
line wrap: on
line diff
--- a/mercurial/templater.py Tue Apr 14 12:45:15 2015 -0700 +++ b/mercurial/templater.py Mon May 04 10:01:03 2015 +0900 @@ -618,28 +618,25 @@ for j in _flatten(i): yield j -def parsestring(s, quoted=True): - '''unwrap quotes if quoted is True''' - if quoted: - 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 +def parsestring(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) class engine(object): '''template expansion engine.