export patkind() from util
authorRobin Farine <robin.farine@terminus.org>
Thu, 01 Dec 2005 10:48:22 -0600
changeset 1563 cc2a2e12f4ad
parent 1562 2f97af0b522c
child 1564 34579a67fa71
export patkind() from util
mercurial/util.py
--- a/mercurial/util.py	Thu Dec 01 10:48:18 2005 -0600
+++ b/mercurial/util.py	Thu Dec 01 10:48:22 2005 -0600
@@ -106,6 +106,13 @@
 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 @@
     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