comparison mercurial/revset.py @ 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 93731b3efd0d
children a97ebfec8c29
comparison
equal deleted inserted replaced
14700:848a6658069e 14701:4b93bd041772
977 if isinstance(value, str): 977 if isinstance(value, str):
978 for arg in self.args: 978 for arg in self.args:
979 value = value.replace(arg, repr(arg)) 979 value = value.replace(arg, repr(arg))
980 self.replacement, pos = parse(value) 980 self.replacement, pos = parse(value)
981 if pos != len(value): 981 if pos != len(value):
982 raise error.ParseError('invalid token', pos) 982 raise error.ParseError(_('invalid token'), pos)
983 else: 983 else:
984 self.replacement = value 984 self.replacement = value
985 985
986 def match(self, tree): 986 def match(self, tree):
987 if not tree: 987 if not tree:
995 # 'func' + funcname + args 995 # 'func' + funcname + args
996 if ((self.args and len(tree) != 3) or 996 if ((self.args and len(tree) != 3) or
997 (len(self.args) == 1 and tree[2][0] == 'list') or 997 (len(self.args) == 1 and tree[2][0] == 'list') or
998 (len(self.args) > 1 and (tree[2][0] != 'list' or 998 (len(self.args) > 1 and (tree[2][0] != 'list' or
999 len(tree[2]) - 1 != len(self.args)))): 999 len(tree[2]) - 1 != len(self.args)))):
1000 raise error.ParseError('invalid amount of arguments', len(tree) - 2) 1000 raise error.ParseError(_('invalid amount of arguments'),
1001 len(tree) - 2)
1001 return True 1002 return True
1002 1003
1003 def replace(self, tree): 1004 def replace(self, tree):
1004 if tree == (self.type, self.name): 1005 if tree == (self.type, self.name):
1005 return self.replacement 1006 return self.replacement
1031 def match(ui, spec): 1032 def match(ui, spec):
1032 if not spec: 1033 if not spec:
1033 raise error.ParseError(_("empty query")) 1034 raise error.ParseError(_("empty query"))
1034 tree, pos = parse(spec) 1035 tree, pos = parse(spec)
1035 if (pos != len(spec)): 1036 if (pos != len(spec)):
1036 raise error.ParseError("invalid token", pos) 1037 raise error.ParseError(_("invalid token"), pos)
1037 tree = findaliases(ui, tree) 1038 tree = findaliases(ui, tree)
1038 weight, tree = optimize(tree, True) 1039 weight, tree = optimize(tree, True)
1039 def mfunc(repo, subset): 1040 def mfunc(repo, subset):
1040 return getset(repo, subset, tree) 1041 return getset(repo, subset, tree)
1041 return mfunc 1042 return mfunc