# HG changeset patch # User Martin von Zweigbergk # Date 2019-02-10 22:35:36 # Node ID ddbebce946651d28f466c58b06503916d1d0d7b3 # Parent e178b131906aa6e1b55c6e904b3c47e602b68375 match: delete unused root and cwd arguments to constructors (API) Most matchers no longer need the root and cwd arguments. patternmatcher and includematcher still need the root argument for subincludes. Differential Revision: https://phab.mercurial-scm.org/D5929 diff --git a/hgext/sparse.py b/hgext/sparse.py --- a/hgext/sparse.py +++ b/hgext/sparse.py @@ -199,7 +199,7 @@ def _setupdirstate(ui): def walk(orig, self, match, subrepos, unknown, ignored, full=True): # hack to not exclude explicitly-specified paths so that they can # be warned later on e.g. dirstate.add() - em = matchmod.exact(match._root, match._cwd, match.files()) + em = matchmod.exact(None, None, match.files()) sm = matchmod.unionmatcher([self._sparsematcher, em]) match = matchmod.intersectmatchers(match, sm) return orig(self, match, subrepos, unknown, ignored, full) diff --git a/mercurial/fileset.py b/mercurial/fileset.py --- a/mercurial/fileset.py +++ b/mercurial/fileset.py @@ -499,9 +499,8 @@ class matchctx(object): """Create a matcher to select files by predfn(filename)""" if cache: predfn = util.cachefunc(predfn) - repo = self.ctx.repo() - return matchmod.predicatematcher(repo.root, repo.getcwd(), predfn, - predrepr=predrepr, badfn=self._badfn) + return matchmod.predicatematcher(predfn, predrepr=predrepr, + badfn=self._badfn) def fpredicate(self, predfn, predrepr=None, cache=False): """Create a matcher to select files by predfn(fctx) at the current diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1252,7 +1252,7 @@ class localrepository(object): if includeexact and not self._narrowmatch.always(): # do not exclude explicitly-specified paths so that they can # be warned later on - em = matchmod.exact(match._root, match._cwd, match.files()) + em = matchmod.exact(None, None, match.files()) nm = matchmod.unionmatcher([self._narrowmatch, em]) return matchmod.intersectmatchers(match, nm) return matchmod.intersectmatchers(match, self._narrowmatch) diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -42,7 +42,7 @@ def _rematcher(regex): except AttributeError: return m.match -def _expandsets(root, cwd, kindpats, ctx, listsubrepos, badfn): +def _expandsets(kindpats, ctx, listsubrepos, badfn): '''Returns the kindpats list with the 'set' patterns expanded to matchers''' matchers = [] other = [] @@ -57,7 +57,7 @@ def _expandsets(root, cwd, kindpats, ctx if listsubrepos: for subpath in ctx.substate: sm = ctx.sub(subpath).matchfileset(pat, badfn=badfn) - pm = prefixdirmatcher(root, cwd, subpath, sm, badfn=badfn) + pm = prefixdirmatcher(subpath, sm, badfn=badfn) matchers.append(pm) continue @@ -97,18 +97,18 @@ def _kindpatsalwaysmatch(kindpats): return False return True -def _buildkindpatsmatcher(matchercls, root, cwd, kindpats, ctx=None, +def _buildkindpatsmatcher(matchercls, root, kindpats, ctx=None, listsubrepos=False, badfn=None): matchers = [] - fms, kindpats = _expandsets(root, cwd, kindpats, ctx=ctx, + fms, kindpats = _expandsets(kindpats, ctx=ctx, listsubrepos=listsubrepos, badfn=badfn) if kindpats: - m = matchercls(root, cwd, kindpats, badfn=badfn) + m = matchercls(root, kindpats, badfn=badfn) matchers.append(m) if fms: matchers.extend(fms) if not matchers: - return nevermatcher(root, cwd, badfn=badfn) + return nevermatcher(badfn=badfn) if len(matchers) == 1: return matchers[0] return unionmatcher(matchers) @@ -169,36 +169,35 @@ def match(root, cwd, patterns=None, incl if patterns: kindpats = normalize(patterns, default, root, cwd, auditor, warn) if _kindpatsalwaysmatch(kindpats): - m = alwaysmatcher(root, cwd, badfn) + m = alwaysmatcher(badfn) else: - m = _buildkindpatsmatcher(patternmatcher, root, cwd, kindpats, - ctx=ctx, listsubrepos=listsubrepos, - badfn=badfn) + m = _buildkindpatsmatcher(patternmatcher, root, kindpats, ctx=ctx, + listsubrepos=listsubrepos, badfn=badfn) else: # It's a little strange that no patterns means to match everything. # Consider changing this to match nothing (probably using nevermatcher). - m = alwaysmatcher(root, cwd, badfn) + m = alwaysmatcher(badfn) if include: kindpats = normalize(include, 'glob', root, cwd, auditor, warn) - im = _buildkindpatsmatcher(includematcher, root, cwd, kindpats, ctx=ctx, + im = _buildkindpatsmatcher(includematcher, root, kindpats, ctx=ctx, listsubrepos=listsubrepos, badfn=None) m = intersectmatchers(m, im) if exclude: kindpats = normalize(exclude, 'glob', root, cwd, auditor, warn) - em = _buildkindpatsmatcher(includematcher, root, cwd, kindpats, ctx=ctx, + em = _buildkindpatsmatcher(includematcher, root, kindpats, ctx=ctx, listsubrepos=listsubrepos, badfn=None) m = differencematcher(m, em) return m def exact(root, cwd, files, badfn=None): - return exactmatcher(root, cwd, files, badfn=badfn) + return exactmatcher(files, badfn=badfn) def always(root, cwd, badfn=None): - return alwaysmatcher(root, cwd, badfn=badfn) + return alwaysmatcher(badfn=badfn) def never(root, cwd, badfn=None): - return nevermatcher(root, cwd, badfn=badfn) + return nevermatcher(badfn=badfn) def badmatch(match, badfn): """Make a copy of the given matcher, replacing its bad method with the given @@ -251,9 +250,7 @@ def _donormalize(patterns, default, root class basematcher(object): - def __init__(self, root, cwd, badfn=None): - self._root = root - self._cwd = cwd + def __init__(self, badfn=None): if badfn is not None: self.bad = badfn @@ -376,8 +373,8 @@ class basematcher(object): class alwaysmatcher(basematcher): '''Matches everything.''' - def __init__(self, root, cwd, badfn=None): - super(alwaysmatcher, self).__init__(root, cwd, badfn) + def __init__(self, badfn=None): + super(alwaysmatcher, self).__init__(badfn) def always(self): return True @@ -397,8 +394,8 @@ class alwaysmatcher(basematcher): class nevermatcher(basematcher): '''Matches nothing.''' - def __init__(self, root, cwd, badfn=None): - super(nevermatcher, self).__init__(root, cwd, badfn) + def __init__(self, badfn=None): + super(nevermatcher, self).__init__(badfn) # It's a little weird to say that the nevermatcher is an exact matcher # or a prefix matcher, but it seems to make sense to let callers take @@ -423,8 +420,8 @@ class nevermatcher(basematcher): class predicatematcher(basematcher): """A matcher adapter for a simple boolean function""" - def __init__(self, root, cwd, predfn, predrepr=None, badfn=None): - super(predicatematcher, self).__init__(root, cwd, badfn) + def __init__(self, predfn, predrepr=None, badfn=None): + super(predicatematcher, self).__init__(badfn) self.matchfn = predfn self._predrepr = predrepr @@ -436,8 +433,8 @@ class predicatematcher(basematcher): class patternmatcher(basematcher): - def __init__(self, root, cwd, kindpats, badfn=None): - super(patternmatcher, self).__init__(root, cwd, badfn) + def __init__(self, root, kindpats, badfn=None): + super(patternmatcher, self).__init__(badfn) self._files = _explicitfiles(kindpats) self._prefix = _prefix(kindpats) @@ -514,8 +511,8 @@ class _dirchildren(object): class includematcher(basematcher): - def __init__(self, root, cwd, kindpats, badfn=None): - super(includematcher, self).__init__(root, cwd, badfn) + def __init__(self, root, kindpats, badfn=None): + super(includematcher, self).__init__(badfn) self._pats, self.matchfn = _buildmatch(kindpats, '(?:/|$)', root) self._prefix = _prefix(kindpats) @@ -575,8 +572,8 @@ class exactmatcher(basematcher): patterns (so no kind-prefixes). ''' - def __init__(self, root, cwd, files, badfn=None): - super(exactmatcher, self).__init__(root, cwd, badfn) + def __init__(self, files, badfn=None): + super(exactmatcher, self).__init__(badfn) if isinstance(files, list): self._files = files @@ -623,11 +620,11 @@ class differencematcher(basematcher): '''Composes two matchers by matching if the first matches and the second does not. - The second matcher's non-matching-attributes (root, cwd, bad, explicitdir, + The second matcher's non-matching-attributes (bad, explicitdir, traversedir) are ignored. ''' def __init__(self, m1, m2): - super(differencematcher, self).__init__(m1._root, m1._cwd) + super(differencematcher, self).__init__() self._m1 = m1 self._m2 = m2 self.bad = m1.bad @@ -691,7 +688,7 @@ class differencematcher(basematcher): def intersectmatchers(m1, m2): '''Composes two matchers by matching if both of them match. - The second matcher's non-matching-attributes (root, cwd, bad, explicitdir, + The second matcher's non-matching-attributes (bad, explicitdir, traversedir) are ignored. ''' if m1 is None or m2 is None: @@ -711,7 +708,7 @@ def intersectmatchers(m1, m2): class intersectionmatcher(basematcher): def __init__(self, m1, m2): - super(intersectionmatcher, self).__init__(m1._root, m1._cwd) + super(intersectionmatcher, self).__init__() self._m1 = m1 self._m2 = m2 self.bad = m1.bad @@ -798,7 +795,7 @@ class subdirmatcher(basematcher): """ def __init__(self, path, matcher): - super(subdirmatcher, self).__init__(matcher._root, matcher._cwd) + super(subdirmatcher, self).__init__() self._path = path self._matcher = matcher self._always = matcher.always() @@ -849,14 +846,14 @@ class subdirmatcher(basematcher): class prefixdirmatcher(basematcher): """Adapt a matcher to work on a parent directory. - The matcher's non-matching-attributes (root, cwd, bad, explicitdir, - traversedir) are ignored. + The matcher's non-matching-attributes (bad, explicitdir, traversedir) are + ignored. The prefix path should usually be the relative path from the root of this matcher to the root of the wrapped matcher. >>> m1 = match(util.localpath(b'root/d/e'), b'f', [b'../a.txt', b'b.txt']) - >>> m2 = prefixdirmatcher(b'root', b'd/e/f', b'd/e', m1) + >>> m2 = prefixdirmatcher(b'd/e', m1) >>> bool(m2(b'a.txt'),) False >>> bool(m2(b'd/e/a.txt')) @@ -879,8 +876,8 @@ class prefixdirmatcher(basematcher): False """ - def __init__(self, root, cwd, path, matcher, badfn=None): - super(prefixdirmatcher, self).__init__(root, cwd, badfn) + def __init__(self, path, matcher, badfn=None): + super(prefixdirmatcher, self).__init__(badfn) if not path: raise error.ProgrammingError('prefix path must not be empty') self._path = path @@ -930,13 +927,13 @@ class prefixdirmatcher(basematcher): class unionmatcher(basematcher): """A matcher that is the union of several matchers. - The non-matching-attributes (root, cwd, bad, explicitdir, traversedir) are - taken from the first matcher. + The non-matching-attributes (bad, explicitdir, traversedir) are taken from + the first matcher. """ def __init__(self, matchers): m1 = matchers[0] - super(unionmatcher, self).__init__(m1._root, m1._cwd) + super(unionmatcher, self).__init__() self.explicitdir = m1.explicitdir self.traversedir = m1.traversedir self._matchers = matchers diff --git a/mercurial/sparse.py b/mercurial/sparse.py --- a/mercurial/sparse.py +++ b/mercurial/sparse.py @@ -264,7 +264,7 @@ def forceincludematcher(matcher, include """Returns a matcher that returns true for any of the forced includes before testing against the actual matcher.""" kindpats = [('path', include, '') for include in includes] - includematcher = matchmod.includematcher('', '', kindpats) + includematcher = matchmod.includematcher('', kindpats) return matchmod.unionmatcher([includematcher, matcher]) def matcher(repo, revs=None, includetemp=True): diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -821,8 +821,7 @@ class hgsubrepo(abstractsubrepo): try: sm = sub.matchfileset(expr, badfn=badfn) - pm = matchmod.prefixdirmatcher(repo.root, repo.getcwd(), - subpath, sm, badfn=badfn) + pm = matchmod.prefixdirmatcher(subpath, sm, badfn=badfn) matchers.append(pm) except error.LookupError: self.ui.status(_("skipping missing subrepository: %s\n") diff --git a/tests/test-match.py b/tests/test-match.py --- a/tests/test-match.py +++ b/tests/test-match.py @@ -12,36 +12,36 @@ from mercurial import ( class BaseMatcherTests(unittest.TestCase): def testVisitdir(self): - m = matchmod.basematcher(b'', b'') + m = matchmod.basematcher() self.assertTrue(m.visitdir(b'.')) self.assertTrue(m.visitdir(b'dir')) def testVisitchildrenset(self): - m = matchmod.basematcher(b'', b'') + m = matchmod.basematcher() self.assertEqual(m.visitchildrenset(b'.'), b'this') self.assertEqual(m.visitchildrenset(b'dir'), b'this') class AlwaysMatcherTests(unittest.TestCase): def testVisitdir(self): - m = matchmod.alwaysmatcher(b'', b'') + m = matchmod.alwaysmatcher() self.assertEqual(m.visitdir(b'.'), b'all') self.assertEqual(m.visitdir(b'dir'), b'all') def testVisitchildrenset(self): - m = matchmod.alwaysmatcher(b'', b'') + m = matchmod.alwaysmatcher() self.assertEqual(m.visitchildrenset(b'.'), b'all') self.assertEqual(m.visitchildrenset(b'dir'), b'all') class NeverMatcherTests(unittest.TestCase): def testVisitdir(self): - m = matchmod.nevermatcher(b'', b'') + m = matchmod.nevermatcher() self.assertFalse(m.visitdir(b'.')) self.assertFalse(m.visitdir(b'dir')) def testVisitchildrenset(self): - m = matchmod.nevermatcher(b'', b'') + m = matchmod.nevermatcher() self.assertEqual(m.visitchildrenset(b'.'), set()) self.assertEqual(m.visitchildrenset(b'dir'), set()) @@ -50,12 +50,12 @@ class PredicateMatcherTests(unittest.Tes # this is equivalent to BaseMatcherTests. def testVisitdir(self): - m = matchmod.predicatematcher(b'', b'', lambda *a: False) + m = matchmod.predicatematcher(lambda *a: False) self.assertTrue(m.visitdir(b'.')) self.assertTrue(m.visitdir(b'dir')) def testVisitchildrenset(self): - m = matchmod.predicatematcher(b'', b'', lambda *a: False) + m = matchmod.predicatematcher(lambda *a: False) self.assertEqual(m.visitchildrenset(b'.'), b'this') self.assertEqual(m.visitchildrenset(b'dir'), b'this') @@ -223,8 +223,8 @@ class ExactMatcherTests(unittest.TestCas class DifferenceMatcherTests(unittest.TestCase): def testVisitdirM2always(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.alwaysmatcher() dm = matchmod.differencematcher(m1, m2) # dm should be equivalent to a nevermatcher. self.assertFalse(dm.visitdir(b'.')) @@ -236,8 +236,8 @@ class DifferenceMatcherTests(unittest.Te self.assertFalse(dm.visitdir(b'folder')) def testVisitchildrensetM2always(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.alwaysmatcher() dm = matchmod.differencematcher(m1, m2) # dm should be equivalent to a nevermatcher. self.assertEqual(dm.visitchildrenset(b'.'), set()) @@ -249,8 +249,8 @@ class DifferenceMatcherTests(unittest.Te self.assertEqual(dm.visitchildrenset(b'folder'), set()) def testVisitdirM2never(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.nevermatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.nevermatcher() dm = matchmod.differencematcher(m1, m2) # dm should be equivalent to a alwaysmatcher. # @@ -267,8 +267,8 @@ class DifferenceMatcherTests(unittest.Te self.assertEqual(dm.visitdir(b'folder'), b'all') def testVisitchildrensetM2never(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.nevermatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.nevermatcher() dm = matchmod.differencematcher(m1, m2) # dm should be equivalent to a alwaysmatcher. self.assertEqual(dm.visitchildrenset(b'.'), b'all') @@ -280,7 +280,7 @@ class DifferenceMatcherTests(unittest.Te self.assertEqual(dm.visitchildrenset(b'folder'), b'all') def testVisitdirM2SubdirPrefix(self): - m1 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) dm = matchmod.differencematcher(m1, m2) self.assertEqual(dm.visitdir(b'.'), True) @@ -295,7 +295,7 @@ class DifferenceMatcherTests(unittest.Te self.assertEqual(dm.visitdir(b'folder'), b'all') def testVisitchildrensetM2SubdirPrefix(self): - m1 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) dm = matchmod.differencematcher(m1, m2) self.assertEqual(dm.visitchildrenset(b'.'), b'this') @@ -344,8 +344,8 @@ class DifferenceMatcherTests(unittest.Te class IntersectionMatcherTests(unittest.TestCase): def testVisitdirM2always(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.alwaysmatcher() im = matchmod.intersectmatchers(m1, m2) # im should be equivalent to a alwaysmatcher. self.assertEqual(im.visitdir(b'.'), b'all') @@ -357,8 +357,8 @@ class IntersectionMatcherTests(unittest. self.assertEqual(im.visitdir(b'folder'), b'all') def testVisitchildrensetM2always(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.alwaysmatcher() im = matchmod.intersectmatchers(m1, m2) # im should be equivalent to a alwaysmatcher. self.assertEqual(im.visitchildrenset(b'.'), b'all') @@ -370,8 +370,8 @@ class IntersectionMatcherTests(unittest. self.assertEqual(im.visitchildrenset(b'folder'), b'all') def testVisitdirM2never(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.nevermatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.nevermatcher() im = matchmod.intersectmatchers(m1, m2) # im should be equivalent to a nevermatcher. self.assertFalse(im.visitdir(b'.')) @@ -383,8 +383,8 @@ class IntersectionMatcherTests(unittest. self.assertFalse(im.visitdir(b'folder')) def testVisitchildrensetM2never(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.nevermatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.nevermatcher() im = matchmod.intersectmatchers(m1, m2) # im should be equivalent to a nevermqtcher. self.assertEqual(im.visitchildrenset(b'.'), set()) @@ -396,7 +396,7 @@ class IntersectionMatcherTests(unittest. self.assertEqual(im.visitchildrenset(b'folder'), set()) def testVisitdirM2SubdirPrefix(self): - m1 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) im = matchmod.intersectmatchers(m1, m2) self.assertEqual(im.visitdir(b'.'), True) @@ -411,7 +411,7 @@ class IntersectionMatcherTests(unittest. self.assertEqual(im.visitdir(b'dir/subdir/x'), True) def testVisitchildrensetM2SubdirPrefix(self): - m1 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) im = matchmod.intersectmatchers(m1, m2) self.assertEqual(im.visitchildrenset(b'.'), {b'dir'}) @@ -536,8 +536,8 @@ class IntersectionMatcherTests(unittest. class UnionMatcherTests(unittest.TestCase): def testVisitdirM2always(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.alwaysmatcher() um = matchmod.unionmatcher([m1, m2]) # um should be equivalent to a alwaysmatcher. self.assertEqual(um.visitdir(b'.'), b'all') @@ -549,8 +549,8 @@ class UnionMatcherTests(unittest.TestCas self.assertEqual(um.visitdir(b'folder'), b'all') def testVisitchildrensetM2always(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.alwaysmatcher() um = matchmod.unionmatcher([m1, m2]) # um should be equivalent to a alwaysmatcher. self.assertEqual(um.visitchildrenset(b'.'), b'all') @@ -562,8 +562,8 @@ class UnionMatcherTests(unittest.TestCas self.assertEqual(um.visitchildrenset(b'folder'), b'all') def testVisitdirM1never(self): - m1 = matchmod.nevermatcher(b'', b'') - m2 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.nevermatcher() + m2 = matchmod.alwaysmatcher() um = matchmod.unionmatcher([m1, m2]) # um should be equivalent to a alwaysmatcher. self.assertEqual(um.visitdir(b'.'), b'all') @@ -575,8 +575,8 @@ class UnionMatcherTests(unittest.TestCas self.assertEqual(um.visitdir(b'folder'), b'all') def testVisitchildrensetM1never(self): - m1 = matchmod.nevermatcher(b'', b'') - m2 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.nevermatcher() + m2 = matchmod.alwaysmatcher() um = matchmod.unionmatcher([m1, m2]) # um should be equivalent to a alwaysmatcher. self.assertEqual(um.visitchildrenset(b'.'), b'all') @@ -588,8 +588,8 @@ class UnionMatcherTests(unittest.TestCas self.assertEqual(um.visitchildrenset(b'folder'), b'all') def testVisitdirM2never(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.nevermatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.nevermatcher() um = matchmod.unionmatcher([m1, m2]) # um should be equivalent to a alwaysmatcher. self.assertEqual(um.visitdir(b'.'), b'all') @@ -601,8 +601,8 @@ class UnionMatcherTests(unittest.TestCas self.assertEqual(um.visitdir(b'folder'), b'all') def testVisitchildrensetM2never(self): - m1 = matchmod.alwaysmatcher(b'', b'') - m2 = matchmod.nevermatcher(b'', b'') + m1 = matchmod.alwaysmatcher() + m2 = matchmod.nevermatcher() um = matchmod.unionmatcher([m1, m2]) # um should be equivalent to a alwaysmatcher. self.assertEqual(um.visitchildrenset(b'.'), b'all') @@ -614,7 +614,7 @@ class UnionMatcherTests(unittest.TestCas self.assertEqual(um.visitchildrenset(b'folder'), b'all') def testVisitdirM2SubdirPrefix(self): - m1 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) um = matchmod.unionmatcher([m1, m2]) self.assertEqual(um.visitdir(b'.'), b'all') @@ -626,7 +626,7 @@ class UnionMatcherTests(unittest.TestCas self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all') def testVisitchildrensetM2SubdirPrefix(self): - m1 = matchmod.alwaysmatcher(b'', b'') + m1 = matchmod.alwaysmatcher() m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) um = matchmod.unionmatcher([m1, m2]) self.assertEqual(um.visitchildrenset(b'.'), b'all') @@ -777,7 +777,7 @@ class PrefixdirMatcherTests(unittest.Tes def testVisitdir(self): m = matchmod.match(util.localpath(b'root/d'), b'e/f', [b'../a.txt', b'b.txt']) - pm = matchmod.prefixdirmatcher(b'root', b'd/e/f', b'd', m) + pm = matchmod.prefixdirmatcher(b'd', m) # `m` elides 'd' because it's part of the root, and the rest of the # patterns are relative. @@ -809,7 +809,7 @@ class PrefixdirMatcherTests(unittest.Tes def testVisitchildrenset(self): m = matchmod.match(util.localpath(b'root/d'), b'e/f', [b'../a.txt', b'b.txt']) - pm = matchmod.prefixdirmatcher(b'root', b'd/e/f', b'd', m) + pm = matchmod.prefixdirmatcher(b'd', m) # OPT: visitchildrenset could possibly return {'e'} and {'f'} for these # next two, respectively; patternmatcher does not have this