# HG changeset patch # User Robin Farine # Date 1133455702 21600 # Node ID cc2a2e12f4adf79dea610c6579eebf0c6d169537 # Parent 2f97af0b522c6a927395c9d90bd5dded41b2ee2a export patkind() from util diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -106,6 +106,13 @@ class Abort(Exception): def always(fn): return True def never(fn): return False +def patkind(name, dflt_pat='glob'): + """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 dflt_pat, name + def globre(pat, head='^', tail='$'): "convert a glob pattern into a regexp" i, n = 0, len(pat) @@ -220,11 +227,6 @@ def _matcher(canonroot, cwd, names, inc, make head regex a rooted bool """ - def patkind(name, dflt_pat='glob'): - for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': - if name.startswith(prefix + ':'): return name.split(':', 1) - return dflt_pat, name - def contains_glob(name): for c in name: if c in _globchars: return True