Merge some matcher fixes/cleanups and add some more hg locate tests
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Fri, 16 Mar 2007 22:58:49 -0300
changeset 4237 da6b14877195
parent 4232 0d51eb296fb9 (current diff)
parent 4236 34c4540c04c5 (diff)
child 4248 815ad65cfca9
Merge some matcher fixes/cleanups and add some more hg locate tests
mercurial/util.py
tests/test-revert
tests/test-revert.out
--- a/mercurial/util.py	Fri Mar 16 00:45:18 2007 -0300
+++ b/mercurial/util.py	Fri Mar 16 22:58:49 2007 -0300
@@ -496,7 +496,6 @@
 
     def normalizepats(names, default):
         pats = []
-        files = []
         roots = []
         anypats = False
         for kind, name in [patkind(p, default) for p in names]:
@@ -504,18 +503,20 @@
                 name = canonpath(canonroot, cwd, name)
             elif kind in ('relglob', 'path'):
                 name = normpath(name)
+
+            pats.append((kind, name))
+
             if kind in ('glob', 're', 'relglob', 'relre'):
-                pats.append((kind, name))
                 anypats = True
+
             if kind == 'glob':
                 root = globprefix(name)
                 roots.append(root)
             elif kind in ('relpath', 'path'):
-                files.append((kind, name))
-                roots.append(name)
+                roots.append(name or '.')
             elif kind == 'relglob':
                 roots.append('.')
-        return roots, pats + files, anypats
+        return roots, pats, anypats
 
     roots, pats, anypats = normalizepats(names, dflt_pat)
 
--- a/tests/test-locate	Fri Mar 16 00:45:18 2007 -0300
+++ b/tests/test-locate	Fri Mar 16 22:58:49 2007 -0300
@@ -1,5 +1,14 @@
 #!/bin/sh
-#
+
+hglocate()
+{
+    echo "hg locate $@"
+    hg locate "$@"
+    ret=$?
+    echo
+    return $ret
+}
+
 mkdir t
 cd t
 hg init
@@ -8,24 +17,36 @@
 echo 0 > t.h
 mkdir t
 echo 0 > t/x
+echo 0 > t/b
+echo 0 > t/e.h
 hg ci -A -m m -d "1000000 0"
 touch nottracked
-hg locate a && echo locate succeeded || echo locate failed
-hg locate NONEXISTENT && echo locate succeeded || echo locate failed
-hg locate
+hglocate a && echo locate succeeded || echo locate failed
+hglocate NONEXISTENT && echo locate succeeded || echo locate failed
+hglocate
 hg rm a
 hg ci -m m -d "1000000 0"
-hg locate a
-hg locate NONEXISTENT
-hg locate
-hg locate -r 0 a
-hg locate -r 0 NONEXISTENT
-hg locate -r 0
+hglocate a
+hglocate NONEXISTENT
+hglocate
+hglocate -r 0 a
+hglocate -r 0 NONEXISTENT
+hglocate -r 0
 echo % -I/-X with relative path should work
 cd t
-hg locate
-hg locate -I ../t
+hglocate
+hglocate -I ../t
 # test issue294
 cd ..
 rm -r t
-hg locate t
+hglocate t
+mkdir otherdir
+cd otherdir
+hglocate b
+hglocate '*.h'
+hglocate path:t/x
+hglocate 're:.*\.h'
+hglocate -r 0 b
+hglocate -r 0 '*.h'
+hglocate -r 0 path:t/x
+hglocate -r 0 're:.*\.h'
--- a/tests/test-locate.out	Fri Mar 16 00:45:18 2007 -0300
+++ b/tests/test-locate.out	Fri Mar 16 22:58:49 2007 -0300
@@ -1,25 +1,93 @@
 adding a
 adding b
 adding t.h
+adding t/b
+adding t/e.h
 adding t/x
+hg locate a
+a
+
+locate succeeded
+hg locate NONEXISTENT
+
+locate failed
+hg locate 
 a
-locate succeeded
-locate failed
+b
+t.h
+t/b
+t/e.h
+t/x
+
+hg locate a
+
+hg locate NONEXISTENT
+
+hg locate 
+b
+t.h
+t/b
+t/e.h
+t/x
+
+hg locate -r 0 a
+a
+
+hg locate -r 0 NONEXISTENT
+
+hg locate -r 0
 a
 b
 t.h
+t/b
+t/e.h
 t/x
-b
-t.h
-t/x
-a
-a
+
+% -I/-X with relative path should work
+hg locate 
 b
 t.h
+t/b
+t/e.h
 t/x
-% -I/-X with relative path should work
-b
-t.h
+
+hg locate -I ../t
+t/b
+t/e.h
+t/x
+
+hg locate t
+t/b
+t/e.h
 t/x
-t/x
-t/x
+
+hg locate b
+../b
+../t/b
+
+hg locate *.h
+../t.h
+../t/e.h
+
+hg locate path:t/x
+../t/x
+
+hg locate re:.*\.h
+../t.h
+../t/e.h
+
+hg locate -r 0 b
+../b
+../t/b
+
+hg locate -r 0 *.h
+../t.h
+../t/e.h
+
+hg locate -r 0 path:t/x
+../t/x
+
+hg locate -r 0 re:.*\.h
+../t.h
+../t/e.h
+
--- a/tests/test-revert	Fri Mar 16 00:45:18 2007 -0300
+++ b/tests/test-revert	Fri Mar 16 22:58:49 2007 -0300
@@ -92,4 +92,6 @@
 echo foo > newdir/newfile
 hg add newdir/newfile
 hg revert b newdir
+echo foobar > b/b
+hg revert .
 true
--- a/tests/test-revert.out	Fri Mar 16 00:45:18 2007 -0300
+++ b/tests/test-revert.out	Fri Mar 16 22:58:49 2007 -0300
@@ -62,3 +62,4 @@
 adding b/b
 reverting b/b
 forgetting newdir/newfile
+reverting b/b