match: fold _globprefix into _roots
authorMatt Mackall <mpm@selenic.com>
Sun, 24 May 2009 02:56:14 -0500
changeset 8584 0f06e72abfdc
parent 8583 19d1b2aec562
child 8585 bbcd0da50e96
match: fold _globprefix into _roots
mercurial/match.py
--- a/mercurial/match.py	Sun May 24 02:56:14 2009 -0500
+++ b/mercurial/match.py	Sun May 24 02:56:14 2009 -0500
@@ -217,15 +217,6 @@
                 raise util.Abort("invalid pattern (%s): %s" % (k, p))
         raise util.Abort("invalid pattern")
 
-def _globprefix(pat):
-    '''return the non-glob prefix of a path, e.g. foo/* -> foo'''
-    root = []
-    for p in pat.split('/'):
-        if '[' in p or '{' in p or '*' in p or '?' in p:
-            break
-        root.append(p)
-    return '/'.join(root) or '.'
-
 def _normalize(names, default, root, cwd):
     pats = []
     for kind, name in [_patsplit(p, default) for p in names]:
@@ -240,8 +231,13 @@
 def _roots(patterns):
     r = []
     for kind, name in patterns:
-        if kind == 'glob':
-            r.append(_globprefix(name))
+        if kind == 'glob': # find the non-glob prefix
+            root = []
+            for p in name.split('/'):
+                if '[' in p or '{' in p or '*' in p or '?' in p:
+                    break
+                root.append(p)
+            r.append('/'.join(root) or '.')
         elif kind in ('relpath', 'path'):
             r.append(name or '.')
         elif kind == 'relglob':