changeset 32495:2b5953a49f14

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.
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 16 May 2017 14:31:21 -0700
parents f9445b528687
children bb18728ea617
files mercurial/match.py
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Wed May 17 23:02:42 2017 -0700
+++ b/mercurial/match.py	Tue May 16 14:31:21 2017 -0700
@@ -307,6 +307,7 @@
             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 @@
             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 @@
             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