# HG changeset patch # User Martin von Zweigbergk # Date 2017-05-16 21:31:21 # Node ID 2b5953a49f1407f825d65b45986d213cb5c79203 # Parent f9445b52868731c1c947b432e438c1cc2402d809 match: fix visitdir for roots of includes I'm hoping to rewrite the matcher so excludes are handled by composition of one matcher with another matcher where the second matcher has only includes. For that to work, we need to make visitdir() to return 'all' for directory 'foo' for a '-I foo' matcher. diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -307,6 +307,7 @@ class matcher(basematcher): exclude = [] self._anypats = bool(include or exclude) + self._anyincludepats = False self._always = False self._pathrestricted = bool(include or exclude or patterns) self.patternspat = None @@ -324,6 +325,7 @@ class matcher(basematcher): kindpats = normalize(include, 'glob', root, cwd, auditor, warn) self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)', listsubrepos, root) + self._anyincludepats = _anypats(kindpats) roots, dirs = _rootsanddirs(kindpats) self._includeroots.update(roots) self._includedirs.update(dirs) @@ -381,13 +383,18 @@ class matcher(basematcher): return 'all' if dir in self._excluderoots: return False - if ((self._includeroots or self._includedirs) and - '.' not in self._includeroots and - dir not in self._includeroots and - dir not in self._includedirs and - not any(parent in self._includeroots - for parent in util.finddirs(dir))): - return False + if self._includeroots or self._includedirs: + if (not self._anyincludepats and + not self._excluderoots and + dir in self._includeroots): + # The condition above is essentially self.prefix() for includes + return 'all' + if ('.' not in self._includeroots and + dir not in self._includeroots and + dir not in self._includedirs and + not any(parent in self._includeroots + for parent in util.finddirs(dir))): + return False return (not self._fileset or '.' in self._fileset or dir in self._fileset or