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