diff options
Diffstat (limited to 'mercurial/match.py')
-rw-r--r-- | mercurial/match.py | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/mercurial/match.py b/mercurial/match.py index 927cd59..e01b835 100644 --- a/mercurial/match.py +++ b/mercurial/match.py @@ -9,14 +9,6 @@ import re import scmutil, util, fileset from i18n import _ -def _rematcher(pat): - m = util.compilere(pat) - try: - # slightly faster, provided by facebook's re2 bindings - return m.test_match - except AttributeError: - return m.match - def _expandsets(pats, ctx): '''convert set: patterns into a list of files in the given context''' fset = set() @@ -57,6 +49,7 @@ class match(object): '<something>' - a pattern of the specified default type """ + self._ctx = None self._root = root self._cwd = cwd self._files = [] @@ -70,10 +63,7 @@ class match(object): pats = _normalize(exclude, 'glob', root, cwd, auditor) self.excludepat, em = _buildmatch(ctx, pats, '(?:/|$)') if exact: - if isinstance(patterns, list): - self._files = patterns - else: - self._files = list(patterns) + self._files = patterns pm = self.exact elif patterns: pats = _normalize(patterns, default, root, cwd, auditor) @@ -129,8 +119,6 @@ class match(object): return self._files def anypats(self): return self._anypats - def always(self): - return False class exact(match): def __init__(self, root, cwd, files): @@ -139,8 +127,6 @@ class exact(match): class always(match): def __init__(self, root, cwd): match.__init__(self, root, cwd, []) - def always(self): - return True class narrowmatcher(match): """Adapt a matcher to work on a subdirectory only. @@ -287,8 +273,8 @@ def _buildregexmatch(pats, tail): try: pat = '(?:%s)' % '|'.join([_regex(k, p, tail) for (k, p) in pats]) if len(pat) > 20000: - raise OverflowError - return pat, _rematcher(pat) + raise OverflowError() + return pat, re.compile(pat).match except OverflowError: # We're using a Python with a tiny regex engine and we # made it explode, so we'll divide the pattern list in two @@ -302,7 +288,7 @@ def _buildregexmatch(pats, tail): except re.error: for k, p in pats: try: - _rematcher('(?:%s)' % _regex(k, p, tail)) + re.compile('(?:%s)' % _regex(k, p, tail)) except re.error: raise util.Abort(_("invalid pattern (%s): %s") % (k, p)) raise util.Abort(_("invalid pattern")) @@ -348,5 +334,5 @@ def _roots(patterns): def _anypats(patterns): for kind, name in patterns: - if kind in ('glob', 're', 'relglob', 'relre', 'set'): + if kind in ('glob', 're', 'relglob', 'relre'): return True |