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