[PATCH 11 of 17] match: simplify includematcher a bit

Martin von Zweigbergk martinvonz at google.com
Thu May 25 14:24:52 EDT 2017


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1495521075 25200
#      Mon May 22 23:31:15 2017 -0700
# Node ID c93da2c1d425ac19ca15d423ede99d21368ed39b
# Parent  9f9099e03196c6ede46bbf9d0c367c65d97865e7
match: simplify includematcher a bit

The "include" we have in symbols is redundant and visitdir() can be
simplified a bit.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -411,25 +411,23 @@
         kindpats = normalize(include, 'glob', root, cwd, auditor, warn)
         self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)',
                                           listsubrepos, root)
-        self._anyincludepats = _anypats(kindpats)
+        self._anypats = _anypats(kindpats)
         roots, dirs = _rootsanddirs(kindpats)
         # roots are directories which are recursively included.
-        self._includeroots = set(roots)
+        self._roots = set(roots)
         # dirs are directories which are non-recursively included.
-        self._includedirs = set(dirs)
+        self._dirs = set(dirs)
         self.matchfn = im
 
     def visitdir(self, dir):
-        if not self._anyincludepats and dir in self._includeroots:
+        if not self._anypats and dir in self._roots:
             # 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 True
+        return ('.' in self._roots or
+                dir in self._roots or
+                dir in self._dirs or
+                any(parentdir in self._roots
+                    for parentdir in util.finddirs(dir)))
 
     def anypats(self):
         return True


More information about the Mercurial-devel mailing list