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 18 |
---|
26 | #------------------------------------------------------------------------------- |
---|
27 | setup |
---|
28 | init_repos |
---|
29 | init_branch ctrl $REPOS_URL |
---|
30 | init_branch_wc ren_ed $REPOS_URL |
---|
31 | # Set a special (null) fcm-graphic-merge diff editor. |
---|
32 | export FCM_GRAPHIC_MERGE=fcm-dummy-diff |
---|
33 | cd $TEST_DIR/wc |
---|
34 | #------------------------------------------------------------------------------- |
---|
35 | # Tests fcm conflicts: rename, edit, discard local |
---|
36 | TEST_KEY=$TEST_KEY_BASE-discard |
---|
37 | svn switch -q $ROOT_URL/branches/dev/Share/ctrl |
---|
38 | svn rename -q pro/hello.pro pro/hello.pro.renamed |
---|
39 | svn commit -q -m "Renamed conflict file (local)" |
---|
40 | svn update -q |
---|
41 | echo "Local contents (1)" >>pro/hello.pro.renamed |
---|
42 | svn commit -q -m "Modified conflict file (local)" |
---|
43 | svn update -q |
---|
44 | svn switch -q $ROOT_URL/branches/dev/Share/ren_ed |
---|
45 | echo "Merge contents (1)" >>pro/hello.pro |
---|
46 | svn commit -q -m "Modified conflict file (merge)" |
---|
47 | svn update -q |
---|
48 | svn switch -q $ROOT_URL/branches/dev/Share/ctrl |
---|
49 | fcm merge --non-interactive $ROOT_URL/branches/dev/Share/ren_ed >/dev/null |
---|
50 | run_pass "$TEST_KEY" fcm conflicts <<__IN__ |
---|
51 | n |
---|
52 | __IN__ |
---|
53 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
54 | [info] pro/hello.pro: in tree conflict. |
---|
55 | Locally: renamed to pro/hello.pro.renamed. |
---|
56 | Externally: edited. |
---|
57 | Answer (y) to accept the local rename. |
---|
58 | Answer (n) to keep the file. |
---|
59 | You can then merge in changes. |
---|
60 | Keep the local version? |
---|
61 | 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 |
---|
62 | ==== |
---|
63 | 1:3c |
---|
64 | Local contents (1) |
---|
65 | 2:2a |
---|
66 | 3:3c |
---|
67 | Merge contents (1) |
---|
68 | A pro/hello.pro |
---|
69 | D pro/hello.pro.renamed |
---|
70 | Resolved conflicted state of 'pro/hello.pro' |
---|
71 | __OUT__ |
---|
72 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
73 | #------------------------------------------------------------------------------- |
---|
74 | # Tests fcm conflicts: rename, edit, discard local (status) |
---|
75 | TEST_KEY=$TEST_KEY_BASE-discard-status |
---|
76 | run_pass "$TEST_KEY" svn status --config-dir=$TEST_DIR/.subversion/ |
---|
77 | sed -i "/^ \{8\}> moved /d" $TEST_DIR/"$TEST_KEY.out" |
---|
78 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
79 | M . |
---|
80 | A + pro/hello.pro |
---|
81 | D pro/hello.pro.renamed |
---|
82 | __OUT__ |
---|
83 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
84 | #------------------------------------------------------------------------------- |
---|
85 | # Tests fcm conflicts: rename, edit, discard local (cat) |
---|
86 | TEST_KEY=$TEST_KEY_BASE-discard-cat |
---|
87 | run_pass "$TEST_KEY" cat pro/hello.pro |
---|
88 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
89 | PRO HELLO |
---|
90 | END |
---|
91 | Local contents (1) |
---|
92 | __OUT__ |
---|
93 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
94 | #------------------------------------------------------------------------------- |
---|
95 | cd $TEST_DIR |
---|
96 | rm -rf $TEST_DIR/wc |
---|
97 | mkdir $TEST_DIR/wc |
---|
98 | svn checkout -q $ROOT_URL/branches/dev/Share/ctrl $TEST_DIR/wc |
---|
99 | cd $TEST_DIR/wc |
---|
100 | #------------------------------------------------------------------------------- |
---|
101 | # Tests fcm conflicts: rename, edit, keep local |
---|
102 | TEST_KEY=$TEST_KEY_BASE-keep |
---|
103 | fcm merge --non-interactive $ROOT_URL/branches/dev/Share/ren_ed >/dev/null |
---|
104 | run_pass "$TEST_KEY" fcm conflicts <<__IN__ |
---|
105 | y |
---|
106 | __IN__ |
---|
107 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
108 | [info] pro/hello.pro: in tree conflict. |
---|
109 | Locally: renamed to pro/hello.pro.renamed. |
---|
110 | Externally: edited. |
---|
111 | Answer (y) to accept the local rename. |
---|
112 | Answer (n) to keep the file. |
---|
113 | You can then merge in changes. |
---|
114 | Keep the local version? |
---|
115 | 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 |
---|
116 | ==== |
---|
117 | 1:3c |
---|
118 | Local contents (1) |
---|
119 | 2:2a |
---|
120 | 3:3c |
---|
121 | Merge contents (1) |
---|
122 | Resolved conflicted state of 'pro/hello.pro' |
---|
123 | __OUT__ |
---|
124 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
125 | #------------------------------------------------------------------------------- |
---|
126 | # Tests fcm conflicts: rename, edit, keep local (status) |
---|
127 | TEST_KEY=$TEST_KEY_BASE-keep-status |
---|
128 | run_pass "$TEST_KEY" svn status --config-dir=$TEST_DIR/.subversion/ |
---|
129 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
130 | M . |
---|
131 | __OUT__ |
---|
132 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
133 | #------------------------------------------------------------------------------- |
---|
134 | # Tests fcm conflicts: rename, edit, keep local (cat) |
---|
135 | TEST_KEY=$TEST_KEY_BASE-keep-cat |
---|
136 | run_pass "$TEST_KEY" cat pro/hello.pro.renamed |
---|
137 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
138 | PRO HELLO |
---|
139 | END |
---|
140 | Local contents (1) |
---|
141 | __OUT__ |
---|
142 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
143 | teardown |
---|