Patchwork [8,of,9] match: simplify includematcher a bit

login
register
mail settings
Submitter via Mercurial-devel
Date May 26, 2017, 11:32 p.m.
Message ID <412b06821559698f3464.1495841574@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/20947/
State Accepted
Headers show

Comments

via Mercurial-devel - May 26, 2017, 11:32 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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.

Patch

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