Show More
@@ -476,7 +476,7 b' def overridestatus(' | |||
|
476 | 476 | |
|
477 | 477 | working = ctx2.rev() is None |
|
478 | 478 | parentworking = working and ctx1 == self['.'] |
|
479 |
match = match or matchmod.always( |
|
|
479 | match = match or matchmod.always() | |
|
480 | 480 | |
|
481 | 481 | # Maybe we can use this opportunity to update Watchman's state. |
|
482 | 482 | # Mercurial uses workingcommitctx and/or memctx to represent the part of |
@@ -297,7 +297,7 b' def _dosign(ui, repo, *revs, **opts):' | |||
|
297 | 297 | return |
|
298 | 298 | |
|
299 | 299 | if not opts["force"]: |
|
300 |
msigs = match.exact( |
|
|
300 | msigs = match.exact(['.hgsigs']) | |
|
301 | 301 | if any(repo.status(match=msigs, unknown=True, ignored=True)): |
|
302 | 302 | raise error.Abort(_("working copy of .hgsigs is changed "), |
|
303 | 303 | hint=_("please commit .hgsigs manually")) |
@@ -168,7 +168,7 b' def openlfdirstate(ui, repo, create=True' | |||
|
168 | 168 | |
|
169 | 169 | def lfdirstatestatus(lfdirstate, repo): |
|
170 | 170 | pctx = repo['.'] |
|
171 |
match = matchmod.always( |
|
|
171 | match = matchmod.always() | |
|
172 | 172 | unsure, s = lfdirstate.status(match, subrepos=[], ignored=False, |
|
173 | 173 | clean=False, unknown=False) |
|
174 | 174 | modified, clean = s.modified, s.clean |
@@ -552,7 +552,7 b' def updatestandinsbymatch(repo, match):' | |||
|
552 | 552 | # otherwise to update all standins if the largefiles are |
|
553 | 553 | # large. |
|
554 | 554 | lfdirstate = openlfdirstate(ui, repo) |
|
555 |
dirtymatch = matchmod.always( |
|
|
555 | dirtymatch = matchmod.always() | |
|
556 | 556 | unsure, s = lfdirstate.status(dirtymatch, subrepos=[], ignored=False, |
|
557 | 557 | clean=False, unknown=False) |
|
558 | 558 | modifiedfiles = unsure + s.modified + s.added + s.removed |
@@ -1222,9 +1222,8 b' def scmutiladdremove(orig, repo, matcher' | |||
|
1222 | 1222 | return orig(repo, matcher, prefix, uipathfn, opts) |
|
1223 | 1223 | # Get the list of missing largefiles so we can remove them |
|
1224 | 1224 | lfdirstate = lfutil.openlfdirstate(repo.ui, repo) |
|
1225 |
unsure, s = lfdirstate.status(matchmod.always( |
|
|
1226 |
|
|
|
1227 | unknown=False) | |
|
1225 | unsure, s = lfdirstate.status(matchmod.always(), subrepos=[], | |
|
1226 | ignored=False, clean=False, unknown=False) | |
|
1228 | 1227 | |
|
1229 | 1228 | # Call into the normal remove code, but the removing of the standin, we want |
|
1230 | 1229 | # to have handled by original addremove. Monkey patching here makes sure |
@@ -1414,10 +1413,8 b' def mergeupdate(orig, repo, node, branch' | |||
|
1414 | 1413 | # (*1) deprecated, but used internally (e.g: "rebase --collapse") |
|
1415 | 1414 | |
|
1416 | 1415 | lfdirstate = lfutil.openlfdirstate(repo.ui, repo) |
|
1417 |
unsure, s = lfdirstate.status(matchmod.always( |
|
|
1418 | repo.getcwd()), | |
|
1419 | subrepos=[], ignored=False, | |
|
1420 | clean=True, unknown=False) | |
|
1416 | unsure, s = lfdirstate.status(matchmod.always(), subrepos=[], | |
|
1417 | ignored=False, clean=True, unknown=False) | |
|
1421 | 1418 | oldclean = set(s.clean) |
|
1422 | 1419 | pctx = repo['.'] |
|
1423 | 1420 | dctx = repo[node] |
@@ -103,7 +103,7 b' def reposetup(ui, repo):' | |||
|
103 | 103 | parentworking = working and ctx1 == self['.'] |
|
104 | 104 | |
|
105 | 105 | if match is None: |
|
106 |
match = matchmod.always( |
|
|
106 | match = matchmod.always() | |
|
107 | 107 | |
|
108 | 108 | wlock = None |
|
109 | 109 | try: |
@@ -54,7 +54,7 b' def setupserver(ui, repo):' | |||
|
54 | 54 | elif cap.startswith("excludepattern="): |
|
55 | 55 | excludepattern = cap[len("excludepattern="):].split('\0') |
|
56 | 56 | |
|
57 |
m = match.always( |
|
|
57 | m = match.always() | |
|
58 | 58 | if includepattern or excludepattern: |
|
59 | 59 | m = match.match(repo.root, '', None, |
|
60 | 60 | includepattern, excludepattern) |
@@ -104,7 +104,7 b' def onetimesetup(ui):' | |||
|
104 | 104 | oldnoflatmf = state.noflatmf |
|
105 | 105 | try: |
|
106 | 106 | state.shallowremote = True |
|
107 |
state.match = match.always( |
|
|
107 | state.match = match.always() | |
|
108 | 108 | state.noflatmf = other.get('noflatmanifest') == 'True' |
|
109 | 109 | if includepattern or excludepattern: |
|
110 | 110 | state.match = match.match(repo.root, '', None, |
@@ -162,7 +162,7 b' def makechangegroup(orig, repo, outgoing' | |||
|
162 | 162 | repo.shallowmatch = match.match(repo.root, '', None, |
|
163 | 163 | includepattern, excludepattern) |
|
164 | 164 | else: |
|
165 |
repo.shallowmatch = match.always( |
|
|
165 | repo.shallowmatch = match.always() | |
|
166 | 166 | return orig(repo, outgoing, version, source, *args, **kwargs) |
|
167 | 167 | finally: |
|
168 | 168 | repo.shallowmatch = original |
@@ -289,7 +289,7 b' def wraprepo(repo):' | |||
|
289 | 289 | |
|
290 | 290 | repo.__class__ = shallowrepository |
|
291 | 291 | |
|
292 |
repo.shallowmatch = match.always( |
|
|
292 | repo.shallowmatch = match.always() | |
|
293 | 293 | |
|
294 | 294 | makeunionstores(repo) |
|
295 | 295 |
@@ -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( |
|
|
202 | em = matchmod.exact(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) |
@@ -325,9 +325,9 b' class transplanter(object):' | |||
|
325 | 325 | if merge: |
|
326 | 326 | p1 = repo.dirstate.p1() |
|
327 | 327 | repo.setparents(p1, node) |
|
328 |
m = match.always( |
|
|
328 | m = match.always() | |
|
329 | 329 | else: |
|
330 |
m = match.exact( |
|
|
330 | m = match.exact(files) | |
|
331 | 331 | |
|
332 | 332 | n = repo.commit(message, user, date, extra=extra, match=m, |
|
333 | 333 | editor=self.getcommiteditor()) |
@@ -1313,9 +1313,9 b' def getbundler(version, repo, bundlecaps' | |||
|
1313 | 1313 | assert version in supportedoutgoingversions(repo) |
|
1314 | 1314 | |
|
1315 | 1315 | if matcher is None: |
|
1316 |
matcher = matchmod.always( |
|
|
1316 | matcher = matchmod.always() | |
|
1317 | 1317 | if oldmatcher is None: |
|
1318 |
oldmatcher = matchmod.never( |
|
|
1318 | oldmatcher = matchmod.never() | |
|
1319 | 1319 | |
|
1320 | 1320 | if version == '01' and not matcher.always(): |
|
1321 | 1321 | raise error.ProgrammingError('version 01 changegroups do not support ' |
@@ -148,7 +148,7 b' class dirstate(object):' | |||
|
148 | 148 | def _ignore(self): |
|
149 | 149 | files = self._ignorefiles() |
|
150 | 150 | if not files: |
|
151 |
return matchmod.never( |
|
|
151 | return matchmod.never() | |
|
152 | 152 | |
|
153 | 153 | pats = ['include:%s' % f for f in files] |
|
154 | 154 | return matchmod.match(self._root, '', [], pats, warn=self._ui.warn) |
@@ -538,8 +538,7 b' class matchctx(object):' | |||
|
538 | 538 | |
|
539 | 539 | def never(self): |
|
540 | 540 | """Create a matcher to select nothing""" |
|
541 | repo = self.ctx.repo() | |
|
542 | return matchmod.never(repo.root, repo.getcwd(), badfn=self._badfn) | |
|
541 | return matchmod.never(badfn=self._badfn) | |
|
543 | 542 | |
|
544 | 543 | def match(ctx, expr, badfn=None): |
|
545 | 544 | """Create a matcher for a single fileset expression""" |
@@ -565,9 +565,9 b' def _prettyprintdifflines(context, lines' | |||
|
565 | 565 | def _diffsgen(context, repo, ctx, basectx, files, style, stripecount, |
|
566 | 566 | linerange, lineidprefix): |
|
567 | 567 | if files: |
|
568 |
m = match.exact( |
|
|
568 | m = match.exact(files) | |
|
569 | 569 | else: |
|
570 |
m = match.always( |
|
|
570 | m = match.always() | |
|
571 | 571 | |
|
572 | 572 | diffopts = patch.diffopts(repo.ui, untrusted=True) |
|
573 | 573 | parity = paritygen(stripecount) |
@@ -1227,14 +1227,14 b' class localrepository(object):' | |||
|
1227 | 1227 | @storecache(narrowspec.FILENAME) |
|
1228 | 1228 | def _storenarrowmatch(self): |
|
1229 | 1229 | if repository.NARROW_REQUIREMENT not in self.requirements: |
|
1230 |
return matchmod.always( |
|
|
1230 | return matchmod.always() | |
|
1231 | 1231 | include, exclude = self.narrowpats |
|
1232 | 1232 | return narrowspec.match(self.root, include=include, exclude=exclude) |
|
1233 | 1233 | |
|
1234 | 1234 | @storecache(narrowspec.FILENAME) |
|
1235 | 1235 | def _narrowmatch(self): |
|
1236 | 1236 | if repository.NARROW_REQUIREMENT not in self.requirements: |
|
1237 |
return matchmod.always( |
|
|
1237 | return matchmod.always() | |
|
1238 | 1238 | narrowspec.checkworkingcopynarrowspec(self) |
|
1239 | 1239 | include, exclude = self.narrowpats |
|
1240 | 1240 | return narrowspec.match(self.root, include=include, exclude=exclude) |
@@ -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( |
|
|
1255 | em = matchmod.exact(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) |
@@ -2400,7 +2400,7 b' class localrepository(object):' | |||
|
2400 | 2400 | raise error.Abort('%s: %s' % (f, msg)) |
|
2401 | 2401 | |
|
2402 | 2402 | if not match: |
|
2403 |
match = matchmod.always( |
|
|
2403 | match = matchmod.always() | |
|
2404 | 2404 | |
|
2405 | 2405 | if not force: |
|
2406 | 2406 | vdirs = [] |
@@ -190,14 +190,14 b' def match(root, cwd, patterns=None, incl' | |||
|
190 | 190 | m = differencematcher(m, em) |
|
191 | 191 | return m |
|
192 | 192 | |
|
193 |
def exact( |
|
|
193 | def exact(files, badfn=None): | |
|
194 | 194 | return exactmatcher(files, badfn=badfn) |
|
195 | 195 | |
|
196 |
def always( |
|
|
197 |
return alwaysmatcher(badfn |
|
|
196 | def always(badfn=None): | |
|
197 | return alwaysmatcher(badfn) | |
|
198 | 198 | |
|
199 |
def never( |
|
|
200 |
return nevermatcher(badfn |
|
|
199 | def never(badfn=None): | |
|
200 | return nevermatcher(badfn) | |
|
201 | 201 | |
|
202 | 202 | def badmatch(match, badfn): |
|
203 | 203 | """Make a copy of the given matcher, replacing its bad method with the given |
@@ -127,7 +127,7 b' def match(root, include=None, exclude=No' | |||
|
127 | 127 | # Passing empty include and empty exclude to matchmod.match() |
|
128 | 128 | # gives a matcher that matches everything, so explicitly use |
|
129 | 129 | # the nevermatcher. |
|
130 |
return matchmod.never( |
|
|
130 | return matchmod.never() | |
|
131 | 131 | return matchmod.match(root, '', [], include=include or [], |
|
132 | 132 | exclude=exclude or []) |
|
133 | 133 |
@@ -2073,7 +2073,7 b' def subrepo(repo, subset, x):' | |||
|
2073 | 2073 | if len(args) != 0: |
|
2074 | 2074 | pat = getstring(args[0], _("subrepo requires a pattern")) |
|
2075 | 2075 | |
|
2076 |
m = matchmod.exact( |
|
|
2076 | m = matchmod.exact(['.hgsubstate']) | |
|
2077 | 2077 | |
|
2078 | 2078 | def submatches(names): |
|
2079 | 2079 | k, p, m = stringutil.stringmatcher(pat) |
@@ -821,11 +821,11 b' def match(ctx, pats=(), opts=None, globb' | |||
|
821 | 821 | |
|
822 | 822 | def matchall(repo): |
|
823 | 823 | '''Return a matcher that will efficiently match everything.''' |
|
824 |
return matchmod.always( |
|
|
824 | return matchmod.always() | |
|
825 | 825 | |
|
826 | 826 | def matchfiles(repo, files, badfn=None): |
|
827 | 827 | '''Return a matcher that will efficiently match exactly these files.''' |
|
828 |
return matchmod.exact( |
|
|
828 | return matchmod.exact(files, badfn=badfn) | |
|
829 | 829 | |
|
830 | 830 | def parsefollowlinespattern(repo, rev, pat, msg): |
|
831 | 831 | """Return a file name from `pat` pattern suitable for usage in followlines |
@@ -277,7 +277,7 b' def matcher(repo, revs=None, includetemp' | |||
|
277 | 277 | """ |
|
278 | 278 | # If sparse isn't enabled, sparse matcher matches everything. |
|
279 | 279 | if not enabled: |
|
280 |
return matchmod.always( |
|
|
280 | return matchmod.always() | |
|
281 | 281 | |
|
282 | 282 | if not revs or revs == [None]: |
|
283 | 283 | revs = [repo.changelog.rev(node) |
@@ -305,7 +305,7 b' def matcher(repo, revs=None, includetemp' | |||
|
305 | 305 | pass |
|
306 | 306 | |
|
307 | 307 | if not matchers: |
|
308 |
result = matchmod.always( |
|
|
308 | result = matchmod.always() | |
|
309 | 309 | elif len(matchers) == 1: |
|
310 | 310 | result = matchers[0] |
|
311 | 311 | else: |
@@ -323,7 +323,7 b' class abstractsubrepo(object):' | |||
|
323 | 323 | |
|
324 | 324 | def matchfileset(self, expr, badfn=None): |
|
325 | 325 | """Resolve the fileset expression for this repo""" |
|
326 |
return matchmod.never( |
|
|
326 | return matchmod.never(badfn=badfn) | |
|
327 | 327 | |
|
328 | 328 | def printfiles(self, ui, m, fm, fmt, subrepos): |
|
329 | 329 | """handle the files command for this subrepo""" |
@@ -807,12 +807,11 b' class hgsubrepo(abstractsubrepo):' | |||
|
807 | 807 | |
|
808 | 808 | @annotatesubrepoerror |
|
809 | 809 | def matchfileset(self, expr, badfn=None): |
|
810 | repo = self._repo | |
|
811 | 810 | if self._ctx.rev() is None: |
|
812 | ctx = repo[None] | |
|
811 | ctx = self._repo[None] | |
|
813 | 812 | else: |
|
814 | 813 | rev = self._state[1] |
|
815 | ctx = repo[rev] | |
|
814 | ctx = self._repo[rev] | |
|
816 | 815 | |
|
817 | 816 | matchers = [ctx.matchfileset(expr, badfn=badfn)] |
|
818 | 817 |
@@ -536,7 +536,7 b' def tag(repo, names, node, message, loca' | |||
|
536 | 536 | date: date tuple to use if committing''' |
|
537 | 537 | |
|
538 | 538 | if not local: |
|
539 |
m = matchmod.exact( |
|
|
539 | m = matchmod.exact(['.hgtags']) | |
|
540 | 540 | if any(repo.status(match=m, unknown=True, ignored=True)): |
|
541 | 541 | raise error.Abort(_('working copy of .hgtags is changed'), |
|
542 | 542 | hint=_('please commit .hgtags manually')) |
@@ -610,7 +610,7 b' def _tag(repo, names, node, message, loc' | |||
|
610 | 610 | if '.hgtags' not in repo.dirstate: |
|
611 | 611 | repo[None].add(['.hgtags']) |
|
612 | 612 | |
|
613 |
m = matchmod.exact( |
|
|
613 | m = matchmod.exact(['.hgtags']) | |
|
614 | 614 | tagnode = repo.commit(message, user, date, extra=extra, match=m, |
|
615 | 615 | editor=editor) |
|
616 | 616 |
@@ -289,8 +289,7 b' class basemanifesttests(object):' | |||
|
289 | 289 | the resulting manifest.''' |
|
290 | 290 | m = self.parsemanifest(A_HUGE_MANIFEST) |
|
291 | 291 | |
|
292 |
match = matchmod.exact(b' |
|
|
293 | [b'file1', b'file200', b'file300']) | |
|
292 | match = matchmod.exact([b'file1', b'file200', b'file300']) | |
|
294 | 293 | m2 = m.matches(match) |
|
295 | 294 | |
|
296 | 295 | w = (b'file1\0%sx\n' |
@@ -304,8 +303,7 b' class basemanifesttests(object):' | |||
|
304 | 303 | ''' |
|
305 | 304 | m = self.parsemanifest(A_DEEPER_MANIFEST) |
|
306 | 305 | |
|
307 | match = matchmod.exact(b'/', b'', | |
|
308 | [b'a/b/c/bar.txt', b'a/b/d/qux.py', | |
|
306 | match = matchmod.exact([b'a/b/c/bar.txt', b'a/b/d/qux.py', | |
|
309 | 307 | b'readme.txt', b'nonexistent']) |
|
310 | 308 | m2 = m.matches(match) |
|
311 | 309 | |
@@ -329,7 +327,7 b' class basemanifesttests(object):' | |||
|
329 | 327 | m = self.parsemanifest(A_HUGE_MANIFEST) |
|
330 | 328 | |
|
331 | 329 | flist = m.keys()[80:300] |
|
332 |
match = matchmod.exact( |
|
|
330 | match = matchmod.exact(flist) | |
|
333 | 331 | m2 = m.matches(match) |
|
334 | 332 | |
|
335 | 333 | self.assertEqual(flist, m2.keys()) |
@@ -363,7 +361,7 b' class basemanifesttests(object):' | |||
|
363 | 361 | against a directory.''' |
|
364 | 362 | m = self.parsemanifest(A_DEEPER_MANIFEST) |
|
365 | 363 | |
|
366 |
match = matchmod.exact( |
|
|
364 | match = matchmod.exact([b'a/b']) | |
|
367 | 365 | m2 = m.matches(match) |
|
368 | 366 | |
|
369 | 367 | self.assertEqual([], m2.keys()) |
@@ -185,7 +185,7 b' class IncludeMatcherTests(unittest.TestC' | |||
|
185 | 185 | class ExactMatcherTests(unittest.TestCase): |
|
186 | 186 | |
|
187 | 187 | def testVisitdir(self): |
|
188 |
m = matchmod.exact( |
|
|
188 | m = matchmod.exact(files=[b'dir/subdir/foo.txt']) | |
|
189 | 189 | assert isinstance(m, matchmod.exactmatcher) |
|
190 | 190 | self.assertTrue(m.visitdir(b'.')) |
|
191 | 191 | self.assertTrue(m.visitdir(b'dir')) |
@@ -196,7 +196,7 b' class ExactMatcherTests(unittest.TestCas' | |||
|
196 | 196 | self.assertFalse(m.visitdir(b'folder')) |
|
197 | 197 | |
|
198 | 198 | def testVisitchildrenset(self): |
|
199 |
m = matchmod.exact( |
|
|
199 | m = matchmod.exact(files=[b'dir/subdir/foo.txt']) | |
|
200 | 200 | assert isinstance(m, matchmod.exactmatcher) |
|
201 | 201 | self.assertEqual(m.visitchildrenset(b'.'), {b'dir'}) |
|
202 | 202 | self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'}) |
@@ -206,7 +206,7 b' class ExactMatcherTests(unittest.TestCas' | |||
|
206 | 206 | self.assertEqual(m.visitchildrenset(b'folder'), set()) |
|
207 | 207 | |
|
208 | 208 | def testVisitchildrensetFilesAndDirs(self): |
|
209 |
m = matchmod.exact( |
|
|
209 | m = matchmod.exact(files=[b'rootfile.txt', | |
|
210 | 210 |
|
|
211 | 211 |
|
|
212 | 212 |
|
General Comments 0
You need to be logged in to leave comments.
Login now