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

login
register
mail settings
Submitter Yuya Nishihara
Date May 10, 2015, 11:03 p.m.
Message ID <c3e6267cfb1f263d4a55.1431298997@mimosa>
Download mbox | patch
Permalink /patch/9013/
State Accepted
Headers show

Comments

Yuya Nishihara - May 10, 2015, 11:03 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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]