Mercurial > hg-stable
changeset 25251:235f6490550c
revset: move validation of incomplete parsing to parse() function
revset.parse() should be responsible for all parsing errors. Perhaps it wasn't
because 'revset.parse' was not a real function when the validation code was
added at ffcb7e4d719f.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 26 Apr 2015 19:42:47 +0900 |
parents | f9a29dc964a3 |
children | ac381dd7a21f |
files | mercurial/commands.py mercurial/hgweb/webcommands.py mercurial/revset.py tests/test-glog.t |
diffstat | 4 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Fri May 22 14:39:34 2015 -0700 +++ b/mercurial/commands.py Sun Apr 26 19:42:47 2015 +0900 @@ -2918,7 +2918,7 @@ expansion. """ if ui.verbose: - tree = revset.parse(expr)[0] + tree = revset.parse(expr) ui.note(revset.prettyformat(tree), "\n") newtree = revset.findaliases(ui, tree) if newtree != tree:
--- a/mercurial/hgweb/webcommands.py Fri May 22 14:39:34 2015 -0700 +++ b/mercurial/hgweb/webcommands.py Sun Apr 26 19:42:47 2015 +0900 @@ -223,7 +223,7 @@ revdef = 'reverse(%s)' % query try: - tree, pos = revset.parse(revdef) + tree = revset.parse(revdef) except ParseError: # can't parse to a revset tree return MODE_KEYWORD, query
--- a/mercurial/revset.py Fri May 22 14:39:34 2015 -0700 +++ b/mercurial/revset.py Sun Apr 26 19:42:47 2015 +0900 @@ -2509,7 +2509,10 @@ def parse(spec, lookup=None): p = parser.parser(tokenize, elements) - return p.parse(spec, lookup=lookup) + tree, pos = p.parse(spec, lookup=lookup) + if pos != len(spec): + raise error.ParseError(_("invalid token"), pos) + return tree def posttreebuilthook(tree, repo): # hook for extensions to execute code on the optimized tree @@ -2521,9 +2524,7 @@ lookup = None if repo: lookup = repo.__contains__ - tree, pos = parse(spec, lookup) - if (pos != len(spec)): - raise error.ParseError(_("invalid token"), pos) + tree = parse(spec, lookup) if ui: tree = findaliases(ui, tree, showwarning=ui.warn) tree = foldconcat(tree)
--- a/tests/test-glog.t Fri May 22 14:39:34 2015 -0700 +++ b/tests/test-glog.t Sun Apr 26 19:42:47 2015 +0900 @@ -89,7 +89,7 @@ > if opts.get('print_revset'): > expr = cmdutil.getgraphlogrevs(repo, pats, opts)[1] > if expr: - > tree = revset.parse(expr)[0] + > tree = revset.parse(expr) > else: > tree = [] > ui.write('%r\n' % (opts.get('rev', []),))