Fossil SCM

fossil-scm / test / merge_renames.test
Blame History Raw 560 lines
1
#
2
# Tests for merging with renames
3
#
4
#
5
6
proc commit_id {version} {
7
regexp -line {^artifact:\s+(\S+)} [fossil whatis $version] - id
8
return $id
9
}
10
11
require_no_open_checkout
12
13
######################################
14
# Test 1 #
15
# Reported: Ticket [554f44ee74e3d] #
16
######################################
17
18
test_setup
19
20
write_file f1 "line"
21
fossil add f1
22
fossil commit -m "c1"
23
fossil tag add pivot current
24
25
write_file f1 "line2"
26
fossil commit -m "c2"
27
28
write_file f1 "line3"
29
fossil commit -m "c3"
30
31
write_file f1 "line4"
32
fossil commit -m "c4"
33
34
write_file f1 "line5"
35
fossil commit -m "c4"
36
37
write_file f1 "line6"
38
fossil commit -m "c4"
39
40
fossil update pivot
41
fossil mv --hard f1 f2
42
fossil commit -b rename -m "c5"
43
44
fossil merge trunk
45
fossil commit -m "trunk merged"
46
47
fossil update pivot
48
write_file f3 "someline"
49
fossil add f3
50
fossil commit -b branch2 -m "newbranch"
51
52
fossil merge trunk
53
test_status_list merge_renames-1 $RESULT {UPDATE f1}
54
55
######################################
56
# Test 2 #
57
# Reported: Ticket [74413366fe5067] #
58
######################################
59
60
test_setup
61
62
write_file f1 "line"
63
fossil add f1
64
fossil commit -m "base file"
65
fossil tag add pivot current
66
67
write_file f2 "line2"
68
fossil add f2
69
fossil commit -m "newfile"
70
71
fossil mv --hard f2 f2new
72
fossil commit -m "rename"
73
74
fossil update pivot
75
write_file f1 "line3"
76
fossil commit -b branch -m "change"
77
78
fossil merge trunk
79
fossil commit -m "trunk merged"
80
81
fossil update trunk
82
83
fossil merge branch
84
test_status_list merge_renames-2 $RESULT {UPDATE f1}
85
86
######################################
87
# Test 3 #
88
# Reported: Ticket [30b28cf351] #
89
######################################
90
91
test_setup
92
93
write_file f1 "line"
94
fossil add f1
95
fossil commit -m "base file"
96
fossil tag add pivot current
97
98
write_file f2 "line2"
99
fossil add f2
100
fossil commit -m "newfile"
101
102
fossil mv --hard f2 f2new
103
fossil commit -m "rename"
104
105
fossil update pivot
106
write_file f1 "line3"
107
fossil commit -b branch -m "change"
108
109
fossil merge trunk
110
fossil commit -m "trunk merged"
111
112
fossil update trunk
113
114
fossil merge branch
115
test_status_list merge_renames-3 $RESULT {UPDATE f1}
116
117
######################################
118
# Test 4 #
119
# Reported: Ticket [67176c3aa4] #
120
######################################
121
122
test_setup
123
124
write_file f1 "f1"
125
fossil add f1
126
fossil commit -m "add f1"
127
128
write_file f1 "f1.1"
129
fossil commit --branch b -m "change f1"
130
131
fossil update trunk
132
fossil mv --hard f1 f2
133
fossil commit -m "f1 -> f2"
134
135
fossil merge b
136
test_status_list merge_renames-4-1 $RESULT {UPDATE f2}
137
test_file_contents merge_renames-4-2 f2 "f1.1"
138
139
######################################
140
# Test 5 #
141
# Handle Rename/Add via Merge #
142
######################################
143
144
test_setup
145
146
write_file f1 "old f1 line"
147
fossil add f1
148
fossil commit -m "base file"
149
150
write_file f3 "f3 line"
151
fossil add f3
152
fossil commit -m "branch file" -b branch_for_f3
153
154
fossil update trunk
155
fossil mv --hard f1 f2
156
write_file f1 "new f1 line"
157
fossil add f1
158
fossil commit -m "rename and add file with old name"
159
160
fossil update branch_for_f3
161
fossil merge trunk
162
test_status_list merge_renames-5-1 $RESULT {
163
RENAME f1 -> f2
164
ADDED f1
165
}
166
167
fossil commit -m "trunk merged, should have 3 files"
168
169
fossil ls
170
171
test merge_renames-5-2 {[normalize_result] eq {f1
172
f2
173
f3}}
174
175
#####################################
176
# Test 6 #
177
# Merging a branch multiple times #
178
#####################################
179
180
test_setup
181
182
write_file f1 "f1"
183
fossil add f1
184
fossil commit -m "add f1"
185
186
fossil mv --hard f1 f2
187
fossil commit -b b -m "f1 -> f2"
188
189
fossil update trunk
190
write_file f3 "f3"
191
write_file f4 "f4"
192
fossil add f3 f4
193
fossil ci -m "add f3, f4"
194
195
fossil mv --hard f3 f3-old
196
fossil mv --hard f4 f3
197
fossil mv --hard f3-old f4
198
fossil ci -m "swap f3 and f4"
199
200
write_file f1 "f1.1"
201
fossil commit -m "edit f1"
202
203
fossil update b
204
fossil merge trunk
205
fossil commit -m "merge trunk"
206
207
fossil update trunk
208
write_file f1 "f1.2"
209
write_file f3 "f3.1"
210
write_file f4 "f4.1"
211
fossil commit -m "edit f1, f4"
212
213
fossil update b
214
fossil merge trunk
215
test_status_list merge_renames-6-1 $RESULT {
216
UPDATE f2
217
UPDATE f3
218
UPDATE f4
219
}
220
test_file_contents merge_renames-6-2 f2 "f1.2"
221
test_file_contents merge_renames-6-3 f3 "f3.1"
222
test_file_contents merge_renames-6-4 f4 "f4.1"
223
224
########################################################################
225
# Test 7 #
226
# Merging with an uncommitted rename of a file that has been renamed #
227
# in the merged branch and adding a new file with the original name #
228
########################################################################
229
230
test_setup
231
232
write_file f1 "f1"
233
fossil add f1
234
fossil commit -m "add f1"
235
236
fossil mv --hard f1 f2
237
write_file f2 "f2"
238
fossil commit -b b -m "f1 -> f2, edit f2"
239
240
fossil update trunk
241
fossil mv --hard f1 f3
242
write_file f1 "f1.1"
243
fossil add f1
244
fossil merge b
245
test_status_list merge_renames-7-1 $RESULT {UPDATE f3}
246
test_file_contents merge_renames-7-2 f1 "f1.1"
247
test_file_contents merge_renames-7-3 f3 "f2"
248
249
######################################################
250
# Test 8 #
251
# Merging two branches that both add the same file #
252
######################################################
253
254
test_setup
255
256
write_file f1 "f1.1"
257
fossil add f1
258
fossil commit -b b1 -m "add f1"
259
260
fossil update trunk
261
write_file f1 "f1.2"
262
fossil add f1
263
fossil commit -b b2 -m "add f1"
264
265
fossil update trunk
266
fossil merge b1
267
fossil merge b2 -expectError
268
test_status_list merge_renames-8-1 $RESULT {
269
MERGE f1
270
WARNING: 1 merge conflicts
271
}
272
273
fossil revert
274
fossil merge --integrate b1
275
fossil merge b2 -expectError
276
test_status_list merge_renames-8-2 $RESULT {
277
MERGE f1
278
WARNING: 1 merge conflicts
279
}
280
281
#############################################
282
# Test 9 #
283
# Merging a delete/rename/add combination #
284
#############################################
285
286
test_setup
287
288
write_file f1 "f1"
289
write_file f2 "f2"
290
fossil add f1 f2
291
fossil commit -m "add files"
292
293
fossil rm --hard f2
294
fossil commit -b b -m "delete f2"
295
296
fossil mv --hard f1 f2
297
fossil commit -m "f1 -> f2"
298
299
write_file f1 "f1.1"
300
fossil add f1
301
fossil commit -m "add new f1"
302
303
fossil update trunk
304
fossil merge b
305
set expectedMerge {
306
DELETE f2
307
RENAME f1 -> f2
308
ADDED f1
309
}
310
test_status_list merge_renames-9-1 $RESULT $expectedMerge
311
fossil changes
312
test_status_list merge_renames-9-2 $RESULT "
313
MERGED_WITH [commit_id b]
314
ADDED_BY_MERGE f1
315
RENAMED f1 -> f2
316
DELETED f2 -> f2 (overwritten by rename)
317
"
318
test_file_contents merge_renames-9-3 f1 "f1.1"
319
test_file_contents merge_renames-9-4 f2 "f1"
320
321
# Undo and ensure a dry run merge results in no changes
322
fossil undo
323
test_status_list merge_renames-9-5 $RESULT {
324
UNDO f1
325
UNDO f2
326
}
327
fossil merge -n b -expectError
328
test_status_list merge_renames-9-6 $RESULT "
329
$expectedMerge
330
REMINDER: this was a dry run - no files were actually changed.
331
"
332
test merge_renames-9-7 {[fossil changes] eq ""}
333
334
###################################################################
335
# Test 10 #
336
# Merge swapped filenames, backout the swap, then merge changes #
337
###################################################################
338
339
test_setup
340
341
write_file f1 "f1"
342
write_file f2 "f2"
343
fossil add f1 f2
344
fossil commit -m "add files" ;# N
345
346
fossil mv --hard f1 f1-tmp
347
fossil mv --hard f2 f1
348
fossil mv --hard f1-tmp f2
349
fossil commit -b b -m "swap f1, f2" ;# P
350
351
fossil update trunk
352
fossil merge b
353
test_status_list merge_renames-10-1 $RESULT {
354
RENAME f1 -> f2
355
RENAME f2 -> f1
356
}
357
test_file_contents merge_renames-10-2 f1 "f2"
358
test_file_contents merge_renames-10-3 f2 "f1"
359
fossil commit -m "merge b"
360
361
fossil update b
362
write_file f1 f1.1
363
write_file f2 f2.1
364
fossil commit -m "edit" ;# M
365
366
fossil update trunk
367
fossil merge --backout trunk
368
test_status_list merge_renames-10-4 $RESULT {
369
RENAME f1 -> f2
370
RENAME f2 -> f1
371
}
372
test_file_contents merge_renames-10-5 f1 "f1"
373
test_file_contents merge_renames-10-6 f2 "f2"
374
test_status_list merge_renames-10-7 [fossil changes] "
375
RENAMED f1 -> f2
376
RENAMED f2 -> f1
377
BACKOUT [commit_id trunk]
378
"
379
fossil commit -m "swap back" ;# V
380
381
fossil merge b
382
test_status_list merge_renames-10-8 $RESULT {
383
UPDATE f1
384
UPDATE f2
385
}
386
387
test_file_contents merge_renames-10-9 f1 "f2.1"
388
test_file_contents merge_renames-10-10 f2 "f1.1"
389
390
############################################
391
# Test 11 #
392
# Specifying a baseline #
393
############################################
394
395
test_setup
396
397
write_file f1 "line"
398
fossil add f1
399
fossil commit -m "add f1"
400
401
write_file f1 "line\nline2"
402
fossil commit -b b -m "edit f2" --tag p1
403
404
fossil mv --hard f1 f2
405
fossil commit -m "f1 -> f2"
406
407
write_file f2 "line\nline2\nline3"
408
fossil commit -m "edit f2" --tag p2
409
410
write_file f2 "line\nline2\nline3\nline4"
411
fossil commit -m "edit f2"
412
413
fossil update trunk
414
fossil merge --baseline p1 b
415
test_status_list merge_renames-11-1 $RESULT {
416
MERGE f1
417
RENAME f1 -> f2
418
}
419
test_file_contents merge_renames-11-2 f2 "line\nline3\nline4"
420
fossil revert
421
fossil merge --baseline p2 b
422
test_status_list merge_renames-11-3 $RESULT {MERGE f1}
423
test_file_contents merge_renames-11-4 f1 "line\nline4"
424
425
#################################################################
426
# Test 12 #
427
# Merge involving a pivot that isn't a first-parent ancestor #
428
# of either the checked-out commit or the commit being merged #
429
#################################################################
430
431
test_setup
432
433
write_file f1 "f1\n"
434
fossil add f1
435
fossil commit -m "add f1" --tag n
436
437
fossil mv --hard f1 f1n
438
fossil commit -m "f1 -> f1n"
439
440
fossil mv --hard f1n f1v
441
write_file f1v "f1v\n"
442
fossil commit -b v -m "f1n -> f1v, edit f1v"
443
444
fossil update trunk
445
fossil mv --hard f1n f1m
446
fossil commit -b m -m "f1n -> f1m"
447
448
fossil update n
449
fossil mv --hard f1 f1p
450
write_file f1p "f1\np"
451
fossil commit -b p -m "f1 -> f1p, edit f1p"
452
453
fossil update m
454
fossil merge p
455
test_status_list merge_renames-12-1 $RESULT {UPDATE f1m}
456
test_file_contents merge_renames-12-2 f1m "f1\np"
457
fossil commit -m "merge p"
458
459
write_file f1m "f1\nm"
460
fossil commit -m "edit f1m"
461
462
fossil update v
463
fossil merge p
464
test_status_list merge_renames-12-3 $RESULT {MERGE f1v}
465
test_file_contents merge_renames-12-4 f1v "f1v\np"
466
fossil commit -m "merge p"
467
468
fossil merge m
469
test_status_list merge_renames-12-5 $RESULT {MERGE f1v}
470
test_file_contents merge_renames-12-6 f1v "f1v\nm"
471
fossil commit -m "merge m"
472
473
#################################################################
474
# Test 13 #
475
# Merge in add+rename that happened on a branch, then merged #
476
# back to branch, and again to trunk, then merge in branch. #
477
#################################################################
478
479
set repoDir [test_setup]
480
write_file f1 "line1"
481
fossil add f1
482
fossil commit -m "add f1" --tag c1
483
484
write_file f2 "line1"
485
fossil add f2
486
fossil commit -m "add f2 on branch" -b b --tag c2
487
fossil update trunk
488
test_status_list merge_renames_13-1 $RESULT {REMOVE f2}
489
write_file f1 "line1\nline2\n"
490
fossil commit -m "edit f1 on trunk" --tag c3
491
492
fossil update b
493
test_status_list merge_renames_13-2 $RESULT {
494
UPDATE f1
495
ADD f2
496
}
497
fossil merge trunk
498
fossil commit -m "merge trunk" --tag c4
499
fossil mv --hard f2 f2n
500
test_status_list merge_renames-13-3 $RESULT "
501
RENAME f2 f2n
502
MOVED_FILE [file normalize $repoDir]/f2
503
"
504
fossil commit -m "renamed f2->f2n" --tag c5
505
506
fossil update trunk
507
fossil merge b
508
test_status_list merge_renames-13-4 $RESULT {ADDED f2n}
509
fossil commit -m "merge f2n" --tag m1 --tag c6
510
511
fossil update b
512
write_file f1 "line1\nline3\nline2"
513
fossil commit -m "edit f1 on b" --tag c7
514
515
fossil update trunk
516
write_file f1 "line1\nline3\nline2\nline4"
517
fossil commit -m "edit f1 on trunk" --tag c8
518
519
fossil update b
520
fossil merge trunk
521
test_status_list merge_renames-13-5 $RESULT {MERGE f1}
522
fossil commit -m "merge trunk" --tag c9
523
write_file f1 "line1\nline3\nline4"
524
fossil commit -m "edit f1 on b" --tag c10
525
526
fossil update m1
527
fossil merge b
528
test_status_list merge_renames-13-6 $RESULT {
529
UPDATE f1
530
}
531
test_file_contents merge_renames-13-7 f2n "line1"
532
533
fossil revert
534
test_status_list merge_renames-13-8 $RESULT {
535
REVERT f1
536
}
537
fossil update trunk
538
fossil merge --integrate b
539
test_status_list merge_renames-13-9 $RESULT {
540
UPDATE f1
541
}
542
test_file_contents merge_renames-13-10 f2n "line1"
543
544
fossil revert
545
test_status_list merge_renames-13-11 $RESULT {
546
REVERT f1
547
}
548
549
######################################
550
#
551
# Tests for troubles not specifically linked with renames but that I'd like to
552
# write:
553
# [c26c63eb1b] - 'merge --backout' does not handle conflicts properly
554
# [953031915f] - Lack of warning when overwriting extra files
555
# [4df5f38f1e] - Troubles merging a file delete with a file change
556
557
###############################################################################
558
559
test_cleanup
560

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button