Mercurial > hg
changeset 35744:8685192a8733
templater: fix crash by empty group expression
'exp' may be None because of '(group None)' node. The error message is copied
from revset.py.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 16 Jan 2018 23:50:01 +0900 |
parents | 3c2a6246fd63 |
children | 3bd8ab4c80a5 |
files | mercurial/templater.py tests/test-command-template.t |
diffstat | 2 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templater.py Tue Jan 16 21:46:17 2018 +0900 +++ b/mercurial/templater.py Tue Jan 16 23:50:01 2018 +0900 @@ -259,6 +259,8 @@ def compileexp(exp, context, curmethods): """Compile parsed template tree to (func, data) pair""" + if not exp: + raise error.ParseError(_("missing argument")) t = exp[0] if t in curmethods: return curmethods[t](exp, context)
--- a/tests/test-command-template.t Tue Jan 16 21:46:17 2018 +0900 +++ b/tests/test-command-template.t Tue Jan 16 23:50:01 2018 +0900 @@ -2766,6 +2766,16 @@ hg: parse error at 6: invalid token [255] + $ hg log -T '{}' + hg: parse error at 2: not a prefix: end + [255] + $ hg debugtemplate -v '{()}' + (template + (group + None)) + hg: parse error: missing argument + [255] + Behind the scenes, this will throw TypeError $ hg log -l 3 --template '{date|obfuscate}\n'