Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/fileset.py @ 31198:ec5b56b50e19
fileset: add class to host special handling of initial subset
Future patches will add a function to switch mctx.ctx object so that we can
forcibly evaluate a fileset expression in a specified revision. For example,
new "revs()" function will be used to match predicate agains another revision
$ hg revert 'set:revs(42, added())'
fullmatchctx class is similar to revset.fullreposet. It will allow us to
recalculate the subset only if it is not filtered yet.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 24 Jan 2015 19:55:14 +0900 |
parents | d532ef155b0e |
children | 3c32a3fdfd16 |
comparison
equal
deleted
inserted
replaced
31197:6b8e1a08ef1d | 31198:ec5b56b50e19 |
---|---|
496 return (f for f in self.subset | 496 return (f for f in self.subset |
497 if (f in self.ctx and f not in removed) or f in unknown) | 497 if (f in self.ctx and f not in removed) or f in unknown) |
498 def narrow(self, files): | 498 def narrow(self, files): |
499 return matchctx(self.ctx, self.filter(files), self._status) | 499 return matchctx(self.ctx, self.filter(files), self._status) |
500 | 500 |
501 class fullmatchctx(matchctx): | |
502 """A match context where any files in any revisions should be valid""" | |
503 | |
504 def __init__(self, ctx, subset=None, status=None): | |
505 super(fullmatchctx, self).__init__(ctx, subset, status) | |
506 | |
501 def _intree(funcs, tree): | 507 def _intree(funcs, tree): |
502 if isinstance(tree, tuple): | 508 if isinstance(tree, tuple): |
503 if tree[0] == 'func' and tree[1][0] == 'symbol': | 509 if tree[0] == 'func' and tree[1][0] == 'symbol': |
504 if tree[1][1] in funcs: | 510 if tree[1][1] in funcs: |
505 return True | 511 return True |
527 subset.extend(c) | 533 subset.extend(c) |
528 else: | 534 else: |
529 status = None | 535 status = None |
530 subset = list(ctx.walk(ctx.match([]))) | 536 subset = list(ctx.walk(ctx.match([]))) |
531 | 537 |
532 return getset(matchctx(ctx, subset, status), tree) | 538 return getset(fullmatchctx(ctx, subset, status), tree) |
533 | 539 |
534 def prettyformat(tree): | 540 def prettyformat(tree): |
535 return parser.prettyformat(tree, ('string', 'symbol')) | 541 return parser.prettyformat(tree, ('string', 'symbol')) |
536 | 542 |
537 def loadpredicate(ui, extname, registrarobj): | 543 def loadpredicate(ui, extname, registrarobj): |