changeset 32588:b3083be7dcb9

match: drop support for empty pattern list in patternmatcher Since the caller now deals with empty pattern lists, we can drop that support in the patternmatcher. It now gets the more logical behavior of matching nothing when no patterns are given (although there is no in-core caller that will pass no patterns).
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 19 May 2017 11:58:16 -0700
parents f44ea253ffe2
children 5f08eca8f8d3
files mercurial/match.py
diffstat 1 files changed, 13 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Sat May 20 23:49:14 2017 -0700
+++ b/mercurial/match.py	Fri May 19 11:58:16 2017 -0700
@@ -341,36 +341,21 @@
     def __init__(self, root, cwd, normalize, patterns, default='glob',
                  auditor=None, ctx=None, listsubrepos=False, warn=None,
                  badfn=None):
-        super(patternmatcher, self).__init__(root, cwd, badfn,
-                                             relativeuipath=bool(patterns))
-
-        self._anypats = False
-        self._always = False
-        self.patternspat = None
+        super(patternmatcher, self).__init__(root, cwd, badfn)
 
-        matchfns = []
-        if patterns:
-            kindpats = normalize(patterns, default, root, cwd, auditor, warn)
-            if not _kindpatsalwaysmatch(kindpats):
-                self._files = _explicitfiles(kindpats)
-                self._anypats = self._anypats or _anypats(kindpats)
-                self.patternspat, pm = _buildmatch(ctx, kindpats, '$',
-                                                   listsubrepos, root)
-                matchfns.append(pm)
-
-        if not matchfns:
-            m = util.always
+        kindpats = normalize(patterns, default, root, cwd, auditor, warn)
+        if not _kindpatsalwaysmatch(kindpats):
+            self._files = _explicitfiles(kindpats)
+            self._anypats = _anypats(kindpats)
+            self.patternspat, pm = _buildmatch(ctx, kindpats, '$',
+                                               listsubrepos, root)
+            self._always = False
+            self.matchfn = pm
+        else:
+            self._anypats = False
+            self.patternspat = None
             self._always = True
-        elif len(matchfns) == 1:
-            m = matchfns[0]
-        else:
-            def m(f):
-                for matchfn in matchfns:
-                    if not matchfn(f):
-                        return False
-                return True
-
-        self.matchfn = m
+            self.matchfn = lambda f: True
 
     @propertycache
     def _dirs(self):