Mercurial > hg
diff mercurial/util.py @ 8568:4fa1618bf495
match: refactor patkind
add patkind(pat) to match
change external users
change util.patkind to _patsplit
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 24 May 2009 02:56:14 -0500 |
parents | 744d6322b05b |
children | 4fadac101818 |
line wrap: on
line diff
--- a/mercurial/util.py Sun May 24 02:56:14 2009 -0500 +++ b/mercurial/util.py Sun May 24 02:56:14 2009 -0500 @@ -207,12 +207,12 @@ def always(fn): return True def never(fn): return False -def patkind(name, default): +def _patsplit(pat, default): """Split a string into an optional pattern kind prefix and the actual pattern.""" for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': - if name.startswith(prefix + ':'): return name.split(':', 1) - return default, name + if pat.startswith(prefix + ':'): return pat.split(':', 1) + return default, pat def globre(pat, head='^', tail='$'): "convert a glob pattern into a regexp" @@ -436,7 +436,7 @@ pats = [] roots = [] anypats = False - for kind, name in [patkind(p, default) for p in names]: + for kind, name in [_patsplit(p, default) for p in names]: if kind in ('glob', 'relpath'): name = canonpath(canonroot, cwd, name) elif kind in ('relglob', 'path'): @@ -739,7 +739,7 @@ '''On Windows, expand the implicit globs in a list of patterns''' ret = [] for p in pats: - kind, name = patkind(p, None) + kind, name = _patsplit(p, None) if kind is None: globbed = glob.glob(name) if globbed: