Skip to content
Snippets Groups Projects
Commit 10a13da8 authored by Ryan McElroy's avatar Ryan McElroy
Browse files

templater: fail more gracefully for blank strings to word

parent eea3977e
No related branches found
No related tags found
No related merge requests found
......@@ -539,7 +539,12 @@
raise error.ParseError(_("word expects two or three arguments, got %d")
% len(args))
num = int(stringify(args[0][0](context, mapping, args[0][1])))
try:
num = int(stringify(args[0][0](context, mapping, args[0][1])))
except ValueError:
# i18n: "word" is a keyword
raise error.ParseError(
_("Use strings like '3' for numbers passed to word function"))
text = stringify(args[1][0](context, mapping, args[1][1]))
if len(args) == 3:
splitter = stringify(args[2][0](context, mapping, args[2][1]))
......
......@@ -2620,3 +2620,9 @@
$ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}"
hg: parse error: word expects two or three arguments, got 7
[255]
Test word for invalid numbers
$ hg log -Gv -R a --template "{word(2, desc)}"
hg: parse error: Use strings like '3' for numbers passed to word function
[255]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment