# HG changeset patch # User Alexis S. L. Carvalho # Date 1174096729 10800 # Node ID da6b148771950a1f876683e7458cd9acb337bc31 # Parent 0d51eb296fb93ca3a4035de62cd06c3da940c248# Parent 34c4540c04c577932a9ca3cb623636070edfdc2d Merge some matcher fixes/cleanups and add some more hg locate tests diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -496,7 +496,6 @@ def _matcher(canonroot, cwd, names, inc, def normalizepats(names, default): pats = [] - files = [] roots = [] anypats = False for kind, name in [patkind(p, default) for p in names]: @@ -504,18 +503,20 @@ def _matcher(canonroot, cwd, names, inc, 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) diff --git a/tests/test-locate b/tests/test-locate --- a/tests/test-locate +++ b/tests/test-locate @@ -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 > b 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' diff --git a/tests/test-locate.out b/tests/test-locate.out --- a/tests/test-locate.out +++ b/tests/test-locate.out @@ -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 + diff --git a/tests/test-revert b/tests/test-revert --- a/tests/test-revert +++ b/tests/test-revert @@ -92,4 +92,6 @@ mkdir newdir echo foo > newdir/newfile hg add newdir/newfile hg revert b newdir +echo foobar > b/b +hg revert . true diff --git a/tests/test-revert.out b/tests/test-revert.out --- a/tests/test-revert.out +++ b/tests/test-revert.out @@ -62,3 +62,4 @@ reverting a adding b/b reverting b/b forgetting newdir/newfile +reverting b/b