1 | #!/bin/bash |
---|
2 | # ------------------------------------------------------------------------------ |
---|
3 | # (C) British Crown Copyright 2006-17 Met Office. |
---|
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 conflicts" (tree conflict mode). |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | check_svn_version |
---|
25 | tests 24 |
---|
26 | #------------------------------------------------------------------------------- |
---|
27 | setup |
---|
28 | init_repos |
---|
29 | init_branch ctrl $REPOS_URL |
---|
30 | init_branch_wc ed_ren $REPOS_URL |
---|
31 | export SVN_EDITOR="sed -i 1i\foo" |
---|
32 | # Set a special (null) fcm-graphic-merge diff editor. |
---|
33 | export FCM_GRAPHIC_MERGE=fcm-dummy-diff |
---|
34 | cd $TEST_DIR/wc |
---|
35 | #------------------------------------------------------------------------------- |
---|
36 | # Tests fcm conflicts: edit, rename, discard local |
---|
37 | TEST_KEY=$TEST_KEY_BASE-discard |
---|
38 | svn switch -q $ROOT_URL/branches/dev/Share/ctrl |
---|
39 | echo "Local contents (1)" >>pro/hello.pro |
---|
40 | svn commit -q -m "Modified local copy of conflict file" |
---|
41 | svn update -q |
---|
42 | svn switch -q $ROOT_URL/branches/dev/Share/ed_ren |
---|
43 | echo "Merge contents (1)" >>pro/hello.pro |
---|
44 | svn rename -q pro/hello.pro pro/hello.pro.renamed |
---|
45 | svn commit -q -m "Modified and renamed merge copy of conflict file" |
---|
46 | svn update -q |
---|
47 | echo "Merge contents (2)" >>pro/hello.pro.renamed |
---|
48 | svn commit -q -m "Modified the merge copy of renamed conflict file" |
---|
49 | svn update -q |
---|
50 | svn switch -q $ROOT_URL/branches/dev/Share/ctrl |
---|
51 | fcm merge --non-interactive $ROOT_URL/branches/dev/Share/ed_ren >/dev/null |
---|
52 | run_pass "$TEST_KEY" fcm conflicts <<__IN__ |
---|
53 | n |
---|
54 | __IN__ |
---|
55 | sed -i "/^Resolved conflicted state of 'pro\/hello.pro'$/d" $TEST_DIR/"$TEST_KEY.out" |
---|
56 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
57 | [info] pro/hello.pro: in tree conflict. |
---|
58 | Locally: edited. |
---|
59 | Externally: renamed to pro/hello.pro.renamed. |
---|
60 | Answer (y) to keep the file. |
---|
61 | Answer (n) to accept the external rename. |
---|
62 | You can then merge in changes. |
---|
63 | Keep the local version? |
---|
64 | Enter "y" or "n" (or just press <return> for "n") diff3 pro/hello.pro.renamed.working pro/hello.pro.renamed.merge-left.r1 pro/hello.pro.renamed.merge-right.r8 |
---|
65 | ==== |
---|
66 | 1:3c |
---|
67 | Local contents (1) |
---|
68 | 2:2a |
---|
69 | 3:3,4c |
---|
70 | Merge contents (1) |
---|
71 | Merge contents (2) |
---|
72 | D pro/hello.pro |
---|
73 | __OUT__ |
---|
74 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
75 | #------------------------------------------------------------------------------- |
---|
76 | # Tests fcm conflicts: edit, rename, discard local (status) |
---|
77 | TEST_KEY=$TEST_KEY_BASE-discard-status |
---|
78 | run_pass "$TEST_KEY" svn status --config-dir=$TEST_DIR/.subversion/ |
---|
79 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
80 | M . |
---|
81 | D pro/hello.pro |
---|
82 | A + pro/hello.pro.renamed |
---|
83 | __OUT__ |
---|
84 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
85 | #------------------------------------------------------------------------------- |
---|
86 | # Tests fcm conflicts: edit, rename, discard local (info) |
---|
87 | TEST_KEY=$TEST_KEY_BASE-discard-info |
---|
88 | run_pass "$TEST_KEY" svn info pro/hello.pro.renamed |
---|
89 | sed -i "/Date:\|Updated:\|UUID:\|Checksum\|Relative URL:\|Working Copy Root Path:/d" $TEST_DIR/"$TEST_KEY.out" |
---|
90 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
91 | Path: pro/hello.pro.renamed |
---|
92 | Name: hello.pro.renamed |
---|
93 | URL: $ROOT_URL/branches/dev/Share/ctrl/pro/hello.pro.renamed |
---|
94 | Repository Root: $REPOS_URL |
---|
95 | Revision: 8 |
---|
96 | Node Kind: file |
---|
97 | Schedule: add |
---|
98 | Copied From URL: $ROOT_URL/branches/dev/Share/ed_ren/pro/hello.pro.renamed |
---|
99 | Copied From Rev: 8 |
---|
100 | Last Changed Author: $LOGNAME |
---|
101 | Last Changed Rev: 8 |
---|
102 | |
---|
103 | __OUT__ |
---|
104 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
105 | #------------------------------------------------------------------------------- |
---|
106 | # Tests fcm conflicts: delete, rename, discard local (cat) |
---|
107 | TEST_KEY=$TEST_KEY_BASE-discard-cat |
---|
108 | run_pass "$TEST_KEY" cat pro/hello.pro.renamed |
---|
109 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
110 | PRO HELLO |
---|
111 | END |
---|
112 | Merge contents (1) |
---|
113 | Merge contents (2) |
---|
114 | __OUT__ |
---|
115 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
116 | #------------------------------------------------------------------------------- |
---|
117 | cd $TEST_DIR |
---|
118 | rm -rf $TEST_DIR/wc |
---|
119 | mkdir $TEST_DIR/wc |
---|
120 | svn checkout -q $ROOT_URL/branches/dev/Share/ctrl $TEST_DIR/wc |
---|
121 | cd $TEST_DIR/wc |
---|
122 | #------------------------------------------------------------------------------- |
---|
123 | # Tests fcm conflicts: edit, rename, keep local |
---|
124 | TEST_KEY=$TEST_KEY_BASE-keep |
---|
125 | fcm merge --non-interactive $ROOT_URL/branches/dev/Share/ed_ren >/dev/null |
---|
126 | run_pass "$TEST_KEY" fcm conflicts <<__IN__ |
---|
127 | y |
---|
128 | __IN__ |
---|
129 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
130 | [info] pro/hello.pro: in tree conflict. |
---|
131 | Locally: edited. |
---|
132 | Externally: renamed to pro/hello.pro.renamed. |
---|
133 | Answer (y) to keep the file. |
---|
134 | Answer (n) to accept the external rename. |
---|
135 | You can then merge in changes. |
---|
136 | Keep the local version? |
---|
137 | Enter "y" or "n" (or just press <return> for "n") diff3 pro/hello.pro.working pro/hello.pro.merge-left.r1 pro/hello.pro.merge-right.r8 |
---|
138 | ==== |
---|
139 | 1:3c |
---|
140 | Local contents (1) |
---|
141 | 2:2a |
---|
142 | 3:3,4c |
---|
143 | Merge contents (1) |
---|
144 | Merge contents (2) |
---|
145 | Reverted 'pro/hello.pro.renamed' |
---|
146 | Resolved conflicted state of 'pro/hello.pro' |
---|
147 | __OUT__ |
---|
148 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
149 | #------------------------------------------------------------------------------- |
---|
150 | # Tests fcm conflicts: edit, rename, keep local (status) |
---|
151 | TEST_KEY=$TEST_KEY_BASE-keep-status |
---|
152 | run_pass "$TEST_KEY" svn status --config-dir=$TEST_DIR/.subversion/ |
---|
153 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
154 | M . |
---|
155 | __OUT__ |
---|
156 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
157 | #------------------------------------------------------------------------------- |
---|
158 | # Tests fcm conflicts: edit, rename, keep local (info) |
---|
159 | TEST_KEY=$TEST_KEY_BASE-keep-info |
---|
160 | run_pass "$TEST_KEY" svn info pro/hello.pro |
---|
161 | sed -i "/Date:\|Updated:\|UUID:\|Checksum\|Relative URL:\|Working Copy Root Path:/d" $TEST_DIR/"$TEST_KEY.out" |
---|
162 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
163 | Path: pro/hello.pro |
---|
164 | Name: hello.pro |
---|
165 | URL: $ROOT_URL/branches/dev/Share/ctrl/pro/hello.pro |
---|
166 | Repository Root: $REPOS_URL |
---|
167 | Revision: 8 |
---|
168 | Node Kind: file |
---|
169 | Schedule: normal |
---|
170 | Last Changed Author: $LOGNAME |
---|
171 | Last Changed Rev: 6 |
---|
172 | |
---|
173 | __OUT__ |
---|
174 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
175 | #------------------------------------------------------------------------------- |
---|
176 | # Tests fcm conflicts: delete, rename, keep local (cat) |
---|
177 | TEST_KEY=$TEST_KEY_BASE-keep-cat |
---|
178 | run_pass "$TEST_KEY" cat pro/hello.pro |
---|
179 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
180 | PRO HELLO |
---|
181 | END |
---|
182 | Local contents (1) |
---|
183 | __OUT__ |
---|
184 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
185 | teardown |
---|
186 | #------------------------------------------------------------------------------- |
---|