diff mercurial/match.py @ 32605:e6ff007e107e

match: introduce nevermatcher for when no ignore files are present 952017471f93 introduced a deterministic `__repr__` for ignores. However, it didn't account for when ignore was `util.never`. This broke fsmonitor's ignore change detection -- with an empty hgignore, it would kick in all the time. Introduce `nevermatcher` and switch to it. This neatly parallels `alwaysmatcher`.
author Siddharth Agarwal <sid0@fb.com>
date Thu, 01 Jun 2017 00:40:52 -0700
parents 3fdcc34c0aba
children 783394c0c978
line wrap: on
line diff
--- a/mercurial/match.py	Wed May 31 11:41:54 2017 -0700
+++ b/mercurial/match.py	Thu Jun 01 00:40:52 2017 -0700
@@ -175,6 +175,9 @@
 def always(root, cwd):
     return alwaysmatcher(root, cwd)
 
+def never(root, cwd):
+    return nevermatcher(root, cwd)
+
 def badmatch(match, badfn):
     """Make a copy of the given matcher, replacing its bad method with the given
     one.
@@ -339,6 +342,25 @@
     def __repr__(self):
         return '<alwaysmatcher>'
 
+class nevermatcher(basematcher):
+    '''Matches nothing.'''
+
+    def __init__(self, root, cwd, badfn=None, relativeuipath=False):
+        super(nevermatcher, self).__init__(root, cwd, badfn,
+                                           relativeuipath=relativeuipath)
+
+    def always(self):
+        return False
+
+    def matchfn(self, f):
+        return False
+
+    def visitdir(self, dir):
+        return False
+
+    def __repr__(self):
+        return '<nevermatcher>'
+
 class patternmatcher(basematcher):
 
     def __init__(self, root, cwd, kindpats, ctx=None, listsubrepos=False,