636 |
636 |
637 def __init__(self, root, kindpats, badfn=None): |
637 def __init__(self, root, kindpats, badfn=None): |
638 super(patternmatcher, self).__init__(badfn) |
638 super(patternmatcher, self).__init__(badfn) |
639 kindpats.sort() |
639 kindpats.sort() |
640 |
640 |
|
641 roots, dirs, parents = _rootsdirsandparents(kindpats) |
641 self._files = _explicitfiles(kindpats) |
642 self._files = _explicitfiles(kindpats) |
|
643 self._dirs_explicit = set(dirs) |
|
644 self._dirs = parents |
642 self._prefix = _prefix(kindpats) |
645 self._prefix = _prefix(kindpats) |
643 self._pats, self._matchfn = _buildmatch(kindpats, b'$', root) |
646 self._pats, self._matchfn = _buildmatch(kindpats, b'$', root) |
644 |
647 |
645 def matchfn(self, fn): |
648 def matchfn(self, fn): |
646 if fn in self._fileset: |
649 if fn in self._fileset: |
647 return True |
650 return True |
648 return self._matchfn(fn) |
651 return self._matchfn(fn) |
649 |
652 |
650 @propertycache |
|
651 def _dirs(self): |
|
652 return set(pathutil.dirs(self._fileset)) |
|
653 |
|
654 def visitdir(self, dir): |
653 def visitdir(self, dir): |
655 if self._prefix and dir in self._fileset: |
654 if self._prefix and dir in self._fileset: |
656 return b'all' |
655 return b'all' |
657 return dir in self._dirs or path_or_parents_in_set(dir, self._fileset) |
656 return ( |
|
657 dir in self._dirs |
|
658 or path_or_parents_in_set(dir, self._fileset) |
|
659 or path_or_parents_in_set(dir, self._dirs_explicit) |
|
660 ) |
658 |
661 |
659 def visitchildrenset(self, dir): |
662 def visitchildrenset(self, dir): |
660 ret = self.visitdir(dir) |
663 ret = self.visitdir(dir) |
661 if ret is True: |
664 if ret is True: |
662 return b'this' |
665 return b'this' |