|
1
|
# |
|
2
|
# Copyright (c) 2010 D. Richard Hipp |
|
3
|
# |
|
4
|
# This program is free software; you can redistribute it and/or |
|
5
|
# modify it under the terms of the Simplified BSD License (also |
|
6
|
# known as the "2-Clause License" or "FreeBSD License".) |
|
7
|
# |
|
8
|
# This program is distributed in the hope that it will be useful, |
|
9
|
# but without any warranty; without even the implied warranty of |
|
10
|
# merchantability or fitness for a particular purpose. |
|
11
|
# |
|
12
|
# Author contact information: |
|
13
|
# [email protected] |
|
14
|
# http://www.hwaci.com/drh/ |
|
15
|
# |
|
16
|
############################################################################ |
|
17
|
# |
|
18
|
# Tests of the "merge" command |
|
19
|
# |
|
20
|
|
|
21
|
if {! $::QUIET} { |
|
22
|
puts "Skipping Merge5 tests" |
|
23
|
} |
|
24
|
protOut { |
|
25
|
fossil sqlite3 --no-repository reacts badly to SQL dumped from |
|
26
|
repositories created from fossil older than version 2.0. |
|
27
|
} |
|
28
|
#test merge5-sqlite3-issue false knownBug |
|
29
|
test_cleanup_then_return |
|
30
|
|
|
31
|
# Verify the results of a check-out |
|
32
|
# |
|
33
|
proc checkout-test {testid expected_content} { |
|
34
|
set flist {} |
|
35
|
foreach {status filename} [exec $::fossilexe ls -l] { |
|
36
|
if {$status!="DELETED"} {lappend flist $filename} |
|
37
|
} |
|
38
|
eval fossil sha1sum [lsort $flist] |
|
39
|
global RESULT |
|
40
|
regsub -all {\n *} [string trim $expected_content] "\n " expected |
|
41
|
regsub -all {\n *} [string trim $RESULT] "\n " result |
|
42
|
if {$result!=$expected} { |
|
43
|
protOut " Expected:\n $expected" |
|
44
|
protOut " Got:\n $result" |
|
45
|
test merge5-$testid 0 |
|
46
|
} else { |
|
47
|
test merge5-$testid 1 |
|
48
|
} |
|
49
|
} |
|
50
|
|
|
51
|
require_no_open_checkout; test_setup "" |
|
52
|
|
|
53
|
# Construct a test repository |
|
54
|
# |
|
55
|
exec $::fossilexe sqlite3 --no-repository m5.fossil <$testdir/${testfile}_repo.sql |
|
56
|
fossil rebuild m5.fossil |
|
57
|
fossil open m5.fossil |
|
58
|
fossil user default drh --user drh |
|
59
|
fossil update baseline |
|
60
|
checkout-test 10 { |
|
61
|
da5c8346496f3421cb58f84b6e59e9531d9d424d one.txt |
|
62
|
ed24d19d726d173f18dbf4a9a0f8514daa3e3ca4 three.txt |
|
63
|
278a402316510f6ae4a77186796a6bde78c7dbc1 two.txt |
|
64
|
} |
|
65
|
|
|
66
|
# Update to the tip of the trunk |
|
67
|
# |
|
68
|
fossil update trunk |
|
69
|
checkout-test 20 { |
|
70
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
71
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
72
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
73
|
} |
|
74
|
|
|
75
|
# Merge in the change that adds file four.txt |
|
76
|
# |
|
77
|
fossil merge br1 |
|
78
|
checkout-test 30 { |
|
79
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
80
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
81
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
82
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
83
|
} |
|
84
|
|
|
85
|
# Undo the merge. Verify restoration of former state. |
|
86
|
# |
|
87
|
fossil undo |
|
88
|
checkout-test 40 { |
|
89
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
90
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
91
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
92
|
} |
|
93
|
|
|
94
|
# Now switch to br1 then merge in the trunk. Verify that the result |
|
95
|
# is the same as merging br1 into trunk. |
|
96
|
# |
|
97
|
fossil update br1 |
|
98
|
fossil merge trunk |
|
99
|
checkout-test 50 { |
|
100
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
101
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
102
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
103
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
104
|
} |
|
105
|
fossil undo |
|
106
|
fossil update trunk |
|
107
|
checkout-test 60 { |
|
108
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
109
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
110
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
111
|
} |
|
112
|
|
|
113
|
# Go back to the tip of the trunk and merge branch br1 again. This |
|
114
|
# time do a check-in of the merge. Verify that the same content appears |
|
115
|
# after the merge. |
|
116
|
# |
|
117
|
fossil update chng3 |
|
118
|
fossil merge br1 |
|
119
|
checkout-test 70 { |
|
120
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
121
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
122
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
123
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
124
|
} |
|
125
|
fossil commit -tag m1 -m {merge with br1} -nosign -f |
|
126
|
checkout-test 71 { |
|
127
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
128
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
129
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
130
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
131
|
} |
|
132
|
fossil update chng3 |
|
133
|
checkout-test 72 { |
|
134
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
135
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
136
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
137
|
} |
|
138
|
fossil update m1 |
|
139
|
checkout-test 73 { |
|
140
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
141
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
142
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
143
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
144
|
} |
|
145
|
|
|
146
|
# Merge br2 into the trunk. br2 contains some independent change to the |
|
147
|
# two.txt file. Verify that these are merge in correctly. |
|
148
|
# |
|
149
|
fossil update m1 |
|
150
|
fossil merge br2 |
|
151
|
checkout-test 80 { |
|
152
|
8f09bc55a60eb8ca06f10a3b577aafa869b31695 five.txt |
|
153
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
154
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
155
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
156
|
68eeee8b843eaea76e33d3911f416b745d0e5e5c two.txt |
|
157
|
} |
|
158
|
fossil undo |
|
159
|
checkout-test 81 { |
|
160
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
161
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
162
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
163
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
164
|
} |
|
165
|
|
|
166
|
# Now merge trunk into br2. Verify that the same set of changes result. |
|
167
|
# |
|
168
|
fossil update br2 |
|
169
|
fossil merge trunk |
|
170
|
checkout-test 90 { |
|
171
|
8f09bc55a60eb8ca06f10a3b577aafa869b31695 five.txt |
|
172
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
173
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
174
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
175
|
68eeee8b843eaea76e33d3911f416b745d0e5e5c two.txt |
|
176
|
} |
|
177
|
fossil undo |
|
178
|
checkout-test 91 { |
|
179
|
8f09bc55a60eb8ca06f10a3b577aafa869b31695 five.txt |
|
180
|
da5c8346496f3421cb58f84b6e59e9531d9d424d one.txt |
|
181
|
ed24d19d726d173f18dbf4a9a0f8514daa3e3ca4 three.txt |
|
182
|
85286cb3bc6d9e6f2f586eb5532f6065678f75b9 two.txt |
|
183
|
} |
|
184
|
|
|
185
|
# Starting from chng3, merge in br4. The one file is deleted from br4, so |
|
186
|
# the merge should cause the one file to disappear from the checkout. |
|
187
|
# |
|
188
|
fossil update chng3 |
|
189
|
checkout-test 100 { |
|
190
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
191
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
192
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
193
|
} |
|
194
|
fossil merge br4 |
|
195
|
checkout-test 101 { |
|
196
|
6e167b139c294bed560e2e30b352361b101e1f39 four.txt |
|
197
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
198
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
199
|
} |
|
200
|
fossil undo |
|
201
|
checkout-test 102 { |
|
202
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
203
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
204
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
205
|
} |
|
206
|
|
|
207
|
# Do the same merge of br4 into chng3, but this time check it in as a new |
|
208
|
# branch. |
|
209
|
# |
|
210
|
fossil update chng3 |
|
211
|
fossil merge br4 |
|
212
|
fossil commit -nosign -branch br4-b -m {merge in br4} -tag m2 |
|
213
|
checkout-test 110 { |
|
214
|
6e167b139c294bed560e2e30b352361b101e1f39 four.txt |
|
215
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
216
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
217
|
} |
|
218
|
|
|
219
|
# Branches br1 and br4 both add file four.txt. So if we merge them together, |
|
220
|
# the version of file four.txt in the original should be preserved. |
|
221
|
# |
|
222
|
fossil update br1 |
|
223
|
checkout-test 120 { |
|
224
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
225
|
da5c8346496f3421cb58f84b6e59e9531d9d424d one.txt |
|
226
|
ed24d19d726d173f18dbf4a9a0f8514daa3e3ca4 three.txt |
|
227
|
278a402316510f6ae4a77186796a6bde78c7dbc1 two.txt |
|
228
|
} |
|
229
|
fossil merge br4 -expectError |
|
230
|
checkout-test 121 { |
|
231
|
35815cf5804e8933eab64ae34e00bbb381be72c5 four.txt |
|
232
|
ed24d19d726d173f18dbf4a9a0f8514daa3e3ca4 three.txt |
|
233
|
278a402316510f6ae4a77186796a6bde78c7dbc1 two.txt |
|
234
|
} |
|
235
|
fossil undo |
|
236
|
fossil update br4 |
|
237
|
checkout-test 122 { |
|
238
|
6e167b139c294bed560e2e30b352361b101e1f39 four.txt |
|
239
|
ed24d19d726d173f18dbf4a9a0f8514daa3e3ca4 three.txt |
|
240
|
278a402316510f6ae4a77186796a6bde78c7dbc1 two.txt |
|
241
|
} |
|
242
|
fossil merge br1 -expectError |
|
243
|
checkout-test 123 { |
|
244
|
6e167b139c294bed560e2e30b352361b101e1f39 four.txt |
|
245
|
ed24d19d726d173f18dbf4a9a0f8514daa3e3ca4 three.txt |
|
246
|
278a402316510f6ae4a77186796a6bde78c7dbc1 two.txt |
|
247
|
} |
|
248
|
fossil undo |
|
249
|
|
|
250
|
# Merge br5 (which includes a file rename) into chng3 |
|
251
|
# |
|
252
|
fossil update chng3 |
|
253
|
checkout-test 130 { |
|
254
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
255
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
256
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
257
|
} |
|
258
|
fossil merge br5 |
|
259
|
checkout-test 131 { |
|
260
|
7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt |
|
261
|
98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt |
|
262
|
e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt |
|
263
|
} |
|
264
|
fossil undo |
|
265
|
checkout-test 132 { |
|
266
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
267
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
268
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
269
|
} |
|
270
|
fossil merge br5 |
|
271
|
checkout-test 133 { |
|
272
|
7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt |
|
273
|
98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt |
|
274
|
e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt |
|
275
|
} |
|
276
|
fossil commit -nosign -m {merge with rename} -branch {trunk+br5} |
|
277
|
checkout-test 134 { |
|
278
|
7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt |
|
279
|
98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt |
|
280
|
e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt |
|
281
|
} |
|
282
|
fossil update chng3 |
|
283
|
checkout-test 135 { |
|
284
|
6f525ab779ad66e24474d845c5fb7938be42d50d one.txt |
|
285
|
64a8a5c7320fccfa4b2e5dfc5fd20a5381a86c5b three.txt |
|
286
|
b262fee89ed8a27a23a5e09d3917e0bebe22cd24 two.txt |
|
287
|
} |
|
288
|
fossil update trunk+br5 |
|
289
|
checkout-test 136 { |
|
290
|
7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt |
|
291
|
98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt |
|
292
|
e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt |
|
293
|
} |
|
294
|
|
|
295
|
# Merge the chng3 check-in into br5, verifying that the change to two.txt |
|
296
|
# from chng3 are applies to two-rename.txt in br5. |
|
297
|
# |
|
298
|
fossil update br5 |
|
299
|
checkout-test 140 { |
|
300
|
e866bb885d5184cba497cfb6a4eb281688519521 one.txt |
|
301
|
e09593950837f76e70ca2f8ff2272ae3df0ba017 three.txt |
|
302
|
5ebb3c9ad50740a7382902657b84a6105c32fc7b two-rename.txt |
|
303
|
} |
|
304
|
fossil merge chng3 |
|
305
|
checkout-test 141 { |
|
306
|
7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt |
|
307
|
98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt |
|
308
|
e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt |
|
309
|
} |
|
310
|
fossil commit -nosign -m {change to two} -branch br5-2 |
|
311
|
checkout-test 142 { |
|
312
|
7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt |
|
313
|
98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt |
|
314
|
e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt |
|
315
|
} |
|
316
|
|
|
317
|
############################################################################### |
|
318
|
|
|
319
|
test_cleanup |
|
320
|
|