Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/fileset.py @ 25252:ac381dd7a21f
fileset: move validation of incomplete parsing to parse() function
fileset.parse() should be responsible for all parsing errors as well.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 26 Apr 2015 19:50:42 +0900 |
parents | caa6b6c65dc3 |
children | ad1d2c952889 |
comparison
equal
deleted
inserted
replaced
25251:235f6490550c | 25252:ac381dd7a21f |
---|---|
79 pos += 1 | 79 pos += 1 |
80 yield ('end', None, pos) | 80 yield ('end', None, pos) |
81 | 81 |
82 def parse(expr): | 82 def parse(expr): |
83 p = parser.parser(tokenize, elements) | 83 p = parser.parser(tokenize, elements) |
84 return p.parse(expr) | 84 tree, pos = p.parse(expr) |
85 if pos != len(expr): | |
86 raise error.ParseError(_("invalid token"), pos) | |
87 return tree | |
85 | 88 |
86 def getstring(x, err): | 89 def getstring(x, err): |
87 if x and (x[0] == 'string' or x[0] == 'symbol'): | 90 if x and (x[0] == 'string' or x[0] == 'symbol'): |
88 return x[1] | 91 return x[1] |
89 raise error.ParseError(err) | 92 raise error.ParseError(err) |
489 'size', | 492 'size', |
490 'symlink', | 493 'symlink', |
491 ] | 494 ] |
492 | 495 |
493 def getfileset(ctx, expr): | 496 def getfileset(ctx, expr): |
494 tree, pos = parse(expr) | 497 tree = parse(expr) |
495 if (pos != len(expr)): | |
496 raise error.ParseError(_("invalid token"), pos) | |
497 | 498 |
498 # do we need status info? | 499 # do we need status info? |
499 if (_intree(['modified', 'added', 'removed', 'deleted', | 500 if (_intree(['modified', 'added', 'removed', 'deleted', |
500 'unknown', 'ignored', 'clean'], tree) or | 501 'unknown', 'ignored', 'clean'], tree) or |
501 # Using matchctx.existing() on a workingctx requires us to check | 502 # Using matchctx.existing() on a workingctx requires us to check |