glob:<directory> patterns match the files in that directory.
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Tue, 20 Mar 2007 22:09:55 -0300
changeset 4255 ef1f1a4b2efb
parent 4254 a7cae4e22749
child 4256 fe0fe0b4d73b
child 4306 6cecaec07cc9
glob:<directory> patterns match the files in that directory. This makes the behaviour of glob: patterns more consistent: hg status glob:dir and hg status -I glob:dir will match the same files. It's also consistent with the fact that {rel,}path patterns recursively match the contents of a directory.
mercurial/util.py
tests/test-walk.out
--- a/mercurial/util.py	Tue Mar 20 22:09:53 2007 -0300
+++ b/mercurial/util.py	Tue Mar 20 22:09:55 2007 -0300
@@ -427,7 +427,7 @@
             if c in _globchars: return True
         return False
 
-    def regex(kind, name, tail):
+    def regex(kind, name):
         '''convert a pattern into a regular expression'''
         if not name:
             return ''
@@ -443,16 +443,16 @@
             if name.startswith('^'):
                 return name
             return '.*' + name
-        return globre(name, '', tail)
+        return globre(name, '', '(?:/|$)')
 
-    def matchfn(pats, tail):
+    def matchfn(pats):
         """build a matching function from a set of patterns"""
         if not pats:
             return
         matches = []
         for k, p in pats:
             try:
-                pat = '(?:%s)' % regex(k, p, tail)
+                pat = '(?:%s)' % regex(k, p)
                 matches.append(re.compile(pat).match)
             except re.error:
                 if src: raise Abort("%s: invalid pattern (%s): %s" % (src, k, p))
@@ -500,15 +500,15 @@
 
     roots, pats, anypats = normalizepats(names, dflt_pat)
 
-    patmatch = matchfn(pats, '$') or always
+    patmatch = matchfn(pats) or always
     incmatch = always
     if inc:
         dummy, inckinds, dummy = normalizepats(inc, 'glob')
-        incmatch = matchfn(inckinds, '(?:/|$)')
+        incmatch = matchfn(inckinds)
     excmatch = lambda fn: False
     if exc:
         dummy, exckinds, dummy = normalizepats(exc, 'glob')
-        excmatch = matchfn(exckinds, '(?:/|$)')
+        excmatch = matchfn(exckinds)
 
     if not names and inc and not exc:
         # common case: hgignore patterns
--- a/tests/test-walk.out	Tue Mar 20 22:09:53 2007 -0300
+++ b/tests/test-walk.out	Tue Mar 20 22:09:55 2007 -0300
@@ -210,10 +210,20 @@
 beans/.hg: No such file or directory
 
 hg debugwalk glob:*
-f  fennel      fennel
-f  fenugreek   fenugreek
-f  fiddlehead  fiddlehead
-f  glob:glob   glob:glob
+f  beans/black                     beans/black
+f  beans/borlotti                  beans/borlotti
+f  beans/kidney                    beans/kidney
+f  beans/navy                      beans/navy
+f  beans/pinto                     beans/pinto
+f  beans/turtle                    beans/turtle
+f  fennel                          fennel
+f  fenugreek                       fenugreek
+f  fiddlehead                      fiddlehead
+f  glob:glob                       glob:glob
+f  mammals/Procyonidae/cacomistle  mammals/Procyonidae/cacomistle
+f  mammals/Procyonidae/coatimundi  mammals/Procyonidae/coatimundi
+f  mammals/Procyonidae/raccoon     mammals/Procyonidae/raccoon
+f  mammals/skunk                   mammals/skunk
 
 hg debugwalk re:.*[kb]$
 f  beans/black    beans/black