Show More
@@ -352,8 +352,8 def _setupdirstate(ui): | |||
|
352 | 352 | |
|
353 | 353 | sparsematch = repo.sparsematch() |
|
354 | 354 | if self.sparsematch != sparsematch or self.origignore != origignore: |
|
355 |
self.func = unionmatcher([ |
|
|
356 |
|
|
|
355 | self.func = matchmod.unionmatcher([ | |
|
356 | origignore, matchmod.negatematcher(sparsematch)]) | |
|
357 | 357 | self.sparsematch = sparsematch |
|
358 | 358 | self.origignore = origignore |
|
359 | 359 | return self.func |
@@ -448,7 +448,8 def _wraprepo(ui, repo): | |||
|
448 | 448 | include=includes, exclude=excludes, |
|
449 | 449 | default='relpath') |
|
450 | 450 | if subdirs: |
|
451 |
matcher = forceincludematcher(matcher, |
|
|
451 | matcher = matchmod.forceincludematcher(matcher, | |
|
452 | subdirs) | |
|
452 | 453 | matchers.append(matcher) |
|
453 | 454 | except IOError: |
|
454 | 455 | pass |
@@ -459,11 +460,11 def _wraprepo(ui, repo): | |||
|
459 | 460 | elif len(matchers) == 1: |
|
460 | 461 | result = matchers[0] |
|
461 | 462 | else: |
|
462 | result = unionmatcher(matchers) | |
|
463 | result = matchmod.unionmatcher(matchers) | |
|
463 | 464 | |
|
464 | 465 | if kwargs.get('includetemp', True): |
|
465 | 466 | tempincludes = sparse.readtemporaryincludes(self) |
|
466 | result = forceincludematcher(result, tempincludes) | |
|
467 | result = matchmod.forceincludematcher(result, tempincludes) | |
|
467 | 468 | |
|
468 | 469 | self._sparsematchercache[key] = result |
|
469 | 470 | |
@@ -861,83 +862,3 def _verbose_output(ui, opts, profilecou | |||
|
861 | 862 | dropped) |
|
862 | 863 | fm.condwrite(ui.verbose, 'files_conflicting', |
|
863 | 864 | 'Files conflicting: %d\n', lookup) |
|
864 | ||
|
865 | class forceincludematcher(object): | |
|
866 | """A matcher that returns true for any of the forced includes before testing | |
|
867 | against the actual matcher.""" | |
|
868 | def __init__(self, matcher, includes): | |
|
869 | self._matcher = matcher | |
|
870 | self._includes = includes | |
|
871 | ||
|
872 | def __call__(self, value): | |
|
873 | return value in self._includes or self._matcher(value) | |
|
874 | ||
|
875 | def always(self): | |
|
876 | return False | |
|
877 | ||
|
878 | def files(self): | |
|
879 | return [] | |
|
880 | ||
|
881 | def isexact(self): | |
|
882 | return False | |
|
883 | ||
|
884 | def anypats(self): | |
|
885 | return True | |
|
886 | ||
|
887 | def prefix(self): | |
|
888 | return False | |
|
889 | ||
|
890 | def __repr__(self): | |
|
891 | return ('<forceincludematcher matcher=%r, includes=%r>' % | |
|
892 | (self._matcher, sorted(self._includes))) | |
|
893 | ||
|
894 | class unionmatcher(object): | |
|
895 | """A matcher that is the union of several matchers.""" | |
|
896 | def __init__(self, matchers): | |
|
897 | self._matchers = matchers | |
|
898 | ||
|
899 | def __call__(self, value): | |
|
900 | for match in self._matchers: | |
|
901 | if match(value): | |
|
902 | return True | |
|
903 | return False | |
|
904 | ||
|
905 | def always(self): | |
|
906 | return False | |
|
907 | ||
|
908 | def files(self): | |
|
909 | return [] | |
|
910 | ||
|
911 | def isexact(self): | |
|
912 | return False | |
|
913 | ||
|
914 | def anypats(self): | |
|
915 | return True | |
|
916 | ||
|
917 | def prefix(self): | |
|
918 | return False | |
|
919 | ||
|
920 | def __repr__(self): | |
|
921 | return ('<unionmatcher matchers=%r>' % self._matchers) | |
|
922 | ||
|
923 | class negatematcher(object): | |
|
924 | def __init__(self, matcher): | |
|
925 | self._matcher = matcher | |
|
926 | ||
|
927 | def __call__(self, value): | |
|
928 | return not self._matcher(value) | |
|
929 | ||
|
930 | def always(self): | |
|
931 | return False | |
|
932 | ||
|
933 | def files(self): | |
|
934 | return [] | |
|
935 | ||
|
936 | def isexact(self): | |
|
937 | return False | |
|
938 | ||
|
939 | def anypats(self): | |
|
940 | return True | |
|
941 | ||
|
942 | def __repr__(self): | |
|
943 | return ('<negatematcher matcher=%r>' % self._matcher) |
@@ -641,6 +641,59 class subdirmatcher(basematcher): | |||
|
641 | 641 | return ('<subdirmatcher path=%r, matcher=%r>' % |
|
642 | 642 | (self._path, self._matcher)) |
|
643 | 643 | |
|
644 | class forceincludematcher(basematcher): | |
|
645 | """A matcher that returns true for any of the forced includes before testing | |
|
646 | against the actual matcher.""" | |
|
647 | def __init__(self, matcher, includes): | |
|
648 | self._matcher = matcher | |
|
649 | self._includes = includes | |
|
650 | ||
|
651 | def __call__(self, value): | |
|
652 | return value in self._includes or self._matcher(value) | |
|
653 | ||
|
654 | def anypats(self): | |
|
655 | return True | |
|
656 | ||
|
657 | def prefix(self): | |
|
658 | return False | |
|
659 | ||
|
660 | def __repr__(self): | |
|
661 | return ('<forceincludematcher matcher=%r, includes=%r>' % | |
|
662 | (self._matcher, sorted(self._includes))) | |
|
663 | ||
|
664 | class unionmatcher(basematcher): | |
|
665 | """A matcher that is the union of several matchers.""" | |
|
666 | def __init__(self, matchers): | |
|
667 | self._matchers = matchers | |
|
668 | ||
|
669 | def __call__(self, value): | |
|
670 | for match in self._matchers: | |
|
671 | if match(value): | |
|
672 | return True | |
|
673 | return False | |
|
674 | ||
|
675 | def anypats(self): | |
|
676 | return True | |
|
677 | ||
|
678 | def prefix(self): | |
|
679 | return False | |
|
680 | ||
|
681 | def __repr__(self): | |
|
682 | return ('<unionmatcher matchers=%r>' % self._matchers) | |
|
683 | ||
|
684 | class negatematcher(basematcher): | |
|
685 | def __init__(self, matcher): | |
|
686 | self._matcher = matcher | |
|
687 | ||
|
688 | def __call__(self, value): | |
|
689 | return not self._matcher(value) | |
|
690 | ||
|
691 | def anypats(self): | |
|
692 | return True | |
|
693 | ||
|
694 | def __repr__(self): | |
|
695 | return ('<negatematcher matcher=%r>' % self._matcher) | |
|
696 | ||
|
644 | 697 | def patkind(pattern, default=None): |
|
645 | 698 | '''If pattern is 'kind:pat' with a known kind, return kind.''' |
|
646 | 699 | return _patsplit(pattern, default)[0] |
General Comments 0
You need to be logged in to leave comments.
Login now