Show More
@@ -539,7 +539,12 b' def word(context, mapping, args):' | |||||
539 | raise error.ParseError(_("word expects two or three arguments, got %d") |
|
539 | raise error.ParseError(_("word expects two or three arguments, got %d") | |
540 | % len(args)) |
|
540 | % len(args)) | |
541 |
|
541 | |||
542 | num = int(stringify(args[0][0](context, mapping, args[0][1]))) |
|
542 | try: | |
|
543 | num = int(stringify(args[0][0](context, mapping, args[0][1]))) | |||
|
544 | except ValueError: | |||
|
545 | # i18n: "word" is a keyword | |||
|
546 | raise error.ParseError( | |||
|
547 | _("Use strings like '3' for numbers passed to word function")) | |||
543 | text = stringify(args[1][0](context, mapping, args[1][1])) |
|
548 | text = stringify(args[1][0](context, mapping, args[1][1])) | |
544 | if len(args) == 3: |
|
549 | if len(args) == 3: | |
545 | splitter = stringify(args[2][0](context, mapping, args[2][1])) |
|
550 | splitter = stringify(args[2][0](context, mapping, args[2][1])) |
@@ -2620,3 +2620,9 b' Test word error messages for not enough ' | |||||
2620 | $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}" |
|
2620 | $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}" | |
2621 | hg: parse error: word expects two or three arguments, got 7 |
|
2621 | hg: parse error: word expects two or three arguments, got 7 | |
2622 | [255] |
|
2622 | [255] | |
|
2623 | ||||
|
2624 | Test word for invalid numbers | |||
|
2625 | ||||
|
2626 | $ hg log -Gv -R a --template "{word(2, desc)}" | |||
|
2627 | hg: parse error: Use strings like '3' for numbers passed to word function | |||
|
2628 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now