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