[PATCH 3 of 4] templater: update error message of invalid number passed to word() function

Yuya Nishihara yuya at tcha.org
Sun May 10 18:03:17 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1430549378 -32400
#      Sat May 02 15:49:38 2015 +0900
# Node ID c3e6267cfb1f263d4a559709909951af0efed9d3
# Parent  663a1ce35fd69b0dc946b467aca652a992a7ffc0
templater: update error message of invalid number passed to word() function

"word(3, desc)" is valid now.

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -569,8 +569,7 @@ def word(context, mapping, args):
         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"))
+        raise error.ParseError(_("word expects an integer index"))
     text = stringify(args[1][0](context, mapping, args[1][1]))
     if len(args) == 3:
         splitter = stringify(args[2][0](context, mapping, args[2][1]))
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -2778,5 +2778,5 @@ Test word for integer literal
 Test word for invalid numbers
 
   $ hg log -Gv -R a --template "{word('a', desc)}"
-  hg: parse error: Use strings like '3' for numbers passed to word function
+  hg: parse error: word expects an integer index
   [255]


More information about the Mercurial-devel mailing list