Show More
@@ -638,7 +638,10 b' class patternmatcher(basematcher):' | |||
|
638 | 638 | super(patternmatcher, self).__init__(badfn) |
|
639 | 639 | kindpats.sort() |
|
640 | 640 | |
|
641 | roots, dirs, parents = _rootsdirsandparents(kindpats) | |
|
641 | 642 | self._files = _explicitfiles(kindpats) |
|
643 | self._dirs_explicit = set(dirs) | |
|
644 | self._dirs = parents | |
|
642 | 645 | self._prefix = _prefix(kindpats) |
|
643 | 646 | self._pats, self._matchfn = _buildmatch(kindpats, b'$', root) |
|
644 | 647 | |
@@ -647,14 +650,14 b' class patternmatcher(basematcher):' | |||
|
647 | 650 | return True |
|
648 | 651 | return self._matchfn(fn) |
|
649 | 652 | |
|
650 | @propertycache | |
|
651 | def _dirs(self): | |
|
652 | return set(pathutil.dirs(self._fileset)) | |
|
653 | ||
|
654 | 653 | def visitdir(self, dir): |
|
655 | 654 | if self._prefix and dir in self._fileset: |
|
656 | 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 | 662 | def visitchildrenset(self, dir): |
|
660 | 663 | ret = self.visitdir(dir) |
@@ -1461,7 +1464,7 b' def _buildregexmatch(kindpats, globsuffi' | |||
|
1461 | 1464 | allgroups = [] |
|
1462 | 1465 | regexps = [] |
|
1463 | 1466 | exact = set() |
|
1464 |
for |
|
|
1467 | for kind, pattern, _source in kindpats: | |
|
1465 | 1468 | if kind == b'filepath': |
|
1466 | 1469 | exact.add(pattern) |
|
1467 | 1470 | continue |
@@ -94,12 +94,14 b' class PatternMatcherTests(unittest.TestC' | |||
|
94 | 94 | patterns=[b'rootfilesin:dir/subdir'], |
|
95 | 95 | ) |
|
96 | 96 | assert isinstance(m, matchmod.patternmatcher) |
|
97 | self.assertFalse(m.visitdir(b'dir/subdir/x')) | |
|
97 | # OPT: we shouldn't visit [x] as a directory, | |
|
98 | # but we should still visit it as a file. | |
|
99 | # Unfortunately, `visitdir` is used for both. | |
|
100 | self.assertTrue(m.visitdir(b'dir/subdir/x')) | |
|
98 | 101 | self.assertFalse(m.visitdir(b'folder')) |
|
99 | # FIXME: These should probably be True. | |
|
100 |
self.assert |
|
|
101 |
self.assert |
|
|
102 | self.assertFalse(m.visitdir(b'dir/subdir')) | |
|
102 | self.assertTrue(m.visitdir(b'')) | |
|
103 | self.assertTrue(m.visitdir(b'dir')) | |
|
104 | self.assertTrue(m.visitdir(b'dir/subdir')) | |
|
103 | 105 | |
|
104 | 106 | def testVisitchildrensetRootfilesin(self): |
|
105 | 107 | m = matchmod.match( |
@@ -108,13 +110,13 b' class PatternMatcherTests(unittest.TestC' | |||
|
108 | 110 | patterns=[b'rootfilesin:dir/subdir'], |
|
109 | 111 | ) |
|
110 | 112 | assert isinstance(m, matchmod.patternmatcher) |
|
111 |
self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), |
|
|
113 | self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
112 | 114 | self.assertEqual(m.visitchildrenset(b'folder'), set()) |
|
113 |
# |
|
|
114 | # respectively, or at least 'this' for all three. | |
|
115 |
self.assertEqual(m.visitchildrenset(b''), |
|
|
116 |
self.assertEqual(m.visitchildrenset(b'dir'), |
|
|
117 |
self.assertEqual(m.visitchildrenset(b'dir/subdir'), |
|
|
115 | # OPT: These should probably be {'dir'}, {'subdir'} and 'this', | |
|
116 | # respectively | |
|
117 | self.assertEqual(m.visitchildrenset(b''), b'this') | |
|
118 | self.assertEqual(m.visitchildrenset(b'dir'), b'this') | |
|
119 | self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this') | |
|
118 | 120 | |
|
119 | 121 | def testVisitdirGlob(self): |
|
120 | 122 | m = matchmod.match( |
@@ -863,6 +863,7 b" in rhg it's empty, in Python it's missin" | |||
|
863 | 863 | M subdir/modified (no-rhg !) |
|
864 | 864 | R subdir/removed (no-rhg !) |
|
865 | 865 | ! subdir/deleted (no-rhg !) |
|
866 | ? subdir/unknown (no-rhg !) | |
|
866 | 867 | |
|
867 | 868 | Note: `hg status some-name` creates a patternmatcher which is not supported |
|
868 | 869 | yet by the Rust implementation of status, but includematcher is supported. |
General Comments 0
You need to be logged in to leave comments.
Login now