diff -r 21e1ece30f8c -r 36872036169b mercurial/manifest.py --- a/mercurial/manifest.py Mon Apr 06 14:36:08 2015 -0700 +++ b/mercurial/manifest.py Mon Apr 06 10:51:53 2015 -0700 @@ -581,11 +581,19 @@ return self._matches(match) - def _matches(self, match): + def _matches(self, match, alldirs=False): '''recursively generate a new manifest filtered by the match argument. - ''' + + Will visit all subdirectories if alldirs is True, otherwise it will + only visit subdirectories for which match.visitdir is True.''' ret = treemanifest(self._dir) + if not alldirs: + # substring to strip trailing slash + visit = match.visitdir(self._dir[:-1] or '.') + if not visit: + return ret + alldirs = (visit == 'all') for fn in self._files: fullp = self._subpath(fn) @@ -596,7 +604,7 @@ ret._flags[fn] = self._flags[fn] for dir, subm in self._dirs.iteritems(): - m = subm._matches(match) + m = subm._matches(match, alldirs) if not m._isempty(): ret._dirs[dir] = m