# HG changeset patch # User Yuya Nishihara # Date 1455432169 -32400 # Node ID 1987ed32efca8e93453267852b44d92dae011c27 # Parent 1d461ee26e1bf536daa7b320e6e485005ad8a37a templater: relax type of mapped template Now compiled template fragments are packed into a generic type, (func, data), a string can be a valid template. This change allows us to unwrap a trivial string node. See the next patch for details. diff -r 1d461ee26e1b -r 1987ed32efca mercurial/templater.py --- a/mercurial/templater.py Sat Feb 13 23:54:24 2016 +0900 +++ b/mercurial/templater.py Sun Feb 14 15:42:49 2016 +0900 @@ -210,7 +210,7 @@ def gettemplate(exp, context): """Compile given template tree or load named template from map file; returns (func, data) pair""" - if exp[0] == 'template': + if exp[0] in ('template', 'string'): return compileexp(exp, context, methods) if exp[0] == 'symbol': # unlike runsymbol(), here 'symbol' is always taken as template name diff -r 1d461ee26e1b -r 1987ed32efca tests/test-command-template.t --- a/tests/test-command-template.t Sat Feb 13 23:54:24 2016 +0900 +++ b/tests/test-command-template.t Sun Feb 14 15:42:49 2016 +0900 @@ -2900,12 +2900,8 @@ template: 0 $ hg log -Ra -r0 -T '{r"rawstring: {rev}"}\n' rawstring: {rev} - -because map operation requires template, raw string can't be used - - $ hg log -Ra -r0 -T '{files % r"rawstring"}\n' - hg: parse error: expected template specifier - [255] + $ hg log -Ra -r0 -T '{files % r"rawstring: {file}"}\n' + rawstring: {file} Test string escaping: