609 """Create a matcher to select nothing""" |
608 """Create a matcher to select nothing""" |
610 repo = self.ctx.repo() |
609 repo = self.ctx.repo() |
611 return matchmod.nevermatcher(repo.root, repo.getcwd(), |
610 return matchmod.nevermatcher(repo.root, repo.getcwd(), |
612 badfn=self._badfn) |
611 badfn=self._badfn) |
613 |
612 |
614 def filter(self, files): |
|
615 return [f for f in files if f in self.subset] |
|
616 |
|
617 def switch(self, ctx, status=None): |
613 def switch(self, ctx, status=None): |
618 subset = self.filter(_buildsubset(ctx, status)) |
614 return matchctx(ctx, status, self._badfn) |
619 return matchctx(ctx, subset, status, self._badfn) |
|
620 |
615 |
621 class fullmatchctx(matchctx): |
616 class fullmatchctx(matchctx): |
622 """A match context where any files in any revisions should be valid""" |
617 """A match context where any files in any revisions should be valid""" |
623 |
618 |
624 def __init__(self, ctx, status=None, badfn=None): |
619 def __init__(self, ctx, status=None, badfn=None): |
625 subset = _buildsubset(ctx, status) |
620 super(fullmatchctx, self).__init__(ctx, status, badfn) |
626 super(fullmatchctx, self).__init__(ctx, subset, status, badfn) |
|
627 def switch(self, ctx, status=None): |
621 def switch(self, ctx, status=None): |
628 return fullmatchctx(ctx, status, self._badfn) |
622 return fullmatchctx(ctx, status, self._badfn) |
629 |
623 |
630 # filesets using matchctx.switch() |
624 # filesets using matchctx.switch() |
631 _switchcallers = [ |
625 _switchcallers = [ |
644 for s in tree[1:]: |
638 for s in tree[1:]: |
645 if _intree(funcs, s): |
639 if _intree(funcs, s): |
646 return True |
640 return True |
647 return False |
641 return False |
648 |
642 |
649 def _buildsubset(ctx, status): |
|
650 if status: |
|
651 subset = [] |
|
652 for c in status: |
|
653 subset.extend(c) |
|
654 return subset |
|
655 else: |
|
656 return list(ctx.walk(ctx.match([]))) |
|
657 |
|
658 def match(ctx, expr, badfn=None): |
643 def match(ctx, expr, badfn=None): |
659 """Create a matcher for a single fileset expression""" |
644 """Create a matcher for a single fileset expression""" |
660 tree = parse(expr) |
645 tree = parse(expr) |
661 mctx = fullmatchctx(ctx, _buildstatus(ctx, tree), badfn=badfn) |
646 mctx = fullmatchctx(ctx, _buildstatus(ctx, tree), badfn=badfn) |
662 return getmatch(mctx, tree) |
647 return getmatch(mctx, tree) |