Show More
@@ -656,18 +656,10 class treemanifest(object): | |||||
656 | if not self.hasdir(fn): |
|
656 | if not self.hasdir(fn): | |
657 | match.bad(fn, None) |
|
657 | match.bad(fn, None) | |
658 |
|
658 | |||
659 |
def _walk(self, match |
|
659 | def _walk(self, match): | |
660 | '''Recursively generates matching file names for walk(). |
|
660 | '''Recursively generates matching file names for walk().''' | |
661 |
|
661 | if not match.visitdir(self._dir[:-1] or '.'): | ||
662 | Will visit all subdirectories if alldirs is True, otherwise it will |
|
662 | return | |
663 | only visit subdirectories for which match.visitdir is True.''' |
|
|||
664 |
|
||||
665 | if not alldirs: |
|
|||
666 | # substring to strip trailing slash |
|
|||
667 | visit = match.visitdir(self._dir[:-1] or '.') |
|
|||
668 | if not visit: |
|
|||
669 | return |
|
|||
670 | alldirs = (visit == 'all') |
|
|||
671 |
|
663 | |||
672 | # yield this dir's files and walk its submanifests |
|
664 | # yield this dir's files and walk its submanifests | |
673 | for p in sorted(self._dirs.keys() + self._files.keys()): |
|
665 | for p in sorted(self._dirs.keys() + self._files.keys()): | |
@@ -676,7 +668,7 class treemanifest(object): | |||||
676 | if match(fullp): |
|
668 | if match(fullp): | |
677 | yield fullp |
|
669 | yield fullp | |
678 | else: |
|
670 | else: | |
679 |
for f in self._dirs[p]._walk(match |
|
671 | for f in self._dirs[p]._walk(match): | |
680 | yield f |
|
672 | yield f | |
681 |
|
673 | |||
682 | def matches(self, match): |
|
674 | def matches(self, match): | |
@@ -686,19 +678,13 class treemanifest(object): | |||||
686 |
|
678 | |||
687 | return self._matches(match) |
|
679 | return self._matches(match) | |
688 |
|
680 | |||
689 |
def _matches(self, match |
|
681 | def _matches(self, match): | |
690 | '''recursively generate a new manifest filtered by the match argument. |
|
682 | '''recursively generate a new manifest filtered by the match argument. | |
691 |
|
683 | ''' | ||
692 | Will visit all subdirectories if alldirs is True, otherwise it will |
|
|||
693 | only visit subdirectories for which match.visitdir is True.''' |
|
|||
694 |
|
||||
695 | ret = treemanifest(self._dir) |
|
684 | ret = treemanifest(self._dir) | |
696 | if not alldirs: |
|
685 | ||
697 | # substring to strip trailing slash |
|
686 | if not match.visitdir(self._dir[:-1] or '.'): | |
698 | visit = match.visitdir(self._dir[:-1] or '.') |
|
687 | return ret | |
699 | if not visit: |
|
|||
700 | return ret |
|
|||
701 | alldirs = (visit == 'all') |
|
|||
702 |
|
688 | |||
703 | for fn in self._files: |
|
689 | for fn in self._files: | |
704 | fullp = self._subpath(fn) |
|
690 | fullp = self._subpath(fn) | |
@@ -709,7 +695,7 class treemanifest(object): | |||||
709 | ret._flags[fn] = self._flags[fn] |
|
695 | ret._flags[fn] = self._flags[fn] | |
710 |
|
696 | |||
711 | for dir, subm in self._dirs.iteritems(): |
|
697 | for dir, subm in self._dirs.iteritems(): | |
712 |
m = subm._matches(match |
|
698 | m = subm._matches(match) | |
713 | if not m._isempty(): |
|
699 | if not m._isempty(): | |
714 | ret._dirs[dir] = m |
|
700 | ret._dirs[dir] = m | |
715 |
|
701 |
@@ -174,14 +174,10 class match(object): | |||||
174 | return set(util.dirs(self._fmap)) | set(['.']) |
|
174 | return set(util.dirs(self._fmap)) | set(['.']) | |
175 |
|
175 | |||
176 | def visitdir(self, dir): |
|
176 | def visitdir(self, dir): | |
177 | '''Helps while traversing a directory tree. Returns the string 'all' if |
|
177 | return (not self._fmap or '.' in self._fmap or | |
178 | the given directory and all subdirectories should be visited. Otherwise |
|
178 | dir in self._fmap or dir in self._dirs or | |
179 | returns True or False indicating whether the given directory should be |
|
179 | any(parentdir in self._fmap | |
180 | visited. If 'all' is returned, calling this method on a subdirectory |
|
180 | for parentdir in util.finddirs(dir))) | |
181 | gives an undefined result.''' |
|
|||
182 | if not self._fmap or self.exact(dir): |
|
|||
183 | return 'all' |
|
|||
184 | return dir in self._dirs |
|
|||
185 |
|
181 | |||
186 | def exact(self, f): |
|
182 | def exact(self, f): | |
187 | '''Returns True if f is in .files().''' |
|
183 | '''Returns True if f is in .files().''' |
General Comments 0
You need to be logged in to leave comments.
Login now