Mercurial > hg-stable
changeset 25490:ad14fb602e5e
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 09 Jun 2015 13:21:20 -0500 |
parents | ef8956aa8755 (current diff) 7298da81f5a9 (diff) |
children | 8cd0159207df |
files | mercurial/templater.py tests/test-command-template.t |
diffstat | 2 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templater.py Sat Apr 04 01:03:52 2015 -0700 +++ b/mercurial/templater.py Tue Jun 09 13:21:20 2015 -0500 @@ -364,12 +364,13 @@ yield dictarg.get(key) def _evalifliteral(arg, context, mapping): - t = stringify(arg[0](context, mapping, arg[1])) - if arg[0] == runstring or arg[0] == runrawstring: + # get back to token tag to reinterpret string as template + strtoken = {runstring: 'string', runrawstring: 'rawstring'}.get(arg[0]) + if strtoken: yield runtemplate(context, mapping, - compiletemplate(t, context, strtoken='rawstring')) + compiletemplate(arg[1], context, strtoken)) else: - yield t + yield stringify(arg[0](context, mapping, arg[1])) def if_(context, mapping, args): """:if(expr, then[, else]): Conditionally execute based on the result of
--- a/tests/test-command-template.t Sat Apr 04 01:03:52 2015 -0700 +++ b/tests/test-command-template.t Tue Jun 09 13:21:20 2015 -0500 @@ -2857,6 +2857,17 @@ \{rev} \{file} \\\head1 $ cd .. +Test leading backslashes in "if" expression (issue4714): + + $ cd latesttag + $ hg log -r 2 -T '{if("1", "\{rev}")} {if("1", r"\{rev}")}\n' + {rev} \2 + $ hg log -r 2 -T '{if("1", "\\{rev}")} {if("1", r"\\{rev}")}\n' + \2 \\2 + $ hg log -r 2 -T '{if("1", "\\\{rev}")} {if("1", r"\\\{rev}")}\n' + \{rev} \\\2 + $ cd .. + "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice) $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'