changeset 4190:769bc4af561d

util.*matcher: change default "names" argument names=['.'] means "include (recursively) only files from the current subdir"; the function then did a hack to walk the whole tree. Clean that up. This also fixes a problem where "--include ." works in a subdir, but not on the tree root.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 10 Mar 2007 23:00:51 -0300
parents b1716a1f79c4
children 02de0f98ca33
files mercurial/util.py tests/test-walk tests/test-walk.out
diffstat 3 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Sat Mar 10 23:00:49 2007 -0300
+++ b/mercurial/util.py	Sat Mar 10 23:00:51 2007 -0300
@@ -378,10 +378,10 @@
 
         raise Abort('%s not under root' % myname)
 
-def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None):
+def matcher(canonroot, cwd='', names=[], inc=[], exc=[], head='', src=None):
     return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src)
 
-def cmdmatcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='',
+def cmdmatcher(canonroot, cwd='', names=[], inc=[], exc=[], head='',
                src=None, globbed=False):
     if not globbed:
         names = expand_glob(names)
@@ -428,6 +428,8 @@
 
     def regex(kind, name, tail):
         '''convert a pattern into a regular expression'''
+        if not name:
+            return ''
         if kind == 're':
             return name
         elif kind == 'path':
@@ -477,8 +479,6 @@
     for kind, name in [patkind(p, dflt_pat) for p in names]:
         if kind in ('glob', 'relpath'):
             name = canonpath(canonroot, cwd, name)
-            if name == '':
-                kind, name = 'glob', '**'
         elif kind in ('relglob', 'path'):
             name = normpath(name)
         if kind in ('glob', 're', 'relglob'):
@@ -509,7 +509,7 @@
                          (not pats and not files) or
                          (pats and patmatch(fn)) or
                          (files and filematch(fn)))),
-            (inc or exc or (pats and pats != [('glob', '**')])) and True)
+            (inc or exc or pats) and True)
 
 def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None):
     '''enhanced shell command execution.
--- a/tests/test-walk	Sat Mar 10 23:00:49 2007 -0300
+++ b/tests/test-walk	Sat Mar 10 23:00:51 2007 -0300
@@ -19,8 +19,10 @@
 hg addremove
 hg commit -m "commit #0" -d "1000000 0"
 hg debugwalk
+hg debugwalk -I.
 cd mammals
 hg debugwalk .
+hg debugwalk -I.
 hg debugwalk Procyonidae
 cd Procyonidae
 hg debugwalk .
--- a/tests/test-walk.out	Sat Mar 10 23:00:49 2007 -0300
+++ b/tests/test-walk.out	Sat Mar 10 23:00:51 2007 -0300
@@ -26,6 +26,24 @@
 f  mammals/Procyonidae/coatimundi  mammals/Procyonidae/coatimundi
 f  mammals/Procyonidae/raccoon     mammals/Procyonidae/raccoon
 f  mammals/skunk                   mammals/skunk
+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
+f  mammals/Procyonidae/cacomistle  Procyonidae/cacomistle
+f  mammals/Procyonidae/coatimundi  Procyonidae/coatimundi
+f  mammals/Procyonidae/raccoon     Procyonidae/raccoon
+f  mammals/skunk                   skunk
 f  mammals/Procyonidae/cacomistle  Procyonidae/cacomistle
 f  mammals/Procyonidae/coatimundi  Procyonidae/coatimundi
 f  mammals/Procyonidae/raccoon     Procyonidae/raccoon