# HG changeset patch # User Yuya Nishihara # Date 1455422957 -32400 # Node ID 542d200bd2611003f72d3b1cce4b1277844d2e0d # Parent d81437c91a2665d9638c920d5c4b9391c683d810 templater: fix shortest() to evaluate int argument and handle error diff -r d81437c91a26 -r 542d200bd261 mercurial/templater.py --- a/mercurial/templater.py Sun Feb 14 13:05:09 2016 +0900 +++ b/mercurial/templater.py Sun Feb 14 13:09:17 2016 +0900 @@ -621,7 +621,9 @@ minlength = 4 if len(args) > 1: - minlength = int(args[1][1]) + minlength = evalinteger(context, mapping, args[1], + # i18n: "shortest" is a keyword + _("shortest() expects an integer minlength")) cl = mapping['ctx']._repo.changelog def isvalid(test): diff -r d81437c91a26 -r 542d200bd261 tests/test-command-template.t --- a/tests/test-command-template.t Sun Feb 14 13:05:09 2016 +0900 +++ b/tests/test-command-template.t Sun Feb 14 13:09:17 2016 +0900 @@ -3219,6 +3219,12 @@ $ hg log --template '{node|shortest}\n' -l1 e777 + $ hg log -r 0 -T '{shortest(node, "1{"0"}")}\n' + f7769ec2ab + $ hg log -r 0 -T '{shortest(node, "not an int")}\n' + hg: parse error: shortest() expects an integer minlength + [255] + Test pad function $ hg log --template '{pad(rev, 20)} {author|user}\n'