##// END OF EJS Templates
match: make subdirmatcher extend basematcher...
Martin von Zweigbergk -
r32456:f9445b52 default
parent child Browse files
Show More
@@ -409,7 +409,7 b' class matcher(basematcher):'
409 409 (self._files, self.patternspat, self.includepat,
410 410 self.excludepat))
411 411
412 class subdirmatcher(matcher):
412 class subdirmatcher(basematcher):
413 413 """Adapt a matcher to work on a subdirectory only.
414 414
415 415 The paths are remapped to remove/insert the path as needed:
@@ -440,11 +440,10 b' class subdirmatcher(matcher):'
440 440 """
441 441
442 442 def __init__(self, path, matcher):
443 self._root = matcher._root
444 self._cwd = matcher._cwd
443 super(subdirmatcher, self).__init__(matcher._root, matcher._cwd)
445 444 self._path = path
446 445 self._matcher = matcher
447 self._always = matcher._always
446 self._always = matcher.always()
448 447
449 448 self._files = [f[len(path) + 1:] for f in matcher._files
450 449 if f.startswith(path + "/")]
@@ -454,7 +453,6 b' class subdirmatcher(matcher):'
454 453 if matcher.prefix():
455 454 self._always = any(f == path for f in matcher._files)
456 455
457 self._anypats = matcher._anypats
458 456 # Some information is lost in the superclass's constructor, so we
459 457 # can not accurately create the matching function for the subdirectory
460 458 # from the inputs. Instead, we override matchfn() and visitdir() to
@@ -480,6 +478,12 b' class subdirmatcher(matcher):'
480 478 dir = self._path + "/" + dir
481 479 return self._matcher.visitdir(dir)
482 480
481 def always(self):
482 return self._always
483
484 def anypats(self):
485 return self._matcher.anypats()
486
483 487 def patkind(pattern, default=None):
484 488 '''If pattern is 'kind:pat' with a known kind, return kind.'''
485 489 return _patsplit(pattern, default)[0]
General Comments 0
You need to be logged in to leave comments. Login now