Mercurial > hg-stable
changeset 19058:d8d548d868d3
template: call runtemplate on the src argument to sub
This allows using a template keyword on calls to the sub function and brings
the function inline with most other semantics of the other template functions.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Wed, 10 Apr 2013 19:27:49 -0500 |
parents | 3d265e0822d3 |
children | 53eadcb814fd |
files | mercurial/templater.py tests/test-command-template.t |
diffstat | 2 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templater.py Wed Apr 17 03:41:34 2013 +0200 +++ b/mercurial/templater.py Wed Apr 10 19:27:49 2013 -0500 @@ -251,6 +251,8 @@ pat = stringify(args[0][0](context, mapping, args[0][1])) rpl = stringify(args[1][0](context, mapping, args[1][1])) src = stringify(args[2][0](context, mapping, args[2][1])) + src = stringify(runtemplate(context, mapping, + compiletemplate(src, context))) yield re.sub(pat, rpl, src) def if_(context, mapping, args):
--- a/tests/test-command-template.t Wed Apr 17 03:41:34 2013 +0200 +++ b/tests/test-command-template.t Wed Apr 10 19:27:49 2013 -0500 @@ -1531,3 +1531,7 @@ $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n' modified files: .hgtags +Test the sub function of templating for expansion: + + $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n' + xx