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 conflicts" (tree conflict mode). |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | check_svn_version |
---|
25 | [[ $SVN_VERSION == "1.13.0" ]] && skip_all "Tests do not work with svn 1.13.0" |
---|
26 | tests 18 |
---|
27 | #------------------------------------------------------------------------------- |
---|
28 | setup |
---|
29 | init_repos |
---|
30 | init_branch ctrl $REPOS_URL |
---|
31 | init_branch_wc del_ed $REPOS_URL |
---|
32 | export SVN_EDITOR="sed -i 1i\foo" |
---|
33 | # Set a special (null) fcm-graphic-merge diff editor. |
---|
34 | export FCM_GRAPHIC_MERGE=fcm-dummy-diff |
---|
35 | cd $TEST_DIR/wc |
---|
36 | #------------------------------------------------------------------------------- |
---|
37 | # Tests fcm conflicts: delete, edit, discard local |
---|
38 | TEST_KEY=$TEST_KEY_BASE-discard |
---|
39 | svn switch -q $ROOT_URL/branches/dev/Share/ctrl |
---|
40 | svn delete -q pro/hello.pro |
---|
41 | svn commit -q -m "Deleted local copy of conflict file" |
---|
42 | svn update -q |
---|
43 | svn switch -q $ROOT_URL/branches/dev/Share/del_ed |
---|
44 | echo "Merge contents (1)" >>pro/hello.pro |
---|
45 | svn commit -q -m "Modified merge copy of conflict file" |
---|
46 | svn update -q |
---|
47 | svn switch -q $ROOT_URL/branches/dev/Share/ctrl |
---|
48 | fcm merge --non-interactive $ROOT_URL/branches/dev/Share/del_ed >/dev/null |
---|
49 | run_pass "$TEST_KEY" fcm conflicts <<__IN__ |
---|
50 | n |
---|
51 | __IN__ |
---|
52 | file_cmp_filtered "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
53 | [info] pro/hello.pro: in tree conflict. |
---|
54 | Locally: deleted. |
---|
55 | Externally: edited. |
---|
56 | Answer (y) to accept the local delete. |
---|
57 | Answer (n) to keep the file. |
---|
58 | Keep the local version? |
---|
59 | Enter "y" or "n" (or just press <return> for "n") A pro/hello.pro |
---|
60 | #IF SVN1.8/9 Resolved conflicted state of 'pro/hello.pro' |
---|
61 | #IF SVN1.10/14 Tree conflict at 'pro/hello.pro' marked as resolved. |
---|
62 | __OUT__ |
---|
63 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
64 | #------------------------------------------------------------------------------- |
---|
65 | # Tests fcm conflicts: delete, edit, discard local (status) |
---|
66 | TEST_KEY=$TEST_KEY_BASE-discard-status |
---|
67 | run_pass "$TEST_KEY" svn status --config-dir=$TEST_DIR/.subversion/ |
---|
68 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
69 | M . |
---|
70 | A + pro/hello.pro |
---|
71 | __OUT__ |
---|
72 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
73 | #------------------------------------------------------------------------------- |
---|
74 | # Tests fcm conflicts: delete, edit, discard local (info) |
---|
75 | TEST_KEY=$TEST_KEY_BASE-discard-info |
---|
76 | run_pass "$TEST_KEY" svn info pro/hello.pro |
---|
77 | sed -i "/Date:\|Updated:\|UUID:\|Checksum\|Relative URL:\|Working Copy Root Path:/d" $TEST_DIR/"$TEST_KEY.out" |
---|
78 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
79 | Path: pro/hello.pro |
---|
80 | Name: hello.pro |
---|
81 | URL: $ROOT_URL/branches/dev/Share/ctrl/pro/hello.pro |
---|
82 | Repository Root: $REPOS_URL |
---|
83 | Revision: 7 |
---|
84 | Node Kind: file |
---|
85 | Schedule: add |
---|
86 | Copied From URL: $ROOT_URL/branches/dev/Share/del_ed/pro/hello.pro |
---|
87 | Copied From Rev: 7 |
---|
88 | Last Changed Author: $LOGNAME |
---|
89 | Last Changed Rev: 7 |
---|
90 | |
---|
91 | __OUT__ |
---|
92 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
93 | #------------------------------------------------------------------------------- |
---|
94 | # Tests fcm conflicts: delete, edit, discard local (cat) |
---|
95 | TEST_KEY=$TEST_KEY_BASE-discard-cat |
---|
96 | run_pass "$TEST_KEY" cat pro/hello.pro |
---|
97 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
98 | PRO HELLO |
---|
99 | END |
---|
100 | Merge contents (1) |
---|
101 | __OUT__ |
---|
102 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
103 | #------------------------------------------------------------------------------- |
---|
104 | cd $TEST_DIR |
---|
105 | rm -rf $TEST_DIR/wc |
---|
106 | mkdir $TEST_DIR/wc |
---|
107 | svn checkout -q $ROOT_URL/branches/dev/Share/ctrl $TEST_DIR/wc |
---|
108 | cd $TEST_DIR/wc |
---|
109 | #------------------------------------------------------------------------------- |
---|
110 | # Tests fcm conflicts: delete, edit, keep local |
---|
111 | TEST_KEY=$TEST_KEY_BASE-keep |
---|
112 | fcm merge --non-interactive $ROOT_URL/branches/dev/Share/del_ed >/dev/null |
---|
113 | run_pass "$TEST_KEY" fcm conflicts <<__IN__ |
---|
114 | y |
---|
115 | __IN__ |
---|
116 | file_cmp_filtered "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
117 | [info] pro/hello.pro: in tree conflict. |
---|
118 | Locally: deleted. |
---|
119 | Externally: edited. |
---|
120 | Answer (y) to accept the local delete. |
---|
121 | Answer (n) to keep the file. |
---|
122 | Keep the local version? |
---|
123 | #IF SVN1.8/9 Enter "y" or "n" (or just press <return> for "n") Resolved conflicted state of 'pro/hello.pro' |
---|
124 | #IF SVN1.10/14 Enter "y" or "n" (or just press <return> for "n") Tree conflict at 'pro/hello.pro' marked as resolved. |
---|
125 | __OUT__ |
---|
126 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
127 | #------------------------------------------------------------------------------- |
---|
128 | # Tests fcm conflicts: delete, edit, keep local (status) |
---|
129 | TEST_KEY=$TEST_KEY_BASE-keep-status |
---|
130 | run_pass "$TEST_KEY" svn status --config-dir=$TEST_DIR/.subversion/ |
---|
131 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
132 | M . |
---|
133 | __OUT__ |
---|
134 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
135 | teardown |
---|
136 | #------------------------------------------------------------------------------- |
---|