# HG changeset patch # User Martin von Zweigbergk # Date 2019-02-10 06:50:53 # Node ID 0531dff73d0b4c2da085c05cb6b797a4dab7a9c9 # Parent ddbebce946651d28f466c58b06503916d1d0d7b3 match: delete unused root and cwd arguments from {always,never,exact}() (API) Differential Revision: https://phab.mercurial-scm.org/D5930 diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -476,7 +476,7 @@ def overridestatus( working = ctx2.rev() is None parentworking = working and ctx1 == self['.'] - match = match or matchmod.always(self.root, self.getcwd()) + match = match or matchmod.always() # Maybe we can use this opportunity to update Watchman's state. # Mercurial uses workingcommitctx and/or memctx to represent the part of diff --git a/hgext/gpg.py b/hgext/gpg.py --- a/hgext/gpg.py +++ b/hgext/gpg.py @@ -297,7 +297,7 @@ def _dosign(ui, repo, *revs, **opts): return if not opts["force"]: - msigs = match.exact(repo.root, '', ['.hgsigs']) + msigs = match.exact(['.hgsigs']) if any(repo.status(match=msigs, unknown=True, ignored=True)): raise error.Abort(_("working copy of .hgsigs is changed "), hint=_("please commit .hgsigs manually")) diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -168,7 +168,7 @@ def openlfdirstate(ui, repo, create=True def lfdirstatestatus(lfdirstate, repo): pctx = repo['.'] - match = matchmod.always(repo.root, repo.getcwd()) + match = matchmod.always() unsure, s = lfdirstate.status(match, subrepos=[], ignored=False, clean=False, unknown=False) modified, clean = s.modified, s.clean @@ -552,7 +552,7 @@ def updatestandinsbymatch(repo, match): # otherwise to update all standins if the largefiles are # large. lfdirstate = openlfdirstate(ui, repo) - dirtymatch = matchmod.always(repo.root, repo.getcwd()) + dirtymatch = matchmod.always() unsure, s = lfdirstate.status(dirtymatch, subrepos=[], ignored=False, clean=False, unknown=False) modifiedfiles = unsure + s.modified + s.added + s.removed diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -1222,9 +1222,8 @@ def scmutiladdremove(orig, repo, matcher return orig(repo, matcher, prefix, uipathfn, opts) # Get the list of missing largefiles so we can remove them lfdirstate = lfutil.openlfdirstate(repo.ui, repo) - unsure, s = lfdirstate.status(matchmod.always(repo.root, repo.getcwd()), - subrepos=[], ignored=False, clean=False, - unknown=False) + unsure, s = lfdirstate.status(matchmod.always(), subrepos=[], + ignored=False, clean=False, unknown=False) # Call into the normal remove code, but the removing of the standin, we want # to have handled by original addremove. Monkey patching here makes sure @@ -1414,10 +1413,8 @@ def mergeupdate(orig, repo, node, branch # (*1) deprecated, but used internally (e.g: "rebase --collapse") lfdirstate = lfutil.openlfdirstate(repo.ui, repo) - unsure, s = lfdirstate.status(matchmod.always(repo.root, - repo.getcwd()), - subrepos=[], ignored=False, - clean=True, unknown=False) + unsure, s = lfdirstate.status(matchmod.always(), subrepos=[], + ignored=False, clean=True, unknown=False) oldclean = set(s.clean) pctx = repo['.'] dctx = repo[node] diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py --- a/hgext/largefiles/reposetup.py +++ b/hgext/largefiles/reposetup.py @@ -103,7 +103,7 @@ def reposetup(ui, repo): parentworking = working and ctx1 == self['.'] if match is None: - match = matchmod.always(self.root, self.getcwd()) + match = matchmod.always() wlock = None try: diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py --- a/hgext/remotefilelog/remotefilelogserver.py +++ b/hgext/remotefilelog/remotefilelogserver.py @@ -54,7 +54,7 @@ def setupserver(ui, repo): elif cap.startswith("excludepattern="): excludepattern = cap[len("excludepattern="):].split('\0') - m = match.always(repo.root, '') + m = match.always() if includepattern or excludepattern: m = match.match(repo.root, '', None, includepattern, excludepattern) @@ -104,7 +104,7 @@ def onetimesetup(ui): oldnoflatmf = state.noflatmf try: state.shallowremote = True - state.match = match.always(repo.root, '') + state.match = match.always() state.noflatmf = other.get('noflatmanifest') == 'True' if includepattern or excludepattern: state.match = match.match(repo.root, '', None, diff --git a/hgext/remotefilelog/shallowbundle.py b/hgext/remotefilelog/shallowbundle.py --- a/hgext/remotefilelog/shallowbundle.py +++ b/hgext/remotefilelog/shallowbundle.py @@ -162,7 +162,7 @@ def makechangegroup(orig, repo, outgoing repo.shallowmatch = match.match(repo.root, '', None, includepattern, excludepattern) else: - repo.shallowmatch = match.always(repo.root, '') + repo.shallowmatch = match.always() return orig(repo, outgoing, version, source, *args, **kwargs) finally: repo.shallowmatch = original diff --git a/hgext/remotefilelog/shallowrepo.py b/hgext/remotefilelog/shallowrepo.py --- a/hgext/remotefilelog/shallowrepo.py +++ b/hgext/remotefilelog/shallowrepo.py @@ -289,7 +289,7 @@ def wraprepo(repo): repo.__class__ = shallowrepository - repo.shallowmatch = match.always(repo.root, '') + repo.shallowmatch = match.always() makeunionstores(repo) 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(None, None, match.files()) + em = matchmod.exact(match.files()) sm = matchmod.unionmatcher([self._sparsematcher, em]) match = matchmod.intersectmatchers(match, sm) return orig(self, match, subrepos, unknown, ignored, full) diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -325,9 +325,9 @@ class transplanter(object): if merge: p1 = repo.dirstate.p1() repo.setparents(p1, node) - m = match.always(repo.root, '') + m = match.always() else: - m = match.exact(repo.root, '', files) + m = match.exact(files) n = repo.commit(message, user, date, extra=extra, match=m, editor=self.getcommiteditor()) diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -1313,9 +1313,9 @@ def getbundler(version, repo, bundlecaps assert version in supportedoutgoingversions(repo) if matcher is None: - matcher = matchmod.always(repo.root, '') + matcher = matchmod.always() if oldmatcher is None: - oldmatcher = matchmod.never(repo.root, '') + oldmatcher = matchmod.never() if version == '01' and not matcher.always(): raise error.ProgrammingError('version 01 changegroups do not support ' diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -148,7 +148,7 @@ class dirstate(object): def _ignore(self): files = self._ignorefiles() if not files: - return matchmod.never(self._root, '') + return matchmod.never() pats = ['include:%s' % f for f in files] return matchmod.match(self._root, '', [], pats, warn=self._ui.warn) diff --git a/mercurial/fileset.py b/mercurial/fileset.py --- a/mercurial/fileset.py +++ b/mercurial/fileset.py @@ -538,8 +538,7 @@ class matchctx(object): def never(self): """Create a matcher to select nothing""" - repo = self.ctx.repo() - return matchmod.never(repo.root, repo.getcwd(), badfn=self._badfn) + return matchmod.never(badfn=self._badfn) def match(ctx, expr, badfn=None): """Create a matcher for a single fileset expression""" diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -565,9 +565,9 @@ def _prettyprintdifflines(context, lines def _diffsgen(context, repo, ctx, basectx, files, style, stripecount, linerange, lineidprefix): if files: - m = match.exact(repo.root, repo.getcwd(), files) + m = match.exact(files) else: - m = match.always(repo.root, repo.getcwd()) + m = match.always() diffopts = patch.diffopts(repo.ui, untrusted=True) parity = paritygen(stripecount) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1227,14 +1227,14 @@ class localrepository(object): @storecache(narrowspec.FILENAME) def _storenarrowmatch(self): if repository.NARROW_REQUIREMENT not in self.requirements: - return matchmod.always(self.root, '') + return matchmod.always() include, exclude = self.narrowpats return narrowspec.match(self.root, include=include, exclude=exclude) @storecache(narrowspec.FILENAME) def _narrowmatch(self): if repository.NARROW_REQUIREMENT not in self.requirements: - return matchmod.always(self.root, '') + return matchmod.always() narrowspec.checkworkingcopynarrowspec(self) include, exclude = self.narrowpats return narrowspec.match(self.root, include=include, exclude=exclude) @@ -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(None, None, match.files()) + em = matchmod.exact(match.files()) nm = matchmod.unionmatcher([self._narrowmatch, em]) return matchmod.intersectmatchers(match, nm) return matchmod.intersectmatchers(match, self._narrowmatch) @@ -2400,7 +2400,7 @@ class localrepository(object): raise error.Abort('%s: %s' % (f, msg)) if not match: - match = matchmod.always(self.root, '') + match = matchmod.always() if not force: vdirs = [] diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -190,14 +190,14 @@ def match(root, cwd, patterns=None, incl m = differencematcher(m, em) return m -def exact(root, cwd, files, badfn=None): +def exact(files, badfn=None): return exactmatcher(files, badfn=badfn) -def always(root, cwd, badfn=None): - return alwaysmatcher(badfn=badfn) +def always(badfn=None): + return alwaysmatcher(badfn) -def never(root, cwd, badfn=None): - return nevermatcher(badfn=badfn) +def never(badfn=None): + return nevermatcher(badfn) def badmatch(match, badfn): """Make a copy of the given matcher, replacing its bad method with the given diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py --- a/mercurial/narrowspec.py +++ b/mercurial/narrowspec.py @@ -127,7 +127,7 @@ def match(root, include=None, exclude=No # Passing empty include and empty exclude to matchmod.match() # gives a matcher that matches everything, so explicitly use # the nevermatcher. - return matchmod.never(root, '') + return matchmod.never() return matchmod.match(root, '', [], include=include or [], exclude=exclude or []) diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2073,7 +2073,7 @@ def subrepo(repo, subset, x): if len(args) != 0: pat = getstring(args[0], _("subrepo requires a pattern")) - m = matchmod.exact(repo.root, repo.root, ['.hgsubstate']) + m = matchmod.exact(['.hgsubstate']) def submatches(names): k, p, m = stringutil.stringmatcher(pat) diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -821,11 +821,11 @@ def match(ctx, pats=(), opts=None, globb def matchall(repo): '''Return a matcher that will efficiently match everything.''' - return matchmod.always(repo.root, repo.getcwd()) + return matchmod.always() def matchfiles(repo, files, badfn=None): '''Return a matcher that will efficiently match exactly these files.''' - return matchmod.exact(repo.root, repo.getcwd(), files, badfn=badfn) + return matchmod.exact(files, badfn=badfn) def parsefollowlinespattern(repo, rev, pat, msg): """Return a file name from `pat` pattern suitable for usage in followlines diff --git a/mercurial/sparse.py b/mercurial/sparse.py --- a/mercurial/sparse.py +++ b/mercurial/sparse.py @@ -277,7 +277,7 @@ def matcher(repo, revs=None, includetemp """ # If sparse isn't enabled, sparse matcher matches everything. if not enabled: - return matchmod.always(repo.root, '') + return matchmod.always() if not revs or revs == [None]: revs = [repo.changelog.rev(node) @@ -305,7 +305,7 @@ def matcher(repo, revs=None, includetemp pass if not matchers: - result = matchmod.always(repo.root, '') + result = matchmod.always() elif len(matchers) == 1: result = matchers[0] else: diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -323,7 +323,7 @@ class abstractsubrepo(object): def matchfileset(self, expr, badfn=None): """Resolve the fileset expression for this repo""" - return matchmod.never(self.wvfs.base, '', badfn=badfn) + return matchmod.never(badfn=badfn) def printfiles(self, ui, m, fm, fmt, subrepos): """handle the files command for this subrepo""" @@ -807,12 +807,11 @@ class hgsubrepo(abstractsubrepo): @annotatesubrepoerror def matchfileset(self, expr, badfn=None): - repo = self._repo if self._ctx.rev() is None: - ctx = repo[None] + ctx = self._repo[None] else: rev = self._state[1] - ctx = repo[rev] + ctx = self._repo[rev] matchers = [ctx.matchfileset(expr, badfn=badfn)] diff --git a/mercurial/tags.py b/mercurial/tags.py --- a/mercurial/tags.py +++ b/mercurial/tags.py @@ -536,7 +536,7 @@ def tag(repo, names, node, message, loca date: date tuple to use if committing''' if not local: - m = matchmod.exact(repo.root, '', ['.hgtags']) + m = matchmod.exact(['.hgtags']) if any(repo.status(match=m, unknown=True, ignored=True)): raise error.Abort(_('working copy of .hgtags is changed'), hint=_('please commit .hgtags manually')) @@ -610,7 +610,7 @@ def _tag(repo, names, node, message, loc if '.hgtags' not in repo.dirstate: repo[None].add(['.hgtags']) - m = matchmod.exact(repo.root, '', ['.hgtags']) + m = matchmod.exact(['.hgtags']) tagnode = repo.commit(message, user, date, extra=extra, match=m, editor=editor) diff --git a/tests/test-manifest.py b/tests/test-manifest.py --- a/tests/test-manifest.py +++ b/tests/test-manifest.py @@ -289,8 +289,7 @@ class basemanifesttests(object): the resulting manifest.''' m = self.parsemanifest(A_HUGE_MANIFEST) - match = matchmod.exact(b'/', b'', - [b'file1', b'file200', b'file300']) + match = matchmod.exact([b'file1', b'file200', b'file300']) m2 = m.matches(match) w = (b'file1\0%sx\n' @@ -304,9 +303,8 @@ class basemanifesttests(object): ''' m = self.parsemanifest(A_DEEPER_MANIFEST) - match = matchmod.exact(b'/', b'', - [b'a/b/c/bar.txt', b'a/b/d/qux.py', - b'readme.txt', b'nonexistent']) + match = matchmod.exact([b'a/b/c/bar.txt', b'a/b/d/qux.py', + b'readme.txt', b'nonexistent']) m2 = m.matches(match) self.assertEqual( @@ -329,7 +327,7 @@ class basemanifesttests(object): m = self.parsemanifest(A_HUGE_MANIFEST) flist = m.keys()[80:300] - match = matchmod.exact(b'/', b'', flist) + match = matchmod.exact(flist) m2 = m.matches(match) self.assertEqual(flist, m2.keys()) @@ -363,7 +361,7 @@ class basemanifesttests(object): against a directory.''' m = self.parsemanifest(A_DEEPER_MANIFEST) - match = matchmod.exact(b'/', b'', [b'a/b']) + match = matchmod.exact([b'a/b']) m2 = m.matches(match) self.assertEqual([], m2.keys()) diff --git a/tests/test-match.py b/tests/test-match.py --- a/tests/test-match.py +++ b/tests/test-match.py @@ -185,7 +185,7 @@ class IncludeMatcherTests(unittest.TestC class ExactMatcherTests(unittest.TestCase): def testVisitdir(self): - m = matchmod.exact(b'x', b'', files=[b'dir/subdir/foo.txt']) + m = matchmod.exact(files=[b'dir/subdir/foo.txt']) assert isinstance(m, matchmod.exactmatcher) self.assertTrue(m.visitdir(b'.')) self.assertTrue(m.visitdir(b'dir')) @@ -196,7 +196,7 @@ class ExactMatcherTests(unittest.TestCas self.assertFalse(m.visitdir(b'folder')) def testVisitchildrenset(self): - m = matchmod.exact(b'x', b'', files=[b'dir/subdir/foo.txt']) + m = matchmod.exact(files=[b'dir/subdir/foo.txt']) assert isinstance(m, matchmod.exactmatcher) self.assertEqual(m.visitchildrenset(b'.'), {b'dir'}) self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'}) @@ -206,11 +206,11 @@ class ExactMatcherTests(unittest.TestCas self.assertEqual(m.visitchildrenset(b'folder'), set()) def testVisitchildrensetFilesAndDirs(self): - m = matchmod.exact(b'x', b'', files=[b'rootfile.txt', - b'a/file1.txt', - b'a/b/file2.txt', - # no file in a/b/c - b'a/b/c/d/file4.txt']) + m = matchmod.exact(files=[b'rootfile.txt', + b'a/file1.txt', + b'a/b/file2.txt', + # no file in a/b/c + b'a/b/c/d/file4.txt']) assert isinstance(m, matchmod.exactmatcher) self.assertEqual(m.visitchildrenset(b'.'), {b'a', b'rootfile.txt'}) self.assertEqual(m.visitchildrenset(b'a'), {b'b', b'file1.txt'})