##// END OF EJS Templates
revset: move validation of incomplete parsing to parse() function...
Yuya Nishihara -
r25251:235f6490 default
parent child Browse files
Show More
@@ -2918,7 +2918,7 b' def debugrevspec(ui, repo, expr, **opts)'
2918 expansion.
2918 expansion.
2919 """
2919 """
2920 if ui.verbose:
2920 if ui.verbose:
2921 tree = revset.parse(expr)[0]
2921 tree = revset.parse(expr)
2922 ui.note(revset.prettyformat(tree), "\n")
2922 ui.note(revset.prettyformat(tree), "\n")
2923 newtree = revset.findaliases(ui, tree)
2923 newtree = revset.findaliases(ui, tree)
2924 if newtree != tree:
2924 if newtree != tree:
@@ -223,7 +223,7 b' def _search(web, req, tmpl):'
223
223
224 revdef = 'reverse(%s)' % query
224 revdef = 'reverse(%s)' % query
225 try:
225 try:
226 tree, pos = revset.parse(revdef)
226 tree = revset.parse(revdef)
227 except ParseError:
227 except ParseError:
228 # can't parse to a revset tree
228 # can't parse to a revset tree
229 return MODE_KEYWORD, query
229 return MODE_KEYWORD, query
@@ -2509,7 +2509,10 b' def foldconcat(tree):'
2509
2509
2510 def parse(spec, lookup=None):
2510 def parse(spec, lookup=None):
2511 p = parser.parser(tokenize, elements)
2511 p = parser.parser(tokenize, elements)
2512 return p.parse(spec, lookup=lookup)
2512 tree, pos = p.parse(spec, lookup=lookup)
2513 if pos != len(spec):
2514 raise error.ParseError(_("invalid token"), pos)
2515 return tree
2513
2516
2514 def posttreebuilthook(tree, repo):
2517 def posttreebuilthook(tree, repo):
2515 # hook for extensions to execute code on the optimized tree
2518 # hook for extensions to execute code on the optimized tree
@@ -2521,9 +2524,7 b' def match(ui, spec, repo=None):'
2521 lookup = None
2524 lookup = None
2522 if repo:
2525 if repo:
2523 lookup = repo.__contains__
2526 lookup = repo.__contains__
2524 tree, pos = parse(spec, lookup)
2527 tree = parse(spec, lookup)
2525 if (pos != len(spec)):
2526 raise error.ParseError(_("invalid token"), pos)
2527 if ui:
2528 if ui:
2528 tree = findaliases(ui, tree, showwarning=ui.warn)
2529 tree = findaliases(ui, tree, showwarning=ui.warn)
2529 tree = foldconcat(tree)
2530 tree = foldconcat(tree)
@@ -89,7 +89,7 b' o (0) root'
89 > if opts.get('print_revset'):
89 > if opts.get('print_revset'):
90 > expr = cmdutil.getgraphlogrevs(repo, pats, opts)[1]
90 > expr = cmdutil.getgraphlogrevs(repo, pats, opts)[1]
91 > if expr:
91 > if expr:
92 > tree = revset.parse(expr)[0]
92 > tree = revset.parse(expr)
93 > else:
93 > else:
94 > tree = []
94 > tree = []
95 > ui.write('%r\n' % (opts.get('rev', []),))
95 > ui.write('%r\n' % (opts.get('rev', []),))
General Comments 0
You need to be logged in to leave comments. Login now