##// END OF EJS Templates
util: privatize globre
util: privatize globre

File last commit:

r8568:4fa1618b default
r8569:4fadac10 default
Show More
match.py
59 lines | 1.7 KiB | text/x-python | PythonLexer
Martin Geisler
match: add copyright and license header
r8231 # match.py - file name matching
#
# Copyright 2008, 2009 Matt Mackall <mpm@selenic.com> and others
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2, incorporated herein by reference.
Matt Mackall
walk: introduce match objects
r6576 import util
Matt Mackall
match: cleanup match classes a bit
r6604 class _match(object):
def __init__(self, root, cwd, files, mf, ap):
Matt Mackall
walk: introduce match objects
r6576 self._root = root
self._cwd = cwd
Matt Mackall
match: cleanup match classes a bit
r6604 self._files = files
Martin Geisler
replace set-like dictionaries with real sets...
r8152 self._fmap = set(files)
Matt Mackall
dirstate.walk: speed up calling match function
r6834 self.matchfn = mf
Matt Mackall
walk: introduce match objects
r6576 self._anypats = ap
def __call__(self, fn):
Matt Mackall
dirstate.walk: speed up calling match function
r6834 return self.matchfn(fn)
Matt Mackall
walk: introduce match objects
r6576 def __iter__(self):
for f in self._files:
yield f
def bad(self, f, msg):
return True
def dir(self, f):
pass
def missing(self, f):
pass
def exact(self, f):
return f in self._fmap
def rel(self, f):
return util.pathto(self._root, self._cwd, f)
def files(self):
return self._files
def anypats(self):
return self._anypats
Matt Mackall
match: add always, never, and exact methods
r6596
Matt Mackall
match: cleanup match classes a bit
r6604 class always(_match):
def __init__(self, root, cwd):
_match.__init__(self, root, cwd, [], lambda f: True, False)
class never(_match):
def __init__(self, root, cwd):
_match.__init__(self, root, cwd, [], lambda f: False, False)
Matt Mackall
match: add always, never, and exact methods
r6596
Matt Mackall
match: cleanup match classes a bit
r6604 class exact(_match):
def __init__(self, root, cwd, files):
Simon Heimberg
match: use self.exact instead of lambda...
r8522 _match.__init__(self, root, cwd, files, self.exact, False)
Matt Mackall
match: add always, never, and exact methods
r6596
Matt Mackall
match: cleanup match classes a bit
r6604 class match(_match):
Matt Mackall
match: add some default args
r8567 def __init__(self, root, cwd, patterns, include=[], exclude=[],
default='glob'):
Matt Mackall
match: cleanup match classes a bit
r6604 f, mf, ap = util.matcher(root, cwd, patterns, include, exclude,
Matt Mackall
match: change all users of util.matcher to match.match
r8566 default)
Matt Mackall
match: cleanup match classes a bit
r6604 _match.__init__(self, root, cwd, f, mf, ap)
Matt Mackall
match: refactor patkind...
r8568
def patkind(pat):
return util._patsplit(pat, None)[0]