Show More
@@ -618,14 +618,13 b' def _flatten(thing):' | |||||
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] |
|
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. |
@@ -2250,6 +2250,29 b' Test string escaping:' | |||||
2250 | <>\n<]> |
|
2250 | <>\n<]> | |
2251 | <>\n< |
|
2251 | <>\n< | |
2252 |
|
2252 | |||
|
2253 | $ hg log -R latesttag -r 0 \ | |||
|
2254 | > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' | |||
|
2255 | > | |||
|
2256 | <>\n<[> | |||
|
2257 | <>\n<]> | |||
|
2258 | <>\n< | |||
|
2259 | ||||
|
2260 | $ hg log -R latesttag -r 0 -T esc \ | |||
|
2261 | > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' | |||
|
2262 | > | |||
|
2263 | <>\n<[> | |||
|
2264 | <>\n<]> | |||
|
2265 | <>\n< | |||
|
2266 | ||||
|
2267 | $ cat <<'EOF' > esctmpl | |||
|
2268 | > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' | |||
|
2269 | > EOF | |||
|
2270 | $ hg log -R latesttag -r 0 --style ./esctmpl | |||
|
2271 | > | |||
|
2272 | <>\n<[> | |||
|
2273 | <>\n<]> | |||
|
2274 | <>\n< | |||
|
2275 | ||||
2253 | "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice) |
|
2276 | "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice) | |
2254 |
|
2277 | |||
2255 | $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n' |
|
2278 | $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n' |
General Comments 0
You need to be logged in to leave comments.
Login now