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 ed_del $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, delete, 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_del |
---|
43 | svn delete -q pro/hello.pro |
---|
44 | svn commit -q -m "Deleted merge copy of conflict file" |
---|
45 | svn update -q |
---|
46 | svn switch -q $ROOT_URL/branches/dev/Share/ctrl |
---|
47 | fcm merge --non-interactive $ROOT_URL/branches/dev/Share/ed_del >/dev/null |
---|
48 | run_pass "$TEST_KEY" fcm conflicts <<__IN__ |
---|
49 | n |
---|
50 | __IN__ |
---|
51 | sed -i "/^Resolved conflicted state of 'pro\/hello.pro'$/d" $TEST_DIR/"$TEST_KEY.out" |
---|
52 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
53 | [info] pro/hello.pro: in tree conflict. |
---|
54 | Locally: edited. |
---|
55 | Externally: deleted. |
---|
56 | Answer (y) to keep the file. |
---|
57 | Answer (n) to accept the external delete. |
---|
58 | Keep the local version? |
---|
59 | Enter "y" or "n" (or just press <return> for "n") D pro/hello.pro |
---|
60 | __OUT__ |
---|
61 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
62 | #------------------------------------------------------------------------------- |
---|
63 | # Tests fcm conflicts: edit, delete, discard local (status) |
---|
64 | TEST_KEY=$TEST_KEY_BASE-discard-status |
---|
65 | run_pass "$TEST_KEY" svn status --config-dir=$TEST_DIR/.subversion/ |
---|
66 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
67 | M . |
---|
68 | D pro/hello.pro |
---|
69 | __OUT__ |
---|
70 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
71 | #------------------------------------------------------------------------------- |
---|
72 | # Tests fcm conflicts: edit, delete, discard local (info) |
---|
73 | TEST_KEY=$TEST_KEY_BASE-discard-info |
---|
74 | run_pass "$TEST_KEY" svn info pro/hello.pro |
---|
75 | sed -i "/Date:\|Updated:\|UUID:\|Checksum\|Relative URL:\|Working Copy Root Path:/d" $TEST_DIR/$TEST_KEY.out |
---|
76 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
77 | Path: pro/hello.pro |
---|
78 | Name: hello.pro |
---|
79 | URL: $ROOT_URL/branches/dev/Share/ctrl/pro/hello.pro |
---|
80 | Repository Root: $REPOS_URL |
---|
81 | Revision: 7 |
---|
82 | Node Kind: file |
---|
83 | Schedule: delete |
---|
84 | Last Changed Author: $LOGNAME |
---|
85 | Last Changed Rev: 6 |
---|
86 | |
---|
87 | __OUT__ |
---|
88 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
89 | #------------------------------------------------------------------------------- |
---|
90 | cd $TEST_DIR |
---|
91 | rm -rf $TEST_DIR/wc |
---|
92 | mkdir $TEST_DIR/wc |
---|
93 | svn checkout -q $ROOT_URL/branches/dev/Share/ctrl $TEST_DIR/wc |
---|
94 | cd $TEST_DIR/wc |
---|
95 | #------------------------------------------------------------------------------- |
---|
96 | # Tests fcm conflicts: edit, delete, keep local |
---|
97 | TEST_KEY=$TEST_KEY_BASE-keep |
---|
98 | fcm merge --non-interactive $ROOT_URL/branches/dev/Share/ed_del >/dev/null |
---|
99 | run_pass "$TEST_KEY" fcm conflicts <<__IN__ |
---|
100 | y |
---|
101 | __IN__ |
---|
102 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
103 | [info] pro/hello.pro: in tree conflict. |
---|
104 | Locally: edited. |
---|
105 | Externally: deleted. |
---|
106 | Answer (y) to keep the file. |
---|
107 | Answer (n) to accept the external delete. |
---|
108 | Keep the local version? |
---|
109 | Enter "y" or "n" (or just press <return> for "n") Resolved conflicted state of 'pro/hello.pro' |
---|
110 | __OUT__ |
---|
111 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
112 | #------------------------------------------------------------------------------- |
---|
113 | # Tests fcm conflicts: edit, delete, keep local (status) |
---|
114 | TEST_KEY=$TEST_KEY_BASE-keep-status |
---|
115 | run_pass "$TEST_KEY" svn status --config-dir=$TEST_DIR/.subversion/ |
---|
116 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
117 | M . |
---|
118 | __OUT__ |
---|
119 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
120 | #------------------------------------------------------------------------------- |
---|
121 | # Tests fcm conflicts: edit, delete, keep local (cat) |
---|
122 | TEST_KEY=$TEST_KEY_BASE-keep-cat |
---|
123 | run_pass "$TEST_KEY" cat pro/hello.pro |
---|
124 | file_cmp "$TEST_KEY.out" "$TEST_KEY.out" <<__OUT__ |
---|
125 | PRO HELLO |
---|
126 | END |
---|
127 | Local contents (1) |
---|
128 | __OUT__ |
---|
129 | file_cmp "$TEST_KEY.err" "$TEST_KEY.err" </dev/null |
---|
130 | teardown |
---|
131 | #------------------------------------------------------------------------------- |
---|