tests: unify test-backout
authorMartin Geisler <mg@lazybytes.net>
Sat, 14 Aug 2010 02:28:53 +0200
changeset 11856 db969ebdebd9
parent 11855 054b0d9c3f0c
child 11857 9661514f85ae
tests: unify test-backout
tests/test-backout
tests/test-backout.out
tests/test-backout.t
--- a/tests/test-backout	Sat Aug 14 02:26:58 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-#!/bin/sh
-
-HGMERGE=true; export HGMERGE
-
-hg init basic
-cd basic
-
-echo '# should complain'
-hg backout
-hg backout -r 0 0
-
-echo '# basic operation'
-echo a > a
-hg commit -d '0 0' -A -m a
-echo b >> a
-hg commit -d '1 0' -m b
-
-hg backout -d '2 0' tip
-cat a
-
-echo '# file that was removed is recreated'
-cd ..
-hg init remove
-cd remove
-
-echo content > a
-hg commit -d '0 0' -A -m a
-
-hg rm a
-hg commit -d '1 0' -m b
-
-hg backout -d '2 0' --merge tip
-cat a
-
-echo '# backout of backout is as if nothing happened'
-
-hg backout -d '3 0' --merge tip
-cat a 2>/dev/null || echo cat: a: No such file or directory
-
-echo '# across branch'
-cd ..
-hg init branch
-cd branch
-echo a > a
-hg ci -Am0
-echo b > b
-hg ci -Am1
-hg co -C 0
-# should fail
-hg backout 1
-echo c > c
-hg ci -Am2
-# should fail
-hg backout 1
-
-echo '# backout with merge'
-cd ..
-hg init merge
-cd merge
-
-echo line 1 > a
-echo line 2 >> a
-hg commit -d '0 0' -A -m a
-# remove line 1
-echo line 2 > a
-hg commit -d '1 0' -m b
-
-echo line 3 >> a
-hg commit -d '2 0' -m c
-
-hg backout --merge -d '3 0' 1
-hg commit -d '4 0' -m d
-# check line 1 is back
-cat a
-
-echo '# backout should not back out subsequent changesets'
-hg init onecs
-cd onecs
-echo 1 > a
-hg commit -d '0 0' -A -m a
-echo 2 >> a
-hg commit -d '1 0' -m b
-echo 1 > b
-hg commit -d '2 0' -A -m c
-hg backout -d '3 0' 1
-hg locate b
-hg update -C tip
-hg locate b
-
-cd ..
-hg init m
-cd m
-echo a > a
-hg commit -d '0 0' -A -m a
-echo b > b
-hg commit -d '1 0' -A -m b
-echo c > c
-hg commit -d '2 0' -A -m b
-hg update 1
-echo d > d
-hg commit -d '3 0' -A -m c
-hg merge 2
-hg commit -d '4 0' -A -m d
-
-echo '# backout of merge should fail'
-
-hg backout 4
-
-echo '# backout of merge with bad parent should fail'
-
-hg backout --parent 0 4
-
-echo '# backout of non-merge with parent should fail'
-
-hg backout --parent 0 3
-
-echo '# backout with valid parent should be ok'
-
-hg backout -d '5 0' --parent 2 4
-
-hg rollback
-hg update -C
-
-hg backout -d '6 0' --parent 3 4
-
-cd ..
-
-echo '# named branches'
-
-hg init named_branches
-cd named_branches
-
-echo default > default
-hg ci -d '0 0' -Am default
-hg branch branch1
-echo branch1 > file1
-hg ci -d '1 0' -Am file1
-hg branch branch2
-echo branch2 > file2
-hg ci -d '2 0' -Am file2
-hg backout -d '3 0' -r 1 -m 'backout on branch1'
-# XXX maybe backout shouldn't suggest a merge here as it is a different branch?
-
-echo '% on branch2 with branch1 not merged, so file1 should still exist:'
-hg id
-hg st -A
-
-echo '% on branch2 with branch1 merged, so file1 should be gone:'
-hg merge
-hg ci -d '4 0' -m 'merge backout of branch1'
-hg id
-hg st -A
-
-echo '% on branch1, so no file1 and file2:'
-hg co -C branch1
-hg id
-hg st -A
-
-exit 0
--- a/tests/test-backout.out	Sat Aug 14 02:26:58 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-# should complain
-abort: please specify a revision to backout
-abort: please specify just one revision
-# basic operation
-adding a
-reverting a
-changeset 2:2929462c3dff backs out changeset 1:a820f4f40a57
-a
-# file that was removed is recreated
-adding a
-adding a
-changeset 2:de31bdc76c0d backs out changeset 1:76862dcce372
-content
-# backout of backout is as if nothing happened
-removing a
-changeset 3:7f6d0f120113 backs out changeset 2:de31bdc76c0d
-cat: a: No such file or directory
-# across branch
-adding a
-adding b
-0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-abort: cannot backout change on a different branch
-adding c
-created new head
-abort: cannot backout change on a different branch
-# backout with merge
-adding a
-reverting a
-created new head
-changeset 3:26b8ccb9ad91 backs out changeset 1:5a50a024c182
-merging with changeset 3:26b8ccb9ad91
-merging a
-0 files updated, 1 files merged, 0 files removed, 0 files unresolved
-(branch merge, don't forget to commit)
-line 1
-line 2
-line 3
-# backout should not back out subsequent changesets
-adding a
-adding b
-reverting a
-created new head
-changeset 3:3202beb76721 backs out changeset 1:22bca4c721e5
-the backout changeset is a new head - do not forget to merge
-(use "backout --merge" if you want to auto-merge)
-b
-1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-adding a
-adding b
-adding c
-0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-adding d
-created new head
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-(branch merge, don't forget to commit)
-# backout of merge should fail
-abort: cannot backout a merge changeset without --parent
-# backout of merge with bad parent should fail
-abort: cb9a9f314b8b is not a parent of b2f3bb92043e
-# backout of non-merge with parent should fail
-abort: cannot use --parent on non-merge changeset
-# backout with valid parent should be ok
-removing d
-changeset 5:10e5328c8435 backs out changeset 4:b2f3bb92043e
-rolling back to revision 4 (undo commit)
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-removing c
-changeset 5:033590168430 backs out changeset 4:b2f3bb92043e
-# named branches
-adding default
-marked working directory as branch branch1
-adding file1
-marked working directory as branch branch2
-adding file2
-removing file1
-created new head
-changeset 3:d4e8f6db59fb backs out changeset 1:bf1602f437f3
-the backout changeset is a new head - do not forget to merge
-(use "backout --merge" if you want to auto-merge)
-% on branch2 with branch1 not merged, so file1 should still exist:
-45bbcd363bf0 (branch2)
-C default
-C file1
-C file2
-% on branch2 with branch1 merged, so file1 should be gone:
-0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-(branch merge, don't forget to commit)
-22149cdde76d (branch2) tip
-C default
-C file2
-% on branch1, so no file1 and file2:
-1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-bf1602f437f3 (branch1)
-C default
-C file1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-backout.t	Sat Aug 14 02:28:53 2010 +0200
@@ -0,0 +1,255 @@
+  $ HGMERGE=true; export HGMERGE
+
+  $ hg init basic
+  $ cd basic
+
+# should complain
+
+  $ hg backout
+  abort: please specify a revision to backout
+  $ hg backout -r 0 0
+  abort: please specify just one revision
+
+# basic operation
+
+  $ echo a > a
+  $ hg commit -d '0 0' -A -m a
+  adding a
+  $ echo b >> a
+  $ hg commit -d '1 0' -m b
+
+  $ hg backout -d '2 0' tip
+  reverting a
+  changeset 2:2929462c3dff backs out changeset 1:a820f4f40a57
+  $ cat a
+  a
+
+# file that was removed is recreated
+
+  $ cd ..
+  $ hg init remove
+  $ cd remove
+
+  $ echo content > a
+  $ hg commit -d '0 0' -A -m a
+  adding a
+
+  $ hg rm a
+  $ hg commit -d '1 0' -m b
+
+  $ hg backout -d '2 0' --merge tip
+  adding a
+  changeset 2:de31bdc76c0d backs out changeset 1:76862dcce372
+  $ cat a
+  content
+
+# backout of backout is as if nothing happened
+
+  $ hg backout -d '3 0' --merge tip
+  removing a
+  changeset 3:7f6d0f120113 backs out changeset 2:de31bdc76c0d
+  $ cat a 2>/dev/null || echo cat: a: No such file or directory
+  cat: a: No such file or directory
+
+# across branch
+
+  $ cd ..
+  $ hg init branch
+  $ cd branch
+  $ echo a > a
+  $ hg ci -Am0
+  adding a
+  $ echo b > b
+  $ hg ci -Am1
+  adding b
+  $ hg co -C 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+
+should fail
+
+  $ hg backout 1
+  abort: cannot backout change on a different branch
+  $ echo c > c
+  $ hg ci -Am2
+  adding c
+  created new head
+
+should fail
+
+  $ hg backout 1
+  abort: cannot backout change on a different branch
+
+# backout with merge
+
+  $ cd ..
+  $ hg init merge
+  $ cd merge
+
+  $ echo line 1 > a
+  $ echo line 2 >> a
+  $ hg commit -d '0 0' -A -m a
+  adding a
+
+remove line 1
+
+  $ echo line 2 > a
+  $ hg commit -d '1 0' -m b
+
+  $ echo line 3 >> a
+  $ hg commit -d '2 0' -m c
+
+  $ hg backout --merge -d '3 0' 1
+  reverting a
+  created new head
+  changeset 3:26b8ccb9ad91 backs out changeset 1:5a50a024c182
+  merging with changeset 3:26b8ccb9ad91
+  merging a
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg commit -d '4 0' -m d
+
+check line 1 is back
+
+  $ cat a
+  line 1
+  line 2
+  line 3
+
+# backout should not back out subsequent changesets
+
+  $ hg init onecs
+  $ cd onecs
+  $ echo 1 > a
+  $ hg commit -d '0 0' -A -m a
+  adding a
+  $ echo 2 >> a
+  $ hg commit -d '1 0' -m b
+  $ echo 1 > b
+  $ hg commit -d '2 0' -A -m c
+  adding b
+  $ hg backout -d '3 0' 1
+  reverting a
+  created new head
+  changeset 3:3202beb76721 backs out changeset 1:22bca4c721e5
+  the backout changeset is a new head - do not forget to merge
+  (use "backout --merge" if you want to auto-merge)
+  $ hg locate b
+  b
+  $ hg update -C tip
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg locate b
+
+  $ cd ..
+  $ hg init m
+  $ cd m
+  $ echo a > a
+  $ hg commit -d '0 0' -A -m a
+  adding a
+  $ echo b > b
+  $ hg commit -d '1 0' -A -m b
+  adding b
+  $ echo c > c
+  $ hg commit -d '2 0' -A -m b
+  adding c
+  $ hg update 1
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo d > d
+  $ hg commit -d '3 0' -A -m c
+  adding d
+  created new head
+  $ hg merge 2
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg commit -d '4 0' -A -m d
+
+# backout of merge should fail
+
+  $ hg backout 4
+  abort: cannot backout a merge changeset without --parent
+
+# backout of merge with bad parent should fail
+
+  $ hg backout --parent 0 4
+  abort: cb9a9f314b8b is not a parent of b2f3bb92043e
+
+# backout of non-merge with parent should fail
+
+  $ hg backout --parent 0 3
+  abort: cannot use --parent on non-merge changeset
+
+# backout with valid parent should be ok
+
+  $ hg backout -d '5 0' --parent 2 4
+  removing d
+  changeset 5:10e5328c8435 backs out changeset 4:b2f3bb92043e
+
+  $ hg rollback
+  rolling back to revision 4 (undo commit)
+  $ hg update -C
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg backout -d '6 0' --parent 3 4
+  removing c
+  changeset 5:033590168430 backs out changeset 4:b2f3bb92043e
+
+  $ cd ..
+
+# named branches
+
+  $ hg init named_branches
+  $ cd named_branches
+
+  $ echo default > default
+  $ hg ci -d '0 0' -Am default
+  adding default
+  $ hg branch branch1
+  marked working directory as branch branch1
+  $ echo branch1 > file1
+  $ hg ci -d '1 0' -Am file1
+  adding file1
+  $ hg branch branch2
+  marked working directory as branch branch2
+  $ echo branch2 > file2
+  $ hg ci -d '2 0' -Am file2
+  adding file2
+  $ hg backout -d '3 0' -r 1 -m 'backout on branch1'
+  removing file1
+  created new head
+  changeset 3:d4e8f6db59fb backs out changeset 1:bf1602f437f3
+  the backout changeset is a new head - do not forget to merge
+  (use "backout --merge" if you want to auto-merge)
+
+XXX maybe backout shouldn't suggest a merge here as it is a different branch?
+
+on branch2 with branch1 not merged, so file1 should still exist:
+
+  $ hg id
+  45bbcd363bf0 (branch2)
+  $ hg st -A
+  C default
+  C file1
+  C file2
+
+on branch2 with branch1 merged, so file1 should be gone:
+
+  $ hg merge
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -d '4 0' -m 'merge backout of branch1'
+  $ hg id
+  22149cdde76d (branch2) tip
+  $ hg st -A
+  C default
+  C file2
+
+on branch1, so no file1 and file2:
+
+  $ hg co -C branch1
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg id
+  bf1602f437f3 (branch1)
+  $ hg st -A
+  C default
+  C file1
+
+  $ exit 0