##// END OF EJS Templates
match: introduce nevermatcher for when no ignore files are present...
Siddharth Agarwal -
r32600:e6ff007e default
parent child Browse files
Show More
@@ -232,7 +232,7 b' class dirstate(object):'
232 def _ignore(self):
232 def _ignore(self):
233 files = self._ignorefiles()
233 files = self._ignorefiles()
234 if not files:
234 if not files:
235 return util.never
235 return matchmod.never(self._root, '')
236
236
237 pats = ['include:%s' % f for f in files]
237 pats = ['include:%s' % f for f in files]
238 return matchmod.match(self._root, '', [], pats, warn=self._ui.warn)
238 return matchmod.match(self._root, '', [], pats, warn=self._ui.warn)
@@ -175,6 +175,9 b' def exact(root, cwd, files, badfn=None):'
175 def always(root, cwd):
175 def always(root, cwd):
176 return alwaysmatcher(root, cwd)
176 return alwaysmatcher(root, cwd)
177
177
178 def never(root, cwd):
179 return nevermatcher(root, cwd)
180
178 def badmatch(match, badfn):
181 def badmatch(match, badfn):
179 """Make a copy of the given matcher, replacing its bad method with the given
182 """Make a copy of the given matcher, replacing its bad method with the given
180 one.
183 one.
@@ -339,6 +342,25 b' class alwaysmatcher(basematcher):'
339 def __repr__(self):
342 def __repr__(self):
340 return '<alwaysmatcher>'
343 return '<alwaysmatcher>'
341
344
345 class nevermatcher(basematcher):
346 '''Matches nothing.'''
347
348 def __init__(self, root, cwd, badfn=None, relativeuipath=False):
349 super(nevermatcher, self).__init__(root, cwd, badfn,
350 relativeuipath=relativeuipath)
351
352 def always(self):
353 return False
354
355 def matchfn(self, f):
356 return False
357
358 def visitdir(self, dir):
359 return False
360
361 def __repr__(self):
362 return '<nevermatcher>'
363
342 class patternmatcher(basematcher):
364 class patternmatcher(basematcher):
343
365
344 def __init__(self, root, cwd, kindpats, ctx=None, listsubrepos=False,
366 def __init__(self, root, cwd, kindpats, ctx=None, listsubrepos=False,
@@ -1,6 +1,10 b''
1 $ hg init ignorerepo
1 $ hg init ignorerepo
2 $ cd ignorerepo
2 $ cd ignorerepo
3
3
4 debugignore with no hgignore should be deterministic:
5 $ hg debugignore
6 <nevermatcher>
7
4 Issue562: .hgignore requires newline at end:
8 Issue562: .hgignore requires newline at end:
5
9
6 $ touch foo
10 $ touch foo
General Comments 0
You need to be logged in to leave comments. Login now