Mercurial > hg
comparison mercurial/match.py @ 33378:adf95bfb423a
match: make nevermatcher an exact matcher and a prefix matcher
The m.isexact() and m.prefix() methods are used by callers to
determine whether m.files() can be used for fast paths. It seems safe
to let callers to any fast paths it can that rely on the empty
m.files().
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sun, 09 Jul 2017 15:19:27 -0700 |
parents | 38b6122df5c7 |
children | 7ddb2aa2b7af |
comparison
equal
deleted
inserted
replaced
33377:5d63e5f40bea | 33378:adf95bfb423a |
---|---|
344 class nevermatcher(basematcher): | 344 class nevermatcher(basematcher): |
345 '''Matches nothing.''' | 345 '''Matches nothing.''' |
346 | 346 |
347 def __init__(self, root, cwd, badfn=None): | 347 def __init__(self, root, cwd, badfn=None): |
348 super(nevermatcher, self).__init__(root, cwd, badfn) | 348 super(nevermatcher, self).__init__(root, cwd, badfn) |
349 | |
350 # It's a little weird to say that the nevermatcher is an exact matcher | |
351 # or a prefix matcher, but it seems to make sense to let callers take | |
352 # fast paths based on either. There will be no exact matches, nor any | |
353 # prefixes (files() returns []), so fast paths iterating over them should | |
354 # be efficient (and correct). | |
355 def isexact(self): | |
356 return True | |
357 | |
358 def prefix(self): | |
359 return True | |
349 | 360 |
350 def __repr__(self): | 361 def __repr__(self): |
351 return '<nevermatcher>' | 362 return '<nevermatcher>' |
352 | 363 |
353 class patternmatcher(basematcher): | 364 class patternmatcher(basematcher): |