changeset 14701:4b93bd041772 stable

parsers: fix localization markup of parser errors
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 21 Jun 2011 00:17:52 +0200
parents 848a6658069e
children 1ec8bd909ac3
files mercurial/fileset.py mercurial/parser.py mercurial/revset.py
diffstat 3 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/fileset.py	Sun Jun 19 22:33:25 2011 -0400
+++ b/mercurial/fileset.py	Tue Jun 21 00:17:52 2011 +0200
@@ -402,7 +402,7 @@
 def getfileset(ctx, expr):
     tree, pos = parse(expr)
     if (pos != len(expr)):
-        raise error.ParseError("invalid token", pos)
+        raise error.ParseError(_("invalid token"), pos)
 
     # do we need status info?
     if _intree(['modified', 'added', 'removed', 'deleted',
--- a/mercurial/parser.py	Sun Jun 19 22:33:25 2011 -0400
+++ b/mercurial/parser.py	Tue Jun 21 00:17:52 2011 +0200
@@ -16,6 +16,7 @@
 # __call__(program) parses program into a labelled tree
 
 import error
+from i18n import _
 
 class parser(object):
     def __init__(self, tokenizer, elements, methods=None):
@@ -34,7 +35,7 @@
     def _match(self, m, pos):
         'make sure the tokenizer matches an end condition'
         if self.current[0] != m:
-            raise error.ParseError("unexpected token: %s" % self.current[0],
+            raise error.ParseError(_("unexpected token: %s") % self.current[0],
                                    self.current[2])
         self._advance()
     def _parse(self, bind=0):
@@ -42,7 +43,7 @@
         # handle prefix rules on current token
         prefix = self._elements[token][1]
         if not prefix:
-            raise error.ParseError("not a prefix: %s" % token, pos)
+            raise error.ParseError(_("not a prefix: %s") % token, pos)
         if len(prefix) == 1:
             expr = (prefix[0], value)
         else:
@@ -64,7 +65,7 @@
             else:
                 # handle infix rules
                 if len(e) < 3 or not e[2]:
-                    raise error.ParseError("not an infix: %s" % token, pos)
+                    raise error.ParseError(_("not an infix: %s") % token, pos)
                 infix = e[2]
                 if len(infix) == 3 and infix[2] == self.current[0]:
                     self._match(infix[2], pos)
--- a/mercurial/revset.py	Sun Jun 19 22:33:25 2011 -0400
+++ b/mercurial/revset.py	Tue Jun 21 00:17:52 2011 +0200
@@ -979,7 +979,7 @@
                 value = value.replace(arg, repr(arg))
             self.replacement, pos = parse(value)
             if pos != len(value):
-                raise error.ParseError('invalid token', pos)
+                raise error.ParseError(_('invalid token'), pos)
         else:
             self.replacement = value
 
@@ -997,7 +997,8 @@
             (len(self.args) == 1 and tree[2][0] == 'list') or
             (len(self.args) > 1 and (tree[2][0] != 'list' or
                                      len(tree[2]) - 1 != len(self.args)))):
-            raise error.ParseError('invalid amount of arguments', len(tree) - 2)
+            raise error.ParseError(_('invalid amount of arguments'),
+                                   len(tree) - 2)
         return True
 
     def replace(self, tree):
@@ -1033,7 +1034,7 @@
         raise error.ParseError(_("empty query"))
     tree, pos = parse(spec)
     if (pos != len(spec)):
-        raise error.ParseError("invalid token", pos)
+        raise error.ParseError(_("invalid token"), pos)
     tree = findaliases(ui, tree)
     weight, tree = optimize(tree, True)
     def mfunc(repo, subset):