tests/test-backout
author Gilles Moris <gilles.moris@free.fr>
Thu, 21 Feb 2008 08:52:52 +0100
changeset 6161 bc1ba9124799
parent 5568 de620356064f
child 6162 554715e584e6
permissions -rwxr-xr-x
Reverse the way backout is doing the merge Currently, backout is creating a backout revision as a child node of the backed out node and will leave you at this new head. This has several drawbacks: * this changes the current head * when there is a long history between the backed out node and the current head, this will generate a huge number of diffs that are scary at first sight, and not very natural to review before commit. The change consists to switch back to the original node as soon as the backout node (which becomes the new tip) has been created. Then the --merge option can just merge this new tip in the current node. * the current head/node is not changed from the user's point of view * even without using the --merge option, the backout revision is still easy to locate, as this is the tip * the merge is much more intuitive as diffs of the merge is right you are looking to backout
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     2
4365
46280c004f22 change tests to use simplemerge by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2614
diff changeset
     3
HGMERGE=true; export HGMERGE
46280c004f22 change tests to use simplemerge by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2614
diff changeset
     4
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     5
hg init basic
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     6
cd basic
4726
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4365
diff changeset
     7
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4365
diff changeset
     8
echo '# should complain'
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4365
diff changeset
     9
hg backout
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4365
diff changeset
    10
hg backout -r 0 0
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4365
diff changeset
    11
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4365
diff changeset
    12
echo '# basic operation'
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    13
echo a > a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    14
hg commit -d '0 0' -A -m a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    15
echo b >> a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    16
hg commit -d '1 0' -m b
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    17
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    18
hg backout -d '2 0' tip
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    19
cat a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    20
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    21
echo '# file that was removed is recreated'
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    22
cd ..
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    23
hg init remove
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    24
cd remove
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    25
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    26
echo content > a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    27
hg commit -d '0 0' -A -m a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    28
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    29
hg rm a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    30
hg commit -d '1 0' -m b
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    31
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    32
hg backout -d '2 0' --merge tip
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    33
cat a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    34
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    35
echo '# backout of backout is as if nothing happened'
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    36
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    37
hg backout -d '3 0' --merge tip
2186
1092533fd11c tests: fix compatibility on Solaris
TK Soh <teekaysoh@yahoo.com>
parents: 2158
diff changeset
    38
cat a 2>/dev/null || echo cat: a: No such file or directory
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    39
5568
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    40
echo '# across branch'
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    41
cd ..
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    42
hg init branch
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    43
cd branch
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    44
echo a > a
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    45
hg ci -Am0 -d '0 0'
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    46
echo b > b
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    47
hg ci -Am1 -d '0 0'
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    48
hg co -C 0
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    49
# should fail
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    50
hg backout -d '0 0' 1
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    51
echo c > c
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    52
hg ci -Am2 -d '0 0'
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    53
# should fail
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    54
hg backout -d '0 0' 1
de620356064f backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents: 4726
diff changeset
    55
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    56
echo '# backout with merge'
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    57
cd ..
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    58
hg init merge
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    59
cd merge
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    60
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    61
echo line 1 > a
6161
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 5568
diff changeset
    62
echo line 2 >> a
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    63
hg commit -d '0 0' -A -m a
6161
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 5568
diff changeset
    64
# remove line 1
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 5568
diff changeset
    65
echo line 2 > a
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    66
hg commit -d '1 0' -m b
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    67
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    68
echo line 3 >> a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    69
hg commit -d '2 0' -m c
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    70
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    71
hg backout --merge -d '3 0' 1
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    72
hg commit -d '4 0' -m d
6161
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 5568
diff changeset
    73
# check line 1 is back
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    74
cat a
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    75
2492
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    76
echo '# backout should not back out subsequent changesets'
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    77
hg init onecs
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    78
cd onecs
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    79
echo 1 > a
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    80
hg commit -d '0 0' -A -m a
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    81
echo 2 >> a
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    82
hg commit -d '1 0' -m b
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    83
echo 1 > b
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    84
hg commit -d '2 0' -A -m c
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    85
hg backout -d '3 0' 1
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    86
hg locate b
6161
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 5568
diff changeset
    87
hg update -C tip
bc1ba9124799 Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents: 5568
diff changeset
    88
hg locate b
2492
2f4addf56715 Test case for #295
Brendan Cully <brendan@kublai.com>
parents: 2186
diff changeset
    89
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    90
cd ..
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    91
hg init m
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    92
cd m
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    93
echo a > a
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    94
hg commit -d '0 0' -A -m a
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    95
echo b > b
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    96
hg commit -d '1 0' -A -m b
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    97
echo c > c
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    98
hg commit -d '2 0' -A -m b
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
    99
hg update 1
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   100
echo d > d
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   101
hg commit -d '3 0' -A -m c
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   102
hg merge 2
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   103
hg commit -d '4 0' -A -m d
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   104
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   105
echo '# backout of merge should fail'
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   106
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   107
hg backout 4
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   108
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   109
echo '# backout of merge with bad parent should fail'
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   110
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   111
hg backout --parent 0 4
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   112
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   113
echo '# backout of non-merge with parent should fail'
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   114
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   115
hg backout --parent 0 3
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   116
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   117
echo '# backout with valid parent should be ok'
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   118
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   119
hg backout -d '5 0' --parent 2 4
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   120
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   121
hg rollback
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   122
hg update -C
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   123
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   124
hg backout -d '6 0' --parent 3 4
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2492
diff changeset
   125
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   126
exit 0