Show More
@@ -7,6 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
|
10 | import errno | |||
10 | import re |
|
11 | import re | |
11 |
|
12 | |||
12 | from .i18n import _ |
|
13 | from .i18n import _ | |
@@ -563,8 +564,56 b' class matchctx(object):' | |||||
563 | self._existingenabled = False |
|
564 | self._existingenabled = False | |
564 | def status(self): |
|
565 | def status(self): | |
565 | return self._status |
|
566 | return self._status | |
|
567 | ||||
566 | def matcher(self, patterns): |
|
568 | def matcher(self, patterns): | |
567 | return self.ctx.match(patterns, badfn=self._badfn) |
|
569 | return self.ctx.match(patterns, badfn=self._badfn) | |
|
570 | ||||
|
571 | def predicate(self, predfn, predrepr=None, cache=False): | |||
|
572 | """Create a matcher to select files by predfn(filename)""" | |||
|
573 | if cache: | |||
|
574 | predfn = util.cachefunc(predfn) | |||
|
575 | repo = self.ctx.repo() | |||
|
576 | return matchmod.predicatematcher(repo.root, repo.getcwd(), predfn, | |||
|
577 | predrepr=predrepr, badfn=self._badfn) | |||
|
578 | ||||
|
579 | def fpredicate(self, predfn, predrepr=None, cache=False): | |||
|
580 | """Create a matcher to select files by predfn(fctx) at the current | |||
|
581 | revision | |||
|
582 | ||||
|
583 | Missing files are ignored. | |||
|
584 | """ | |||
|
585 | ctx = self.ctx | |||
|
586 | if ctx.rev() is None: | |||
|
587 | def fctxpredfn(f): | |||
|
588 | try: | |||
|
589 | fctx = ctx[f] | |||
|
590 | except error.LookupError: | |||
|
591 | return False | |||
|
592 | try: | |||
|
593 | fctx.audit() | |||
|
594 | except error.Abort: | |||
|
595 | return False | |||
|
596 | try: | |||
|
597 | return predfn(fctx) | |||
|
598 | except (IOError, OSError) as e: | |||
|
599 | if e.errno in (errno.ENOENT, errno.ENOTDIR, errno.EISDIR): | |||
|
600 | return False | |||
|
601 | raise | |||
|
602 | else: | |||
|
603 | def fctxpredfn(f): | |||
|
604 | try: | |||
|
605 | fctx = ctx[f] | |||
|
606 | except error.LookupError: | |||
|
607 | return False | |||
|
608 | return predfn(fctx) | |||
|
609 | return self.predicate(fctxpredfn, predrepr=predrepr, cache=cache) | |||
|
610 | ||||
|
611 | def never(self): | |||
|
612 | """Create a matcher to select nothing""" | |||
|
613 | repo = self.ctx.repo() | |||
|
614 | return matchmod.nevermatcher(repo.root, repo.getcwd(), | |||
|
615 | badfn=self._badfn) | |||
|
616 | ||||
568 | def filter(self, files): |
|
617 | def filter(self, files): | |
569 | return [f for f in files if f in self.subset] |
|
618 | return [f for f in files if f in self.subset] | |
570 | def existing(self): |
|
619 | def existing(self): |
General Comments 0
You need to be logged in to leave comments.
Login now