##// END OF EJS Templates
revset: report a parse error if a revset is not parsed completely (issue2654)
Bernhard Leiner -
r14496:ffcb7e4d stable
parent child Browse files
Show More
@@ -1214,7 +1214,7 b' def debugpushkey(ui, repopath, namespace'
1214 1214 def debugrevspec(ui, repo, expr):
1215 1215 '''parse and apply a revision specification'''
1216 1216 if ui.verbose:
1217 tree = revset.parse(expr)
1217 tree = revset.parse(expr)[0]
1218 1218 ui.note(tree, "\n")
1219 1219 func = revset.match(expr)
1220 1220 for c in func(repo, range(len(repo))):
@@ -78,7 +78,9 b' class parser(object):'
78 78 'generate a parse tree from a message'
79 79 self._iter = self._tokenizer(message)
80 80 self._advance()
81 return self._parse()
81 res = self._parse()
82 token, value, pos = self.current
83 return res, pos
82 84 def eval(self, tree):
83 85 'recursively evaluate a parse tree using node methods'
84 86 if not isinstance(tree, tuple):
@@ -810,7 +810,9 b' parse = parser.parser(tokenize, elements'
810 810 def match(spec):
811 811 if not spec:
812 812 raise error.ParseError(_("empty query"))
813 tree = parse(spec)
813 tree, pos = parse(spec)
814 if (pos != len(spec)):
815 raise error.ParseError("invalid token", pos)
814 816 weight, tree = optimize(tree, True)
815 817 def mfunc(repo, subset):
816 818 return getset(repo, subset, tree)
@@ -69,7 +69,6 b' def tokenizer(data):'
69 69 else:
70 70 raise error.ParseError(_("syntax error"), pos)
71 71 pos += 1
72 data[2] = pos
73 72 yield ('end', None, pos)
74 73
75 74 def compiletemplate(tmpl, context):
@@ -91,8 +90,8 b' def compiletemplate(tmpl, context):'
91 90 parsed.append(("string", tmpl[pos:n]))
92 91
93 92 pd = [tmpl, n + 1, stop]
94 parsed.append(p.parse(pd))
95 pos = pd[2]
93 parseres, pos = p.parse(pd)
94 parsed.append(parseres)
96 95
97 96 return [compileexp(e, context) for e in parsed]
98 97
@@ -356,3 +356,10 b' issue2437'
356 356 9
357 357 $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(é)))'
358 358 4
359
360 issue2654: report a parse error if the revset was not completely parsed
361
362 $ log '1 OR 2'
363 hg: parse error at 2: invalid token
364 [255]
365
General Comments 0
You need to be logged in to leave comments. Login now