changeset 1563:cc2a2e12f4ad

export patkind() from util
author Robin Farine <robin.farine@terminus.org>
date Thu, 01 Dec 2005 10:48:22 -0600
parents 2f97af0b522c
children 34579a67fa71
files mercurial/util.py
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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