Mercurial > public > mercurial-scm > hg
comparison mercurial/templater.py @ 24948:db7463aa080f stable
templater: do not process \-escapes at parsestring() (issue4290)
This patch brings back pre-2.8.1 behavior.
The result of parsestring() is stored in templater's cache, t.cache, and then
it is parsed as a template string by compiletemplate(). So t.cache should keep
an unparsed string no matter if it is sourced from config value. Otherwise
backslashes would be processed twice.
The test vector is borrowed from 64b4f0cd7336.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 04 May 2015 09:54:01 +0900 |
parents | 09124cce913f |
children | 890845af1ac2 |
comparison
equal
deleted
inserted
replaced
24933:5bc506ee87d2 | 24948:db7463aa080f |
---|---|
616 elif i is not None: | 616 elif i is not None: |
617 for j in _flatten(i): | 617 for j in _flatten(i): |
618 yield j | 618 yield j |
619 | 619 |
620 def parsestring(s, quoted=True): | 620 def parsestring(s, quoted=True): |
621 '''parse a string using simple c-like syntax. | 621 '''unwrap quotes if quoted is True''' |
622 string must be in quotes if quoted is True.''' | |
623 if quoted: | 622 if quoted: |
624 if len(s) < 2 or s[0] != s[-1]: | 623 if len(s) < 2 or s[0] != s[-1]: |
625 raise SyntaxError(_('unmatched quotes')) | 624 raise SyntaxError(_('unmatched quotes')) |
626 return s[1:-1].decode('string_escape') | 625 return s[1:-1] |
627 | 626 |
628 return s.decode('string_escape') | 627 return s |
629 | 628 |
630 class engine(object): | 629 class engine(object): |
631 '''template expansion engine. | 630 '''template expansion engine. |
632 | 631 |
633 template expansion works like this. a map file contains key=value | 632 template expansion works like this. a map file contains key=value |