Mercurial > public > mercurial-scm > hg-stable
diff mercurial/match.py @ 6596:7fe4610cf920
match: add always, never, and exact methods
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 12 May 2008 11:37:08 -0500 |
parents | f242d3684f83 |
children | 98b6e6f0e49b |
line wrap: on
line diff
--- a/mercurial/match.py Mon May 12 11:37:08 2008 -0500 +++ b/mercurial/match.py Mon May 12 11:37:08 2008 -0500 @@ -34,3 +34,18 @@ 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