tests/test-revert
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
Fri, 16 Mar 2007 00:22:52 -0300
changeset 4225 281f9f8f1bd4
parent 3988 9dcf9d45cab8
child 4237 da6b14877195
permissions -rwxr-xr-x
Fix confusing message from hg revert (issue332) % mkdir sub1 % touch sub1/file1 % hg add sub1/ adding sub1/file1 % hg rev sub1 sub1: No such file in rev e4c586763258 forgetting sub1/file1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
     1
#!/bin/sh
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
     2
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
     3
hg init
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
     4
echo 123 > a
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
     5
echo 123 > c
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
     6
echo 123 > e
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
     7
hg add a c e
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
     8
hg commit -m "first" -d "1000000 0" a c e
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
     9
echo 123 > b
1487
2bc6cd62a29c fix handling of files of unsupported type in the walk code
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1449
diff changeset
    10
echo %% should show b unknown
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    11
hg status
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    12
echo 12 > c
1487
2bc6cd62a29c fix handling of files of unsupported type in the walk code
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1449
diff changeset
    13
echo %% should show b unknown and c modified
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    14
hg status
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    15
hg add b
1487
2bc6cd62a29c fix handling of files of unsupported type in the walk code
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1449
diff changeset
    16
echo %% should show b added and c modified
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    17
hg status
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    18
hg rm a
1487
2bc6cd62a29c fix handling of files of unsupported type in the walk code
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1449
diff changeset
    19
echo %% should show a removed, b added and c modified
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    20
hg status
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    21
hg revert a
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    22
echo %% should show b added, copy saved, and c modified
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    23
hg status
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    24
hg revert b
2043
968f036f93a4 Minor fix for revert: No need to make a backup when forgetting added files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2042
diff changeset
    25
echo %% should show b unknown, and c modified
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    26
hg status
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    27
hg revert --no-backup c
2043
968f036f93a4 Minor fix for revert: No need to make a backup when forgetting added files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2042
diff changeset
    28
echo %% should show unknown: b
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    29
hg status
2043
968f036f93a4 Minor fix for revert: No need to make a backup when forgetting added files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2042
diff changeset
    30
echo %% should show a b c e
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    31
ls
2036
c9226bcc288d Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2029
diff changeset
    32
echo %% should verbosely save backup to e.orig
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    33
echo z > e
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    34
hg revert --all -v
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    35
echo %% should say no changes needed
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    36
hg revert a
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    37
echo %% should say file not managed
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    38
echo q > q
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    39
hg revert q
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    40
rm q
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    41
echo %% should say file not found
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1933
diff changeset
    42
hg revert notfound
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    43
hg rm a
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    44
hg commit -m "second" -d "1000000 0"
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    45
echo z > z
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    46
hg add z
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    47
hg st
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    48
echo %% should add a, forget z
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    49
hg revert --all -r0
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    50
echo %% should forget a
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    51
hg revert --all -rtip
3988
9dcf9d45cab8 Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3019
diff changeset
    52
rm a *.orig
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    53
echo %% should silently add a
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    54
hg revert -r0 a
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2036
diff changeset
    55
hg st a
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    56
2157
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    57
hg update -C
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    58
chmod +x c
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    59
hg revert --all
2157
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    60
echo %% should print non-executable
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    61
test -x c || echo non-executable
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    62
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    63
chmod +x c
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    64
hg commit -d '1000001 0' -m exe
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    65
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    66
chmod -x c
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    67
hg revert --all
2157
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    68
echo %% should print executable
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    69
test -x c && echo executable
1e82f2337498 make test-revert check executable bit.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2043
diff changeset
    70
2272
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    71
echo %% issue 241
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    72
hg init a
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    73
cd a
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    74
echo a >> a
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    75
hg commit -A -d '1 0' -m a
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    76
echo a >> a
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    77
hg commit -d '2 0' -m a
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    78
hg update 0
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    79
mkdir b
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    80
echo b > b/b
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    81
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    82
echo % should fail - no arguments
2272
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    83
hg revert -rtip
e9a0ed9ed4d9 revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2157
diff changeset
    84
2982
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    85
echo % should succeed
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    86
hg revert --all -rtip
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
    87
3019
aebc3f64b20f fix incorrect warning when walking on a particular rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2982
diff changeset
    88
echo %% issue332
aebc3f64b20f fix incorrect warning when walking on a particular rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2982
diff changeset
    89
hg ci -A -m b -d '1000001 0'
aebc3f64b20f fix incorrect warning when walking on a particular rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2982
diff changeset
    90
echo foobar > b/b
4225
281f9f8f1bd4 Fix confusing message from hg revert (issue332)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    91
mkdir newdir
281f9f8f1bd4 Fix confusing message from hg revert (issue332)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    92
echo foo > newdir/newfile
281f9f8f1bd4 Fix confusing message from hg revert (issue332)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    93
hg add newdir/newfile
281f9f8f1bd4 Fix confusing message from hg revert (issue332)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    94
hg revert b newdir
1447
508a3f559553 revert added and removed files to their normal state before reverting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
    95
true