##// END OF EJS Templates
match: write forceincludematcher using unionmatcher...
Martin von Zweigbergk -
r33447:6f4e5e59 default
parent child Browse files
Show More
@@ -647,20 +647,6 class subdirmatcher(basematcher):
647 return ('<subdirmatcher path=%r, matcher=%r>' %
647 return ('<subdirmatcher path=%r, matcher=%r>' %
648 (self._path, self._matcher))
648 (self._path, self._matcher))
649
649
650 class forceincludematcher(basematcher):
651 """A matcher that returns true for any of the forced includes before testing
652 against the actual matcher."""
653 def __init__(self, matcher, includes):
654 self._matcher = matcher
655 self._includes = includes
656
657 def matchfn(self, f):
658 return f in self._includes or self._matcher(f)
659
660 def __repr__(self):
661 return ('<forceincludematcher matcher=%r, includes=%r>' %
662 (self._matcher, sorted(self._includes)))
663
664 class unionmatcher(basematcher):
650 class unionmatcher(basematcher):
665 """A matcher that is the union of several matchers."""
651 """A matcher that is the union of several matchers."""
666 def __init__(self, matchers):
652 def __init__(self, matchers):
@@ -242,6 +242,13 def prunetemporaryincludes(repo):
242 'sparse checkout\n')
242 'sparse checkout\n')
243 repo.ui.status(msg % len(tempincludes))
243 repo.ui.status(msg % len(tempincludes))
244
244
245 def forceincludematcher(matcher, includes):
246 """Returns a matcher that returns true for any of the forced includes
247 before testing against the actual matcher."""
248 kindpats = [('path', include, '') for include in includes]
249 includematcher = matchmod.includematcher('', '', kindpats)
250 return matchmod.unionmatcher([includematcher, matcher])
251
245 def matcher(repo, revs=None, includetemp=True):
252 def matcher(repo, revs=None, includetemp=True):
246 """Obtain a matcher for sparse working directories for the given revs.
253 """Obtain a matcher for sparse working directories for the given revs.
247
254
@@ -289,7 +296,7 def matcher(repo, revs=None, includetemp
289 include=includes, exclude=excludes,
296 include=includes, exclude=excludes,
290 default='relpath')
297 default='relpath')
291 if subdirs:
298 if subdirs:
292 matcher = matchmod.forceincludematcher(matcher, subdirs)
299 matcher = forceincludematcher(matcher, subdirs)
293 matchers.append(matcher)
300 matchers.append(matcher)
294 except IOError:
301 except IOError:
295 pass
302 pass
@@ -303,7 +310,7 def matcher(repo, revs=None, includetemp
303
310
304 if includetemp:
311 if includetemp:
305 tempincludes = readtemporaryincludes(repo)
312 tempincludes = readtemporaryincludes(repo)
306 result = matchmod.forceincludematcher(result, tempincludes)
313 result = forceincludematcher(result, tempincludes)
307
314
308 repo._sparsematchercache[key] = result
315 repo._sparsematchercache[key] = result
309
316
General Comments 0
You need to be logged in to leave comments. Login now