1 | #!/bin/bash |
---|
2 | # ------------------------------------------------------------------------------ |
---|
3 | # Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
---|
4 | # |
---|
5 | # This file is part of FCM, tools for managing and building source code. |
---|
6 | # |
---|
7 | # FCM is free software: you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation, either version 3 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # FCM is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | # ------------------------------------------------------------------------------ |
---|
20 | # Basic tests for "fcm merge --reverse". |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . "$(dirname "$0")/test_header" |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | check_svn_version |
---|
25 | tests 13 |
---|
26 | #------------------------------------------------------------------------------- |
---|
27 | svnadmin create 'foo' |
---|
28 | URL_FOO="file://${PWD}/foo" |
---|
29 | svn mkdir -q -m"season greetings" --no-auth-cache "${URL_FOO}/greet" |
---|
30 | echo 'Merry Xmas' >'xmas.txt' |
---|
31 | echo 'Happy New Year' >'new-year.txt' |
---|
32 | for NAME in 'xmas.txt' 'new-year.txt'; do |
---|
33 | svn import -q -m"import ${NAME}" --no-auth-cache \ |
---|
34 | "${NAME}" "${URL_FOO}/greet/${NAME}" |
---|
35 | done |
---|
36 | svn mkdir -q -m"hello world" --no-auth-cache --parents "${URL_FOO}/hello/trunk" |
---|
37 | svn co -q "${URL_FOO}/hello/trunk" 'hello-wc' |
---|
38 | cat >'hello-wc/world.txt' <<'__TXT__' |
---|
39 | Hello Mercury! |
---|
40 | Hello Venus! |
---|
41 | Hollow Earth! |
---|
42 | Hello Mars! |
---|
43 | __TXT__ |
---|
44 | svn add -q 'hello-wc/world.txt' |
---|
45 | svn ci -q -m'hollow worlds' --no-auth-cache 'hello-wc' |
---|
46 | cat >'hello-wc/world.txt' <<'__TXT__' |
---|
47 | Hello Mercury! |
---|
48 | Hello Venus! |
---|
49 | Hello Earth! |
---|
50 | Hello Mars! |
---|
51 | __TXT__ |
---|
52 | svn ci -q -m'hello worlds' --no-auth-cache 'hello-wc' |
---|
53 | rm -fr 'hello-wc' |
---|
54 | #------------------------------------------------------------------------------- |
---|
55 | TEST_KEY="${TEST_KEY_BASE}-r3" |
---|
56 | svn co -q "${URL_FOO}/greet" 'greet-wc' |
---|
57 | cd 'greet-wc' |
---|
58 | run_pass "${TEST_KEY}" fcm merge --reverse --non-interactive |
---|
59 | cd .. |
---|
60 | svn status 'greet-wc' >"${TEST_KEY}.status" |
---|
61 | file_cmp "${TEST_KEY}.status" "${TEST_KEY}.status" <<'__STATUS__' |
---|
62 | D greet-wc/new-year.txt |
---|
63 | __STATUS__ |
---|
64 | file_cmp "${TEST_KEY}.message" 'greet-wc/#commit_message#' <<'__MESSAGE__' |
---|
65 | --FCM message (will be inserted automatically)-- |
---|
66 | Reversed r3 of /greet |
---|
67 | |
---|
68 | __MESSAGE__ |
---|
69 | rm -rf 'greet-wc' |
---|
70 | #------------------------------------------------------------------------------- |
---|
71 | TEST_KEY="${TEST_KEY_BASE}-r2" |
---|
72 | svn co -q "${URL_FOO}/greet" 'greet-wc' |
---|
73 | cd 'greet-wc' |
---|
74 | run_pass "${TEST_KEY}" fcm merge --reverse -r 2 --non-interactive |
---|
75 | cd .. |
---|
76 | |
---|
77 | svn status 'greet-wc' >"${TEST_KEY}.status" |
---|
78 | file_cmp "${TEST_KEY}.status" "${TEST_KEY}.status" <<'__STATUS__' |
---|
79 | D greet-wc/xmas.txt |
---|
80 | __STATUS__ |
---|
81 | file_cmp "${TEST_KEY}.message" 'greet-wc/#commit_message#' <<'__MESSAGE__' |
---|
82 | --FCM message (will be inserted automatically)-- |
---|
83 | Reversed r2 of /greet |
---|
84 | |
---|
85 | __MESSAGE__ |
---|
86 | rm -rf 'greet-wc' |
---|
87 | #------------------------------------------------------------------------------- |
---|
88 | TEST_KEY="${TEST_KEY_BASE}-r2-r3" |
---|
89 | svn co -q "${URL_FOO}/greet" 'greet-wc' |
---|
90 | cd 'greet-wc' |
---|
91 | run_pass "${TEST_KEY}" fcm merge --reverse -r 3:1 --non-interactive |
---|
92 | cd .. |
---|
93 | |
---|
94 | svn status 'greet-wc' | sort >"${TEST_KEY}.status" |
---|
95 | file_cmp "${TEST_KEY}.status" "${TEST_KEY}.status" <<'__STATUS__' |
---|
96 | D greet-wc/new-year.txt |
---|
97 | D greet-wc/xmas.txt |
---|
98 | __STATUS__ |
---|
99 | file_cmp "${TEST_KEY}.message" 'greet-wc/#commit_message#' <<'__MESSAGE__' |
---|
100 | --FCM message (will be inserted automatically)-- |
---|
101 | Reversed r3:1 of /greet |
---|
102 | |
---|
103 | __MESSAGE__ |
---|
104 | rm -rf 'greet-wc' |
---|
105 | #------------------------------------------------------------------------------- |
---|
106 | TEST_KEY="${TEST_KEY_BASE}-r6" |
---|
107 | svn co -q "${URL_FOO}/hello/trunk" 'hello-wc' |
---|
108 | cd 'hello-wc' |
---|
109 | run_pass "${TEST_KEY}" fcm merge --reverse --non-interactive |
---|
110 | cd .. |
---|
111 | svn status 'hello-wc' >"${TEST_KEY}.status" |
---|
112 | file_cmp "${TEST_KEY}.status" "${TEST_KEY}.status" <<'__STATUS__' |
---|
113 | M hello-wc/world.txt |
---|
114 | __STATUS__ |
---|
115 | svn diff 'hello-wc' >"${TEST_KEY}.diff" |
---|
116 | file_cmp "${TEST_KEY}.diff" "${TEST_KEY}.diff" <<'__DIFF__' |
---|
117 | Index: hello-wc/world.txt |
---|
118 | =================================================================== |
---|
119 | --- hello-wc/world.txt (revision 6) |
---|
120 | +++ hello-wc/world.txt (working copy) |
---|
121 | @@ -1,4 +1,4 @@ |
---|
122 | Hello Mercury! |
---|
123 | Hello Venus! |
---|
124 | -Hello Earth! |
---|
125 | +Hollow Earth! |
---|
126 | Hello Mars! |
---|
127 | __DIFF__ |
---|
128 | file_cmp "${TEST_KEY}.message" 'hello-wc/#commit_message#' <<'__MESSAGE__' |
---|
129 | --FCM message (will be inserted automatically)-- |
---|
130 | Reversed r6 of /hello/trunk |
---|
131 | |
---|
132 | __MESSAGE__ |
---|
133 | rm -rf 'hello-wc' |
---|
134 | #------------------------------------------------------------------------------- |
---|
135 | exit |
---|