[PATCH 8 of 9] match: simplify includematcher a bit

Martin von Zweigbergk martinvonz at google.com
Fri May 26 19:32:54 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 412b06821559698f34640bdb3713255c3c6a8205
# Parent  c93ec56ea18eeb28745557e4e1332925fc0d168a
match: simplify includematcher a bit

The "include" we have in symbols is redundant and the double negative
in visitdir() can be removed.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -410,25 +410,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