# HG changeset patch # User Nicolas Dumazet # Date 2010-08-30 04:32:37 # Node ID 969176bec2177ce3ddb6831569f4691607159cd1 # Parent 6f58430dfdd03a658c72fcf90b70519b75c2b66e tests: unify test-revert diff --git a/tests/test-revert.out b/tests/test-revert.out deleted file mode 100644 --- a/tests/test-revert.out +++ /dev/null @@ -1,87 +0,0 @@ -%% should show b unknown -? b -%% should show b unknown and c modified -M c -? b -%% should show b added and c modified -M c -A b -%% should show a removed, b added and c modified -M c -A b -R a -%% should show b added, copy saved, and c modified -M c -A b -%% should show b unknown, and c modified -M c -? b -%% should show unknown: b -? b -%% should show b added -A b -%% should show b deleted -! b -forgetting b -%% should not find b -b: No such file or directory -%% should show a c e -a -c -e -%% should verbosely save backup to e.orig -saving current version of e as e.orig -reverting e -%% should say no changes needed -no changes needed to a -%% should say file not managed -file not managed: q -%% should say file not found -notfound: no such file in rev 095eacd0c0d7 -A z -? e.orig -%% should add a, remove d, forget z -adding a -removing d -forgetting z -%% should forget a, undelete d -forgetting a -undeleting d -%% should silently add a -A a -R d -%% should silently keep d removed -R d -1 files updated, 0 files merged, 0 files removed, 0 files unresolved -reverting c -%% should print non-executable -non-executable -reverting c -%% should print executable -executable -%% issue 241 -adding a -1 files updated, 0 files merged, 0 files removed, 0 files unresolved -% should fail - no arguments -abort: no files or directories specified; use --all to revert the whole repo -% should succeed -reverting a -%% issue332 -adding b/b -created new head -reverting b/b -forgetting newdir/newfile -reverting b/b -% reverting a rename target should revert the source -? newa -%% 4 ignored files (we will add/commit everything) -I ignored -I ignoreddir/file -I ignoreddir/removed -I removed -%% should revert ignored* and undelete *removed -reverting ignored -reverting ignoreddir/file -undeleting ignoreddir/removed -undeleting removed -%% should silently revert the named files diff --git a/tests/test-revert b/tests/test-revert.t old mode 100755 new mode 100644 rename from tests/test-revert rename to tests/test-revert.t --- a/tests/test-revert +++ b/tests/test-revert.t @@ -1,151 +1,263 @@ -#!/bin/sh + $ hg init repo + $ cd repo + $ echo 123 > a + $ echo 123 > c + $ echo 123 > e + $ hg add a c e + $ hg commit -m "first" -d "1000000 0" a c e + $ echo 123 > b + +should show b unknown + + $ hg status + ? b + $ echo 12 > c + +should show b unknown and c modified + + $ hg status + M c + ? b + $ hg add b + +should show b added and c modified + + $ hg status + M c + A b + $ hg rm a + +should show a removed, b added and c modified + + $ hg status + M c + A b + R a + $ hg revert a + +should show b added, copy saved, and c modified + + $ hg status + M c + A b + $ hg revert b + +should show b unknown, and c modified + + $ hg status + M c + ? b + $ hg revert --no-backup c + +should show unknown: b + + $ hg status + ? b + $ hg add b + +should show b added + + $ hg status b + A b + $ rm b + +should show b deleted -hg init repo -cd repo -echo 123 > a -echo 123 > c -echo 123 > e -hg add a c e -hg commit -m "first" -d "1000000 0" a c e -echo 123 > b -echo %% should show b unknown -hg status -echo 12 > c -echo %% should show b unknown and c modified -hg status -hg add b -echo %% should show b added and c modified -hg status -hg rm a -echo %% should show a removed, b added and c modified -hg status -hg revert a -echo %% should show b added, copy saved, and c modified -hg status -hg revert b -echo %% should show b unknown, and c modified -hg status -hg revert --no-backup c -echo %% should show unknown: b -hg status -hg add b -echo %% should show b added -hg status b -rm b -echo %% should show b deleted -hg status b -hg revert -v b -echo %% should not find b -hg status b -echo %% should show a c e -ls -echo %% should verbosely save backup to e.orig -echo z > e -hg revert --all -v -echo %% should say no changes needed -hg revert a -echo %% should say file not managed -echo q > q -hg revert q -rm q -echo %% should say file not found -hg revert notfound -touch d -hg add d -hg rm a -hg commit -m "second" -d "1000000 0" -echo z > z -hg add z -hg st -echo %% should add a, remove d, forget z -hg revert --all -r0 -echo %% should forget a, undelete d -hg revert --all -rtip -rm a *.orig -echo %% should silently add a -hg revert -r0 a -hg st a -hg rm d -hg st d -echo %% should silently keep d removed -hg revert -r0 d -hg st d + $ hg status b + ! b + $ hg revert -v b + forgetting b + +should not find b + + $ hg status b + b: No such file or directory + +should show a c e + + $ ls + a + c + e + +should verbosely save backup to e.orig + + $ echo z > e + $ hg revert --all -v + saving current version of e as e.orig + reverting e + +should say no changes needed + + $ hg revert a + no changes needed to a + +should say file not managed + + $ echo q > q + $ hg revert q + file not managed: q + $ rm q + +should say file not found + + $ hg revert notfound + notfound: no such file in rev 095eacd0c0d7 + $ touch d + $ hg add d + $ hg rm a + $ hg commit -m "second" -d "1000000 0" + $ echo z > z + $ hg add z + $ hg st + A z + ? e.orig + +should add a, remove d, forget z + + $ hg revert --all -r0 + adding a + removing d + forgetting z + +should forget a, undelete d + + $ hg revert --all -rtip + forgetting a + undeleting d + $ rm a *.orig + +should silently add a -hg update -C -chmod +x c -hg revert --all -echo %% should print non-executable -test -x c || echo non-executable + $ hg revert -r0 a + $ hg st a + A a + $ hg rm d + $ hg st d + R d + +should silently keep d removed + + $ hg revert -r0 d + $ hg st d + R d -chmod +x c -hg commit -d '1000001 0' -m exe + $ hg update -C + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ chmod +x c + $ hg revert --all + reverting c + +should print non-executable -chmod -x c -hg revert --all -echo %% should print executable -test -x c && echo executable + $ test -x c || echo non-executable + non-executable + + $ chmod +x c + $ hg commit -d '1000001 0' -m exe -cd .. + $ chmod -x c + $ hg revert --all + reverting c + +should print executable -echo %% issue 241 -hg init a -cd a -echo a >> a -hg commit -A -d '1 0' -m a -echo a >> a -hg commit -d '2 0' -m a -hg update 0 -mkdir b -echo b > b/b + $ test -x c && echo executable + executable + + $ cd .. + + +issue 241 -echo % should fail - no arguments -hg revert -rtip + $ hg init a + $ cd a + $ echo a >> a + $ hg commit -A -d '1 0' -m a + adding a + $ echo a >> a + $ hg commit -d '2 0' -m a + $ hg update 0 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ mkdir b + $ echo b > b/b -echo % should succeed -hg revert --all -rtip +should fail - no arguments + + $ hg revert -rtip + abort: no files or directories specified; use --all to revert the whole repo + +should succeed + + $ hg revert --all -rtip + reverting a + + +issue332 -echo %% issue332 -hg ci -A -m b -d '1000001 0' -echo foobar > b/b -mkdir newdir -echo foo > newdir/newfile -hg add newdir/newfile -hg revert b newdir -echo foobar > b/b -hg revert . + $ hg ci -A -m b -d '1000001 0' + adding b/b + created new head + $ echo foobar > b/b + $ mkdir newdir + $ echo foo > newdir/newfile + $ hg add newdir/newfile + $ hg revert b newdir + reverting b/b + forgetting newdir/newfile + $ echo foobar > b/b + $ hg revert . + reverting b/b + -echo % reverting a rename target should revert the source -hg mv a newa -hg revert newa -hg st a newa +reverting a rename target should revert the source + + $ hg mv a newa + $ hg revert newa + $ hg st a newa + ? newa -cd .. + $ cd .. -hg init ignored -cd ignored -echo '^ignored$' > .hgignore -echo '^ignoreddir$' >> .hgignore -echo '^removed$' >> .hgignore + $ hg init ignored + $ cd ignored + $ echo '^ignored$' > .hgignore + $ echo '^ignoreddir$' >> .hgignore + $ echo '^removed$' >> .hgignore -mkdir ignoreddir -touch ignoreddir/file -touch ignoreddir/removed -touch ignored -touch removed -echo '%% 4 ignored files (we will add/commit everything)' -hg st -A -X .hgignore -hg ci -qAm 'add files' ignored ignoreddir/file ignoreddir/removed removed + $ mkdir ignoreddir + $ touch ignoreddir/file + $ touch ignoreddir/removed + $ touch ignored + $ touch removed + +4 ignored files (we will add/commit everything) + + $ hg st -A -X .hgignore + I ignored + I ignoreddir/file + I ignoreddir/removed + I removed + $ hg ci -qAm 'add files' ignored ignoreddir/file ignoreddir/removed removed -echo >> ignored -echo >> ignoreddir/file -hg rm removed ignoreddir/removed -echo '%% should revert ignored* and undelete *removed' -hg revert -a --no-backup -hg st -mardi + $ echo >> ignored + $ echo >> ignoreddir/file + $ hg rm removed ignoreddir/removed + +should revert ignored* and undelete *removed -hg up -qC -echo >> ignored -hg rm removed -echo %% should silently revert the named files -hg revert --no-backup ignored removed -hg st -mardi + $ hg revert -a --no-backup + reverting ignored + reverting ignoreddir/file + undeleting ignoreddir/removed + undeleting removed + $ hg st -mardi + + $ hg up -qC + $ echo >> ignored + $ hg rm removed + +should silently revert the named files + + $ hg revert --no-backup ignored removed + $ hg st -mardi