mercurial/util.py
changeset 1270 fc3b41570082
parent 1258 1945754e466b
child 1285 1546c2aa6b30
--- a/mercurial/util.py	Sat Sep 17 00:23:58 2005 -0700
+++ b/mercurial/util.py	Sat Sep 17 00:27:27 2005 -0700
@@ -122,7 +122,7 @@
     else:
         raise Abort('%s not under root' % myname)
 
-def matcher(canonroot, cwd, names, inc, exc, head=''):
+def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''):
     """build a function to match a set of file patterns
 
     arguments:
@@ -134,11 +134,13 @@
     head - a regex to prepend to patterns to control whether a match is rooted
 
     a pattern is one of:
-    're:<regex>'
-    'glob:<shellglob>'
-    'path:<explicit path>'
+    'glob:<rooted glob>'
+    're:<rooted regexp>'
+    'path:<rooted path>'
+    'relglob:<relative glob>'
     'relpath:<relative path>'
-    '<relative path>'
+    'relre:<relative regexp>'
+    '<rooted path or regexp>'
 
     returns:
     a 3-tuple containing
@@ -151,8 +153,8 @@
     """
 
     def patkind(name):
-        for prefix in 're:', 'glob:', 'path:', 'relpath:':
-            if name.startswith(prefix): return name.split(':', 1)
+        for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre':
+            if name.startswith(prefix + ':'): return name.split(':', 1)
         for c in name:
             if c in _globchars: return 'glob', name
         return 'relpath', name
@@ -163,8 +165,14 @@
             return name
         elif kind == 'path':
             return '^' + re.escape(name) + '(?:/|$)'
+        elif kind == 'relglob':
+            return head + globre(name, '(?:|.*/)', tail)
         elif kind == 'relpath':
             return head + re.escape(name) + tail
+        elif kind == 'relre':
+            if name.startswith('^'):
+                return name
+            return '.*' + name
         return head + globre(name, '', tail)
 
     def matchfn(pats, tail):