Mercurial supports nested quoting contexts:
ohnobinki@gibby ~/dcx-ridik-variable-substitution $ t="{'a{'b{pad('x', 2, ',', True)}'}'}"; echo "${t}"; hg log -l1 --template "${t}"; echo
{'a{'b{pad('x', 2, ',', True)}'}'}
ab,x
It also supports “weirdly quoted strings”, as I call them:
ohnobinki@gibby ~/dcx-ridik-variable-substitution $ t="{\'a{\\\\\\'b\\\\\\'}\'}"; echo "${t}"; hg log -l1 --template "${t}"; echo
{\'a{\\\'b\\\'}\'}
ab
In the following, “at 3” refers to the third opening curly brace in the whole expression.
I.e., it is a templating context starting at the first \'
.
It is like nested parser contexts cannot be mixed with “weirdly quoted strings”.
ohnobinki@gibby ~/dcx-ridik-variable-substitution $ t="{'\\\\{\\' {\\'author\\'}\\'}'}"; echo "${t}"; hg log -l1 --template "${t}\n"
{'\\{\' {\'author\'}\'}'}
hg: parse error at 3: unterminated template expansion