##// END OF EJS Templates
match: delete unused root and cwd arguments to constructors (API)...
Martin von Zweigbergk -
r41824:ddbebce9 default
parent child Browse files
Show More
@@ -199,7 +199,7 b' def _setupdirstate(ui):'
199 def walk(orig, self, match, subrepos, unknown, ignored, full=True):
199 def walk(orig, self, match, subrepos, unknown, ignored, full=True):
200 # hack to not exclude explicitly-specified paths so that they can
200 # hack to not exclude explicitly-specified paths so that they can
201 # be warned later on e.g. dirstate.add()
201 # be warned later on e.g. dirstate.add()
202 em = matchmod.exact(match._root, match._cwd, match.files())
202 em = matchmod.exact(None, None, match.files())
203 sm = matchmod.unionmatcher([self._sparsematcher, em])
203 sm = matchmod.unionmatcher([self._sparsematcher, em])
204 match = matchmod.intersectmatchers(match, sm)
204 match = matchmod.intersectmatchers(match, sm)
205 return orig(self, match, subrepos, unknown, ignored, full)
205 return orig(self, match, subrepos, unknown, ignored, full)
@@ -499,9 +499,8 b' class matchctx(object):'
499 """Create a matcher to select files by predfn(filename)"""
499 """Create a matcher to select files by predfn(filename)"""
500 if cache:
500 if cache:
501 predfn = util.cachefunc(predfn)
501 predfn = util.cachefunc(predfn)
502 repo = self.ctx.repo()
502 return matchmod.predicatematcher(predfn, predrepr=predrepr,
503 return matchmod.predicatematcher(repo.root, repo.getcwd(), predfn,
503 badfn=self._badfn)
504 predrepr=predrepr, badfn=self._badfn)
505
504
506 def fpredicate(self, predfn, predrepr=None, cache=False):
505 def fpredicate(self, predfn, predrepr=None, cache=False):
507 """Create a matcher to select files by predfn(fctx) at the current
506 """Create a matcher to select files by predfn(fctx) at the current
@@ -1252,7 +1252,7 b' class localrepository(object):'
1252 if includeexact and not self._narrowmatch.always():
1252 if includeexact and not self._narrowmatch.always():
1253 # do not exclude explicitly-specified paths so that they can
1253 # do not exclude explicitly-specified paths so that they can
1254 # be warned later on
1254 # be warned later on
1255 em = matchmod.exact(match._root, match._cwd, match.files())
1255 em = matchmod.exact(None, None, match.files())
1256 nm = matchmod.unionmatcher([self._narrowmatch, em])
1256 nm = matchmod.unionmatcher([self._narrowmatch, em])
1257 return matchmod.intersectmatchers(match, nm)
1257 return matchmod.intersectmatchers(match, nm)
1258 return matchmod.intersectmatchers(match, self._narrowmatch)
1258 return matchmod.intersectmatchers(match, self._narrowmatch)
@@ -42,7 +42,7 b' def _rematcher(regex):'
42 except AttributeError:
42 except AttributeError:
43 return m.match
43 return m.match
44
44
45 def _expandsets(root, cwd, kindpats, ctx, listsubrepos, badfn):
45 def _expandsets(kindpats, ctx, listsubrepos, badfn):
46 '''Returns the kindpats list with the 'set' patterns expanded to matchers'''
46 '''Returns the kindpats list with the 'set' patterns expanded to matchers'''
47 matchers = []
47 matchers = []
48 other = []
48 other = []
@@ -57,7 +57,7 b' def _expandsets(root, cwd, kindpats, ctx'
57 if listsubrepos:
57 if listsubrepos:
58 for subpath in ctx.substate:
58 for subpath in ctx.substate:
59 sm = ctx.sub(subpath).matchfileset(pat, badfn=badfn)
59 sm = ctx.sub(subpath).matchfileset(pat, badfn=badfn)
60 pm = prefixdirmatcher(root, cwd, subpath, sm, badfn=badfn)
60 pm = prefixdirmatcher(subpath, sm, badfn=badfn)
61 matchers.append(pm)
61 matchers.append(pm)
62
62
63 continue
63 continue
@@ -97,18 +97,18 b' def _kindpatsalwaysmatch(kindpats):'
97 return False
97 return False
98 return True
98 return True
99
99
100 def _buildkindpatsmatcher(matchercls, root, cwd, kindpats, ctx=None,
100 def _buildkindpatsmatcher(matchercls, root, kindpats, ctx=None,
101 listsubrepos=False, badfn=None):
101 listsubrepos=False, badfn=None):
102 matchers = []
102 matchers = []
103 fms, kindpats = _expandsets(root, cwd, kindpats, ctx=ctx,
103 fms, kindpats = _expandsets(kindpats, ctx=ctx,
104 listsubrepos=listsubrepos, badfn=badfn)
104 listsubrepos=listsubrepos, badfn=badfn)
105 if kindpats:
105 if kindpats:
106 m = matchercls(root, cwd, kindpats, badfn=badfn)
106 m = matchercls(root, kindpats, badfn=badfn)
107 matchers.append(m)
107 matchers.append(m)
108 if fms:
108 if fms:
109 matchers.extend(fms)
109 matchers.extend(fms)
110 if not matchers:
110 if not matchers:
111 return nevermatcher(root, cwd, badfn=badfn)
111 return nevermatcher(badfn=badfn)
112 if len(matchers) == 1:
112 if len(matchers) == 1:
113 return matchers[0]
113 return matchers[0]
114 return unionmatcher(matchers)
114 return unionmatcher(matchers)
@@ -169,36 +169,35 b' def match(root, cwd, patterns=None, incl'
169 if patterns:
169 if patterns:
170 kindpats = normalize(patterns, default, root, cwd, auditor, warn)
170 kindpats = normalize(patterns, default, root, cwd, auditor, warn)
171 if _kindpatsalwaysmatch(kindpats):
171 if _kindpatsalwaysmatch(kindpats):
172 m = alwaysmatcher(root, cwd, badfn)
172 m = alwaysmatcher(badfn)
173 else:
173 else:
174 m = _buildkindpatsmatcher(patternmatcher, root, cwd, kindpats,
174 m = _buildkindpatsmatcher(patternmatcher, root, kindpats, ctx=ctx,
175 ctx=ctx, listsubrepos=listsubrepos,
175 listsubrepos=listsubrepos, badfn=badfn)
176 badfn=badfn)
177 else:
176 else:
178 # It's a little strange that no patterns means to match everything.
177 # It's a little strange that no patterns means to match everything.
179 # Consider changing this to match nothing (probably using nevermatcher).
178 # Consider changing this to match nothing (probably using nevermatcher).
180 m = alwaysmatcher(root, cwd, badfn)
179 m = alwaysmatcher(badfn)
181
180
182 if include:
181 if include:
183 kindpats = normalize(include, 'glob', root, cwd, auditor, warn)
182 kindpats = normalize(include, 'glob', root, cwd, auditor, warn)
184 im = _buildkindpatsmatcher(includematcher, root, cwd, kindpats, ctx=ctx,
183 im = _buildkindpatsmatcher(includematcher, root, kindpats, ctx=ctx,
185 listsubrepos=listsubrepos, badfn=None)
184 listsubrepos=listsubrepos, badfn=None)
186 m = intersectmatchers(m, im)
185 m = intersectmatchers(m, im)
187 if exclude:
186 if exclude:
188 kindpats = normalize(exclude, 'glob', root, cwd, auditor, warn)
187 kindpats = normalize(exclude, 'glob', root, cwd, auditor, warn)
189 em = _buildkindpatsmatcher(includematcher, root, cwd, kindpats, ctx=ctx,
188 em = _buildkindpatsmatcher(includematcher, root, kindpats, ctx=ctx,
190 listsubrepos=listsubrepos, badfn=None)
189 listsubrepos=listsubrepos, badfn=None)
191 m = differencematcher(m, em)
190 m = differencematcher(m, em)
192 return m
191 return m
193
192
194 def exact(root, cwd, files, badfn=None):
193 def exact(root, cwd, files, badfn=None):
195 return exactmatcher(root, cwd, files, badfn=badfn)
194 return exactmatcher(files, badfn=badfn)
196
195
197 def always(root, cwd, badfn=None):
196 def always(root, cwd, badfn=None):
198 return alwaysmatcher(root, cwd, badfn=badfn)
197 return alwaysmatcher(badfn=badfn)
199
198
200 def never(root, cwd, badfn=None):
199 def never(root, cwd, badfn=None):
201 return nevermatcher(root, cwd, badfn=badfn)
200 return nevermatcher(badfn=badfn)
202
201
203 def badmatch(match, badfn):
202 def badmatch(match, badfn):
204 """Make a copy of the given matcher, replacing its bad method with the given
203 """Make a copy of the given matcher, replacing its bad method with the given
@@ -251,9 +250,7 b' def _donormalize(patterns, default, root'
251
250
252 class basematcher(object):
251 class basematcher(object):
253
252
254 def __init__(self, root, cwd, badfn=None):
253 def __init__(self, badfn=None):
255 self._root = root
256 self._cwd = cwd
257 if badfn is not None:
254 if badfn is not None:
258 self.bad = badfn
255 self.bad = badfn
259
256
@@ -376,8 +373,8 b' class basematcher(object):'
376 class alwaysmatcher(basematcher):
373 class alwaysmatcher(basematcher):
377 '''Matches everything.'''
374 '''Matches everything.'''
378
375
379 def __init__(self, root, cwd, badfn=None):
376 def __init__(self, badfn=None):
380 super(alwaysmatcher, self).__init__(root, cwd, badfn)
377 super(alwaysmatcher, self).__init__(badfn)
381
378
382 def always(self):
379 def always(self):
383 return True
380 return True
@@ -397,8 +394,8 b' class alwaysmatcher(basematcher):'
397 class nevermatcher(basematcher):
394 class nevermatcher(basematcher):
398 '''Matches nothing.'''
395 '''Matches nothing.'''
399
396
400 def __init__(self, root, cwd, badfn=None):
397 def __init__(self, badfn=None):
401 super(nevermatcher, self).__init__(root, cwd, badfn)
398 super(nevermatcher, self).__init__(badfn)
402
399
403 # It's a little weird to say that the nevermatcher is an exact matcher
400 # It's a little weird to say that the nevermatcher is an exact matcher
404 # or a prefix matcher, but it seems to make sense to let callers take
401 # or a prefix matcher, but it seems to make sense to let callers take
@@ -423,8 +420,8 b' class nevermatcher(basematcher):'
423 class predicatematcher(basematcher):
420 class predicatematcher(basematcher):
424 """A matcher adapter for a simple boolean function"""
421 """A matcher adapter for a simple boolean function"""
425
422
426 def __init__(self, root, cwd, predfn, predrepr=None, badfn=None):
423 def __init__(self, predfn, predrepr=None, badfn=None):
427 super(predicatematcher, self).__init__(root, cwd, badfn)
424 super(predicatematcher, self).__init__(badfn)
428 self.matchfn = predfn
425 self.matchfn = predfn
429 self._predrepr = predrepr
426 self._predrepr = predrepr
430
427
@@ -436,8 +433,8 b' class predicatematcher(basematcher):'
436
433
437 class patternmatcher(basematcher):
434 class patternmatcher(basematcher):
438
435
439 def __init__(self, root, cwd, kindpats, badfn=None):
436 def __init__(self, root, kindpats, badfn=None):
440 super(patternmatcher, self).__init__(root, cwd, badfn)
437 super(patternmatcher, self).__init__(badfn)
441
438
442 self._files = _explicitfiles(kindpats)
439 self._files = _explicitfiles(kindpats)
443 self._prefix = _prefix(kindpats)
440 self._prefix = _prefix(kindpats)
@@ -514,8 +511,8 b' class _dirchildren(object):'
514
511
515 class includematcher(basematcher):
512 class includematcher(basematcher):
516
513
517 def __init__(self, root, cwd, kindpats, badfn=None):
514 def __init__(self, root, kindpats, badfn=None):
518 super(includematcher, self).__init__(root, cwd, badfn)
515 super(includematcher, self).__init__(badfn)
519
516
520 self._pats, self.matchfn = _buildmatch(kindpats, '(?:/|$)', root)
517 self._pats, self.matchfn = _buildmatch(kindpats, '(?:/|$)', root)
521 self._prefix = _prefix(kindpats)
518 self._prefix = _prefix(kindpats)
@@ -575,8 +572,8 b' class exactmatcher(basematcher):'
575 patterns (so no kind-prefixes).
572 patterns (so no kind-prefixes).
576 '''
573 '''
577
574
578 def __init__(self, root, cwd, files, badfn=None):
575 def __init__(self, files, badfn=None):
579 super(exactmatcher, self).__init__(root, cwd, badfn)
576 super(exactmatcher, self).__init__(badfn)
580
577
581 if isinstance(files, list):
578 if isinstance(files, list):
582 self._files = files
579 self._files = files
@@ -623,11 +620,11 b' class differencematcher(basematcher):'
623 '''Composes two matchers by matching if the first matches and the second
620 '''Composes two matchers by matching if the first matches and the second
624 does not.
621 does not.
625
622
626 The second matcher's non-matching-attributes (root, cwd, bad, explicitdir,
623 The second matcher's non-matching-attributes (bad, explicitdir,
627 traversedir) are ignored.
624 traversedir) are ignored.
628 '''
625 '''
629 def __init__(self, m1, m2):
626 def __init__(self, m1, m2):
630 super(differencematcher, self).__init__(m1._root, m1._cwd)
627 super(differencematcher, self).__init__()
631 self._m1 = m1
628 self._m1 = m1
632 self._m2 = m2
629 self._m2 = m2
633 self.bad = m1.bad
630 self.bad = m1.bad
@@ -691,7 +688,7 b' class differencematcher(basematcher):'
691 def intersectmatchers(m1, m2):
688 def intersectmatchers(m1, m2):
692 '''Composes two matchers by matching if both of them match.
689 '''Composes two matchers by matching if both of them match.
693
690
694 The second matcher's non-matching-attributes (root, cwd, bad, explicitdir,
691 The second matcher's non-matching-attributes (bad, explicitdir,
695 traversedir) are ignored.
692 traversedir) are ignored.
696 '''
693 '''
697 if m1 is None or m2 is None:
694 if m1 is None or m2 is None:
@@ -711,7 +708,7 b' def intersectmatchers(m1, m2):'
711
708
712 class intersectionmatcher(basematcher):
709 class intersectionmatcher(basematcher):
713 def __init__(self, m1, m2):
710 def __init__(self, m1, m2):
714 super(intersectionmatcher, self).__init__(m1._root, m1._cwd)
711 super(intersectionmatcher, self).__init__()
715 self._m1 = m1
712 self._m1 = m1
716 self._m2 = m2
713 self._m2 = m2
717 self.bad = m1.bad
714 self.bad = m1.bad
@@ -798,7 +795,7 b' class subdirmatcher(basematcher):'
798 """
795 """
799
796
800 def __init__(self, path, matcher):
797 def __init__(self, path, matcher):
801 super(subdirmatcher, self).__init__(matcher._root, matcher._cwd)
798 super(subdirmatcher, self).__init__()
802 self._path = path
799 self._path = path
803 self._matcher = matcher
800 self._matcher = matcher
804 self._always = matcher.always()
801 self._always = matcher.always()
@@ -849,14 +846,14 b' class subdirmatcher(basematcher):'
849 class prefixdirmatcher(basematcher):
846 class prefixdirmatcher(basematcher):
850 """Adapt a matcher to work on a parent directory.
847 """Adapt a matcher to work on a parent directory.
851
848
852 The matcher's non-matching-attributes (root, cwd, bad, explicitdir,
849 The matcher's non-matching-attributes (bad, explicitdir, traversedir) are
853 traversedir) are ignored.
850 ignored.
854
851
855 The prefix path should usually be the relative path from the root of
852 The prefix path should usually be the relative path from the root of
856 this matcher to the root of the wrapped matcher.
853 this matcher to the root of the wrapped matcher.
857
854
858 >>> m1 = match(util.localpath(b'root/d/e'), b'f', [b'../a.txt', b'b.txt'])
855 >>> m1 = match(util.localpath(b'root/d/e'), b'f', [b'../a.txt', b'b.txt'])
859 >>> m2 = prefixdirmatcher(b'root', b'd/e/f', b'd/e', m1)
856 >>> m2 = prefixdirmatcher(b'd/e', m1)
860 >>> bool(m2(b'a.txt'),)
857 >>> bool(m2(b'a.txt'),)
861 False
858 False
862 >>> bool(m2(b'd/e/a.txt'))
859 >>> bool(m2(b'd/e/a.txt'))
@@ -879,8 +876,8 b' class prefixdirmatcher(basematcher):'
879 False
876 False
880 """
877 """
881
878
882 def __init__(self, root, cwd, path, matcher, badfn=None):
879 def __init__(self, path, matcher, badfn=None):
883 super(prefixdirmatcher, self).__init__(root, cwd, badfn)
880 super(prefixdirmatcher, self).__init__(badfn)
884 if not path:
881 if not path:
885 raise error.ProgrammingError('prefix path must not be empty')
882 raise error.ProgrammingError('prefix path must not be empty')
886 self._path = path
883 self._path = path
@@ -930,13 +927,13 b' class prefixdirmatcher(basematcher):'
930 class unionmatcher(basematcher):
927 class unionmatcher(basematcher):
931 """A matcher that is the union of several matchers.
928 """A matcher that is the union of several matchers.
932
929
933 The non-matching-attributes (root, cwd, bad, explicitdir, traversedir) are
930 The non-matching-attributes (bad, explicitdir, traversedir) are taken from
934 taken from the first matcher.
931 the first matcher.
935 """
932 """
936
933
937 def __init__(self, matchers):
934 def __init__(self, matchers):
938 m1 = matchers[0]
935 m1 = matchers[0]
939 super(unionmatcher, self).__init__(m1._root, m1._cwd)
936 super(unionmatcher, self).__init__()
940 self.explicitdir = m1.explicitdir
937 self.explicitdir = m1.explicitdir
941 self.traversedir = m1.traversedir
938 self.traversedir = m1.traversedir
942 self._matchers = matchers
939 self._matchers = matchers
@@ -264,7 +264,7 b' def forceincludematcher(matcher, include'
264 """Returns a matcher that returns true for any of the forced includes
264 """Returns a matcher that returns true for any of the forced includes
265 before testing against the actual matcher."""
265 before testing against the actual matcher."""
266 kindpats = [('path', include, '') for include in includes]
266 kindpats = [('path', include, '') for include in includes]
267 includematcher = matchmod.includematcher('', '', kindpats)
267 includematcher = matchmod.includematcher('', kindpats)
268 return matchmod.unionmatcher([includematcher, matcher])
268 return matchmod.unionmatcher([includematcher, matcher])
269
269
270 def matcher(repo, revs=None, includetemp=True):
270 def matcher(repo, revs=None, includetemp=True):
@@ -821,8 +821,7 b' class hgsubrepo(abstractsubrepo):'
821
821
822 try:
822 try:
823 sm = sub.matchfileset(expr, badfn=badfn)
823 sm = sub.matchfileset(expr, badfn=badfn)
824 pm = matchmod.prefixdirmatcher(repo.root, repo.getcwd(),
824 pm = matchmod.prefixdirmatcher(subpath, sm, badfn=badfn)
825 subpath, sm, badfn=badfn)
826 matchers.append(pm)
825 matchers.append(pm)
827 except error.LookupError:
826 except error.LookupError:
828 self.ui.status(_("skipping missing subrepository: %s\n")
827 self.ui.status(_("skipping missing subrepository: %s\n")
@@ -12,36 +12,36 b' from mercurial import ('
12 class BaseMatcherTests(unittest.TestCase):
12 class BaseMatcherTests(unittest.TestCase):
13
13
14 def testVisitdir(self):
14 def testVisitdir(self):
15 m = matchmod.basematcher(b'', b'')
15 m = matchmod.basematcher()
16 self.assertTrue(m.visitdir(b'.'))
16 self.assertTrue(m.visitdir(b'.'))
17 self.assertTrue(m.visitdir(b'dir'))
17 self.assertTrue(m.visitdir(b'dir'))
18
18
19 def testVisitchildrenset(self):
19 def testVisitchildrenset(self):
20 m = matchmod.basematcher(b'', b'')
20 m = matchmod.basematcher()
21 self.assertEqual(m.visitchildrenset(b'.'), b'this')
21 self.assertEqual(m.visitchildrenset(b'.'), b'this')
22 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
22 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
23
23
24 class AlwaysMatcherTests(unittest.TestCase):
24 class AlwaysMatcherTests(unittest.TestCase):
25
25
26 def testVisitdir(self):
26 def testVisitdir(self):
27 m = matchmod.alwaysmatcher(b'', b'')
27 m = matchmod.alwaysmatcher()
28 self.assertEqual(m.visitdir(b'.'), b'all')
28 self.assertEqual(m.visitdir(b'.'), b'all')
29 self.assertEqual(m.visitdir(b'dir'), b'all')
29 self.assertEqual(m.visitdir(b'dir'), b'all')
30
30
31 def testVisitchildrenset(self):
31 def testVisitchildrenset(self):
32 m = matchmod.alwaysmatcher(b'', b'')
32 m = matchmod.alwaysmatcher()
33 self.assertEqual(m.visitchildrenset(b'.'), b'all')
33 self.assertEqual(m.visitchildrenset(b'.'), b'all')
34 self.assertEqual(m.visitchildrenset(b'dir'), b'all')
34 self.assertEqual(m.visitchildrenset(b'dir'), b'all')
35
35
36 class NeverMatcherTests(unittest.TestCase):
36 class NeverMatcherTests(unittest.TestCase):
37
37
38 def testVisitdir(self):
38 def testVisitdir(self):
39 m = matchmod.nevermatcher(b'', b'')
39 m = matchmod.nevermatcher()
40 self.assertFalse(m.visitdir(b'.'))
40 self.assertFalse(m.visitdir(b'.'))
41 self.assertFalse(m.visitdir(b'dir'))
41 self.assertFalse(m.visitdir(b'dir'))
42
42
43 def testVisitchildrenset(self):
43 def testVisitchildrenset(self):
44 m = matchmod.nevermatcher(b'', b'')
44 m = matchmod.nevermatcher()
45 self.assertEqual(m.visitchildrenset(b'.'), set())
45 self.assertEqual(m.visitchildrenset(b'.'), set())
46 self.assertEqual(m.visitchildrenset(b'dir'), set())
46 self.assertEqual(m.visitchildrenset(b'dir'), set())
47
47
@@ -50,12 +50,12 b' class PredicateMatcherTests(unittest.Tes'
50 # this is equivalent to BaseMatcherTests.
50 # this is equivalent to BaseMatcherTests.
51
51
52 def testVisitdir(self):
52 def testVisitdir(self):
53 m = matchmod.predicatematcher(b'', b'', lambda *a: False)
53 m = matchmod.predicatematcher(lambda *a: False)
54 self.assertTrue(m.visitdir(b'.'))
54 self.assertTrue(m.visitdir(b'.'))
55 self.assertTrue(m.visitdir(b'dir'))
55 self.assertTrue(m.visitdir(b'dir'))
56
56
57 def testVisitchildrenset(self):
57 def testVisitchildrenset(self):
58 m = matchmod.predicatematcher(b'', b'', lambda *a: False)
58 m = matchmod.predicatematcher(lambda *a: False)
59 self.assertEqual(m.visitchildrenset(b'.'), b'this')
59 self.assertEqual(m.visitchildrenset(b'.'), b'this')
60 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
60 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
61
61
@@ -223,8 +223,8 b' class ExactMatcherTests(unittest.TestCas'
223 class DifferenceMatcherTests(unittest.TestCase):
223 class DifferenceMatcherTests(unittest.TestCase):
224
224
225 def testVisitdirM2always(self):
225 def testVisitdirM2always(self):
226 m1 = matchmod.alwaysmatcher(b'', b'')
226 m1 = matchmod.alwaysmatcher()
227 m2 = matchmod.alwaysmatcher(b'', b'')
227 m2 = matchmod.alwaysmatcher()
228 dm = matchmod.differencematcher(m1, m2)
228 dm = matchmod.differencematcher(m1, m2)
229 # dm should be equivalent to a nevermatcher.
229 # dm should be equivalent to a nevermatcher.
230 self.assertFalse(dm.visitdir(b'.'))
230 self.assertFalse(dm.visitdir(b'.'))
@@ -236,8 +236,8 b' class DifferenceMatcherTests(unittest.Te'
236 self.assertFalse(dm.visitdir(b'folder'))
236 self.assertFalse(dm.visitdir(b'folder'))
237
237
238 def testVisitchildrensetM2always(self):
238 def testVisitchildrensetM2always(self):
239 m1 = matchmod.alwaysmatcher(b'', b'')
239 m1 = matchmod.alwaysmatcher()
240 m2 = matchmod.alwaysmatcher(b'', b'')
240 m2 = matchmod.alwaysmatcher()
241 dm = matchmod.differencematcher(m1, m2)
241 dm = matchmod.differencematcher(m1, m2)
242 # dm should be equivalent to a nevermatcher.
242 # dm should be equivalent to a nevermatcher.
243 self.assertEqual(dm.visitchildrenset(b'.'), set())
243 self.assertEqual(dm.visitchildrenset(b'.'), set())
@@ -249,8 +249,8 b' class DifferenceMatcherTests(unittest.Te'
249 self.assertEqual(dm.visitchildrenset(b'folder'), set())
249 self.assertEqual(dm.visitchildrenset(b'folder'), set())
250
250
251 def testVisitdirM2never(self):
251 def testVisitdirM2never(self):
252 m1 = matchmod.alwaysmatcher(b'', b'')
252 m1 = matchmod.alwaysmatcher()
253 m2 = matchmod.nevermatcher(b'', b'')
253 m2 = matchmod.nevermatcher()
254 dm = matchmod.differencematcher(m1, m2)
254 dm = matchmod.differencematcher(m1, m2)
255 # dm should be equivalent to a alwaysmatcher.
255 # dm should be equivalent to a alwaysmatcher.
256 #
256 #
@@ -267,8 +267,8 b' class DifferenceMatcherTests(unittest.Te'
267 self.assertEqual(dm.visitdir(b'folder'), b'all')
267 self.assertEqual(dm.visitdir(b'folder'), b'all')
268
268
269 def testVisitchildrensetM2never(self):
269 def testVisitchildrensetM2never(self):
270 m1 = matchmod.alwaysmatcher(b'', b'')
270 m1 = matchmod.alwaysmatcher()
271 m2 = matchmod.nevermatcher(b'', b'')
271 m2 = matchmod.nevermatcher()
272 dm = matchmod.differencematcher(m1, m2)
272 dm = matchmod.differencematcher(m1, m2)
273 # dm should be equivalent to a alwaysmatcher.
273 # dm should be equivalent to a alwaysmatcher.
274 self.assertEqual(dm.visitchildrenset(b'.'), b'all')
274 self.assertEqual(dm.visitchildrenset(b'.'), b'all')
@@ -280,7 +280,7 b' class DifferenceMatcherTests(unittest.Te'
280 self.assertEqual(dm.visitchildrenset(b'folder'), b'all')
280 self.assertEqual(dm.visitchildrenset(b'folder'), b'all')
281
281
282 def testVisitdirM2SubdirPrefix(self):
282 def testVisitdirM2SubdirPrefix(self):
283 m1 = matchmod.alwaysmatcher(b'', b'')
283 m1 = matchmod.alwaysmatcher()
284 m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir'])
284 m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir'])
285 dm = matchmod.differencematcher(m1, m2)
285 dm = matchmod.differencematcher(m1, m2)
286 self.assertEqual(dm.visitdir(b'.'), True)
286 self.assertEqual(dm.visitdir(b'.'), True)
@@ -295,7 +295,7 b' class DifferenceMatcherTests(unittest.Te'
295 self.assertEqual(dm.visitdir(b'folder'), b'all')
295 self.assertEqual(dm.visitdir(b'folder'), b'all')
296
296
297 def testVisitchildrensetM2SubdirPrefix(self):
297 def testVisitchildrensetM2SubdirPrefix(self):
298 m1 = matchmod.alwaysmatcher(b'', b'')
298 m1 = matchmod.alwaysmatcher()
299 m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir'])
299 m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir'])
300 dm = matchmod.differencematcher(m1, m2)
300 dm = matchmod.differencematcher(m1, m2)
301 self.assertEqual(dm.visitchildrenset(b'.'), b'this')
301 self.assertEqual(dm.visitchildrenset(b'.'), b'this')
@@ -344,8 +344,8 b' class DifferenceMatcherTests(unittest.Te'
344 class IntersectionMatcherTests(unittest.TestCase):
344 class IntersectionMatcherTests(unittest.TestCase):
345
345
346 def testVisitdirM2always(self):
346 def testVisitdirM2always(self):
347 m1 = matchmod.alwaysmatcher(b'', b'')
347 m1 = matchmod.alwaysmatcher()
348 m2 = matchmod.alwaysmatcher(b'', b'')
348 m2 = matchmod.alwaysmatcher()
349 im = matchmod.intersectmatchers(m1, m2)
349 im = matchmod.intersectmatchers(m1, m2)
350 # im should be equivalent to a alwaysmatcher.
350 # im should be equivalent to a alwaysmatcher.
351 self.assertEqual(im.visitdir(b'.'), b'all')
351 self.assertEqual(im.visitdir(b'.'), b'all')
@@ -357,8 +357,8 b' class IntersectionMatcherTests(unittest.'
357 self.assertEqual(im.visitdir(b'folder'), b'all')
357 self.assertEqual(im.visitdir(b'folder'), b'all')
358
358
359 def testVisitchildrensetM2always(self):
359 def testVisitchildrensetM2always(self):
360 m1 = matchmod.alwaysmatcher(b'', b'')
360 m1 = matchmod.alwaysmatcher()
361 m2 = matchmod.alwaysmatcher(b'', b'')
361 m2 = matchmod.alwaysmatcher()
362 im = matchmod.intersectmatchers(m1, m2)
362 im = matchmod.intersectmatchers(m1, m2)
363 # im should be equivalent to a alwaysmatcher.
363 # im should be equivalent to a alwaysmatcher.
364 self.assertEqual(im.visitchildrenset(b'.'), b'all')
364 self.assertEqual(im.visitchildrenset(b'.'), b'all')
@@ -370,8 +370,8 b' class IntersectionMatcherTests(unittest.'
370 self.assertEqual(im.visitchildrenset(b'folder'), b'all')
370 self.assertEqual(im.visitchildrenset(b'folder'), b'all')
371
371
372 def testVisitdirM2never(self):
372 def testVisitdirM2never(self):
373 m1 = matchmod.alwaysmatcher(b'', b'')
373 m1 = matchmod.alwaysmatcher()
374 m2 = matchmod.nevermatcher(b'', b'')
374 m2 = matchmod.nevermatcher()
375 im = matchmod.intersectmatchers(m1, m2)
375 im = matchmod.intersectmatchers(m1, m2)
376 # im should be equivalent to a nevermatcher.
376 # im should be equivalent to a nevermatcher.
377 self.assertFalse(im.visitdir(b'.'))
377 self.assertFalse(im.visitdir(b'.'))
@@ -383,8 +383,8 b' class IntersectionMatcherTests(unittest.'
383 self.assertFalse(im.visitdir(b'folder'))
383 self.assertFalse(im.visitdir(b'folder'))
384
384
385 def testVisitchildrensetM2never(self):
385 def testVisitchildrensetM2never(self):
386 m1 = matchmod.alwaysmatcher(b'', b'')
386 m1 = matchmod.alwaysmatcher()
387 m2 = matchmod.nevermatcher(b'', b'')
387 m2 = matchmod.nevermatcher()
388 im = matchmod.intersectmatchers(m1, m2)
388 im = matchmod.intersectmatchers(m1, m2)
389 # im should be equivalent to a nevermqtcher.
389 # im should be equivalent to a nevermqtcher.
390 self.assertEqual(im.visitchildrenset(b'.'), set())
390 self.assertEqual(im.visitchildrenset(b'.'), set())
@@ -396,7 +396,7 b' class IntersectionMatcherTests(unittest.'
396 self.assertEqual(im.visitchildrenset(b'folder'), set())
396 self.assertEqual(im.visitchildrenset(b'folder'), set())
397
397
398 def testVisitdirM2SubdirPrefix(self):
398 def testVisitdirM2SubdirPrefix(self):
399 m1 = matchmod.alwaysmatcher(b'', b'')
399 m1 = matchmod.alwaysmatcher()
400 m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir'])
400 m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir'])
401 im = matchmod.intersectmatchers(m1, m2)
401 im = matchmod.intersectmatchers(m1, m2)
402 self.assertEqual(im.visitdir(b'.'), True)
402 self.assertEqual(im.visitdir(b'.'), True)
@@ -411,7 +411,7 b' class IntersectionMatcherTests(unittest.'
411 self.assertEqual(im.visitdir(b'dir/subdir/x'), True)
411 self.assertEqual(im.visitdir(b'dir/subdir/x'), True)
412
412
413 def testVisitchildrensetM2SubdirPrefix(self):
413 def testVisitchildrensetM2SubdirPrefix(self):
414 m1 = matchmod.alwaysmatcher(b'', b'')
414 m1 = matchmod.alwaysmatcher()
415 m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir'])
415 m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir'])
416 im = matchmod.intersectmatchers(m1, m2)
416 im = matchmod.intersectmatchers(m1, m2)
417 self.assertEqual(im.visitchildrenset(b'.'), {b'dir'})
417 self.assertEqual(im.visitchildrenset(b'.'), {b'dir'})
@@ -536,8 +536,8 b' class IntersectionMatcherTests(unittest.'
536 class UnionMatcherTests(unittest.TestCase):
536 class UnionMatcherTests(unittest.TestCase):
537
537
538 def testVisitdirM2always(self):
538 def testVisitdirM2always(self):
539 m1 = matchmod.alwaysmatcher(b'', b'')
539 m1 = matchmod.alwaysmatcher()
540 m2 = matchmod.alwaysmatcher(b'', b'')
540 m2 = matchmod.alwaysmatcher()
541 um = matchmod.unionmatcher([m1, m2])
541 um = matchmod.unionmatcher([m1, m2])
542 # um should be equivalent to a alwaysmatcher.
542 # um should be equivalent to a alwaysmatcher.
543 self.assertEqual(um.visitdir(b'.'), b'all')
543 self.assertEqual(um.visitdir(b'.'), b'all')
@@ -549,8 +549,8 b' class UnionMatcherTests(unittest.TestCas'
549 self.assertEqual(um.visitdir(b'folder'), b'all')
549 self.assertEqual(um.visitdir(b'folder'), b'all')
550
550
551 def testVisitchildrensetM2always(self):
551 def testVisitchildrensetM2always(self):
552 m1 = matchmod.alwaysmatcher(b'', b'')
552 m1 = matchmod.alwaysmatcher()
553 m2 = matchmod.alwaysmatcher(b'', b'')
553 m2 = matchmod.alwaysmatcher()
554 um = matchmod.unionmatcher([m1, m2])
554 um = matchmod.unionmatcher([m1, m2])
555 # um should be equivalent to a alwaysmatcher.
555 # um should be equivalent to a alwaysmatcher.
556 self.assertEqual(um.visitchildrenset(b'.'), b'all')
556 self.assertEqual(um.visitchildrenset(b'.'), b'all')
@@ -562,8 +562,8 b' class UnionMatcherTests(unittest.TestCas'
562 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
562 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
563
563
564 def testVisitdirM1never(self):
564 def testVisitdirM1never(self):
565 m1 = matchmod.nevermatcher(b'', b'')
565 m1 = matchmod.nevermatcher()
566 m2 = matchmod.alwaysmatcher(b'', b'')
566 m2 = matchmod.alwaysmatcher()
567 um = matchmod.unionmatcher([m1, m2])
567 um = matchmod.unionmatcher([m1, m2])
568 # um should be equivalent to a alwaysmatcher.
568 # um should be equivalent to a alwaysmatcher.
569 self.assertEqual(um.visitdir(b'.'), b'all')
569 self.assertEqual(um.visitdir(b'.'), b'all')
@@ -575,8 +575,8 b' class UnionMatcherTests(unittest.TestCas'
575 self.assertEqual(um.visitdir(b'folder'), b'all')
575 self.assertEqual(um.visitdir(b'folder'), b'all')
576
576
577 def testVisitchildrensetM1never(self):
577 def testVisitchildrensetM1never(self):
578 m1 = matchmod.nevermatcher(b'', b'')
578 m1 = matchmod.nevermatcher()
579 m2 = matchmod.alwaysmatcher(b'', b'')
579 m2 = matchmod.alwaysmatcher()
580 um = matchmod.unionmatcher([m1, m2])
580 um = matchmod.unionmatcher([m1, m2])
581 # um should be equivalent to a alwaysmatcher.
581 # um should be equivalent to a alwaysmatcher.
582 self.assertEqual(um.visitchildrenset(b'.'), b'all')
582 self.assertEqual(um.visitchildrenset(b'.'), b'all')
@@ -588,8 +588,8 b' class UnionMatcherTests(unittest.TestCas'
588 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
588 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
589
589
590 def testVisitdirM2never(self):
590 def testVisitdirM2never(self):
591 m1 = matchmod.alwaysmatcher(b'', b'')
591 m1 = matchmod.alwaysmatcher()
592 m2 = matchmod.nevermatcher(b'', b'')
592 m2 = matchmod.nevermatcher()
593 um = matchmod.unionmatcher([m1, m2])
593 um = matchmod.unionmatcher([m1, m2])
594 # um should be equivalent to a alwaysmatcher.
594 # um should be equivalent to a alwaysmatcher.
595 self.assertEqual(um.visitdir(b'.'), b'all')
595 self.assertEqual(um.visitdir(b'.'), b'all')
@@ -601,8 +601,8 b' class UnionMatcherTests(unittest.TestCas'
601 self.assertEqual(um.visitdir(b'folder'), b'all')
601 self.assertEqual(um.visitdir(b'folder'), b'all')
602
602
603 def testVisitchildrensetM2never(self):
603 def testVisitchildrensetM2never(self):
604 m1 = matchmod.alwaysmatcher(b'', b'')
604 m1 = matchmod.alwaysmatcher()
605 m2 = matchmod.nevermatcher(b'', b'')
605 m2 = matchmod.nevermatcher()
606 um = matchmod.unionmatcher([m1, m2])
606 um = matchmod.unionmatcher([m1, m2])
607 # um should be equivalent to a alwaysmatcher.
607 # um should be equivalent to a alwaysmatcher.
608 self.assertEqual(um.visitchildrenset(b'.'), b'all')
608 self.assertEqual(um.visitchildrenset(b'.'), b'all')
@@ -614,7 +614,7 b' class UnionMatcherTests(unittest.TestCas'
614 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
614 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
615
615
616 def testVisitdirM2SubdirPrefix(self):
616 def testVisitdirM2SubdirPrefix(self):
617 m1 = matchmod.alwaysmatcher(b'', b'')
617 m1 = matchmod.alwaysmatcher()
618 m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir'])
618 m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir'])
619 um = matchmod.unionmatcher([m1, m2])
619 um = matchmod.unionmatcher([m1, m2])
620 self.assertEqual(um.visitdir(b'.'), b'all')
620 self.assertEqual(um.visitdir(b'.'), b'all')
@@ -626,7 +626,7 b' class UnionMatcherTests(unittest.TestCas'
626 self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
626 self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
627
627
628 def testVisitchildrensetM2SubdirPrefix(self):
628 def testVisitchildrensetM2SubdirPrefix(self):
629 m1 = matchmod.alwaysmatcher(b'', b'')
629 m1 = matchmod.alwaysmatcher()
630 m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir'])
630 m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir'])
631 um = matchmod.unionmatcher([m1, m2])
631 um = matchmod.unionmatcher([m1, m2])
632 self.assertEqual(um.visitchildrenset(b'.'), b'all')
632 self.assertEqual(um.visitchildrenset(b'.'), b'all')
@@ -777,7 +777,7 b' class PrefixdirMatcherTests(unittest.Tes'
777 def testVisitdir(self):
777 def testVisitdir(self):
778 m = matchmod.match(util.localpath(b'root/d'), b'e/f',
778 m = matchmod.match(util.localpath(b'root/d'), b'e/f',
779 [b'../a.txt', b'b.txt'])
779 [b'../a.txt', b'b.txt'])
780 pm = matchmod.prefixdirmatcher(b'root', b'd/e/f', b'd', m)
780 pm = matchmod.prefixdirmatcher(b'd', m)
781
781
782 # `m` elides 'd' because it's part of the root, and the rest of the
782 # `m` elides 'd' because it's part of the root, and the rest of the
783 # patterns are relative.
783 # patterns are relative.
@@ -809,7 +809,7 b' class PrefixdirMatcherTests(unittest.Tes'
809 def testVisitchildrenset(self):
809 def testVisitchildrenset(self):
810 m = matchmod.match(util.localpath(b'root/d'), b'e/f',
810 m = matchmod.match(util.localpath(b'root/d'), b'e/f',
811 [b'../a.txt', b'b.txt'])
811 [b'../a.txt', b'b.txt'])
812 pm = matchmod.prefixdirmatcher(b'root', b'd/e/f', b'd', m)
812 pm = matchmod.prefixdirmatcher(b'd', m)
813
813
814 # OPT: visitchildrenset could possibly return {'e'} and {'f'} for these
814 # OPT: visitchildrenset could possibly return {'e'} and {'f'} for these
815 # next two, respectively; patternmatcher does not have this
815 # next two, respectively; patternmatcher does not have this
General Comments 0
You need to be logged in to leave comments. Login now