# HG changeset patch # User Matt Mackall # Date 2008-05-12 16:37:08 # Node ID 7fe4610cf9208d66bbf5b0a61ddba00b19a2d0df # Parent 99a92acafdb93cbfc2b24f62a81833c6535f777e match: add always, never, and exact methods diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -34,3 +34,18 @@ class match(object): return self._files def anypats(self): return self._anypats + +def always(root, cwd): + return match(root, cwd, [], None, None, 'relpath') + +def never(root, cwd): + m = match(root, cwd, [], None, None, 'relpath') + m._matchfn = lambda f: False + return m + +def exact(root, cwd, files): + m = always(root, cwd) + m._files = files + m._fmap = dict.fromkeys(files) + m._matchfn = m._fmap.has_key + return m