Fossil SCM

find_filename_changes() should report a rename even if the file ends up reverting back to its original name.

joel 2016-05-06 20:00 merge-renames
Commit 0e9d50b1481dc80bbff8ba4a529e52b98c3ed850
-1
--- src/path.c
+++ src/path.c
@@ -452,11 +452,10 @@
452452
if( nChng ){
453453
aChng = *aiChng = fossil_malloc( nChng*2*sizeof(int) );
454454
for(pChng=pAll, i=0; pChng; pChng=pChng->pNext){
455455
if( pChng->newName==0 ) continue;
456456
if( pChng->origName==0 ) continue;
457
- if( pChng->newName==pChng->origName ) continue;
458457
aChng[i] = pChng->origName;
459458
aChng[i+1] = pChng->newName;
460459
if( zDebug ){
461460
fossil_print("%s summary %d[%z] -> %d[%z]\n",
462461
zDebug,
463462
--- src/path.c
+++ src/path.c
@@ -452,11 +452,10 @@
452 if( nChng ){
453 aChng = *aiChng = fossil_malloc( nChng*2*sizeof(int) );
454 for(pChng=pAll, i=0; pChng; pChng=pChng->pNext){
455 if( pChng->newName==0 ) continue;
456 if( pChng->origName==0 ) continue;
457 if( pChng->newName==pChng->origName ) continue;
458 aChng[i] = pChng->origName;
459 aChng[i+1] = pChng->newName;
460 if( zDebug ){
461 fossil_print("%s summary %d[%z] -> %d[%z]\n",
462 zDebug,
463
--- src/path.c
+++ src/path.c
@@ -452,11 +452,10 @@
452 if( nChng ){
453 aChng = *aiChng = fossil_malloc( nChng*2*sizeof(int) );
454 for(pChng=pAll, i=0; pChng; pChng=pChng->pNext){
455 if( pChng->newName==0 ) continue;
456 if( pChng->origName==0 ) continue;
 
457 aChng[i] = pChng->origName;
458 aChng[i+1] = pChng->newName;
459 if( zDebug ){
460 fossil_print("%s summary %d[%z] -> %d[%z]\n",
461 zDebug,
462
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -330,10 +330,66 @@
330330
test_status_list merge_renames-9-6 $RESULT "
331331
$expectedMerge
332332
REMINDER: this was a dry run - no files were actually changed.
333333
"
334334
test merge_renames-9-7 {[fossil changes] eq ""}
335
+
336
+###################################################################
337
+# Test 10 #
338
+# Merge swapped filenames, backout the swap, then merge changes #
339
+###################################################################
340
+
341
+test_setup
342
+
343
+write_file f1 "f1"
344
+write_file f2 "f2"
345
+fossil add f1 f2
346
+fossil commit -m "add files" ;# N
347
+
348
+fossil mv --hard f1 f1-tmp
349
+fossil mv --hard f2 f1
350
+fossil mv --hard f1-tmp f2
351
+fossil commit -b b -m "swap f1, f2" ;# P
352
+
353
+fossil update trunk
354
+fossil merge b
355
+test_status_list merge_renames-10-1 $RESULT {
356
+ RENAME f1 -> f2
357
+ RENAME f2 -> f1
358
+}
359
+test_file_contents merge_renames-10-2 f1 "f2"
360
+test_file_contents merge_renames-10-3 f2 "f1"
361
+fossil commit -m "merge b"
362
+
363
+fossil update b
364
+write_file f1 f1.1
365
+write_file f2 f2.1
366
+fossil commit -m "edit" ;# M
367
+
368
+fossil update trunk
369
+fossil merge --backout trunk
370
+test_status_list merge_renames-10-4 $RESULT {
371
+ RENAME f1 -> f2
372
+ RENAME f2 -> f1
373
+}
374
+test_file_contents merge_renames-10-5 f1 "f1"
375
+test_file_contents merge_renames-10-6 f2 "f2"
376
+test_status_list merge_renames-10-7 [fossil changes] "
377
+ RENAMED f1
378
+ RENAMED f2
379
+ BACKOUT [commit_id trunk]
380
+"
381
+fossil commit -m "swap back" ;# V
382
+
383
+fossil merge b
384
+test_status_list merge_renames-10-8 $RESULT {
385
+ UPDATE f1
386
+ UPDATE f2
387
+}
388
+
389
+test_file_contents merge_renames-10-9 f1 "f2.1"
390
+test_file_contents merge_renames-10-10 f2 "f1.1"
335391
336392
######################################
337393
#
338394
# Tests for troubles not specifically linked with renames but that I'd like to
339395
# write:
340396
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -330,10 +330,66 @@
330 test_status_list merge_renames-9-6 $RESULT "
331 $expectedMerge
332 REMINDER: this was a dry run - no files were actually changed.
333 "
334 test merge_renames-9-7 {[fossil changes] eq ""}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
336 ######################################
337 #
338 # Tests for troubles not specifically linked with renames but that I'd like to
339 # write:
340
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -330,10 +330,66 @@
330 test_status_list merge_renames-9-6 $RESULT "
331 $expectedMerge
332 REMINDER: this was a dry run - no files were actually changed.
333 "
334 test merge_renames-9-7 {[fossil changes] eq ""}
335
336 ###################################################################
337 # Test 10 #
338 # Merge swapped filenames, backout the swap, then merge changes #
339 ###################################################################
340
341 test_setup
342
343 write_file f1 "f1"
344 write_file f2 "f2"
345 fossil add f1 f2
346 fossil commit -m "add files" ;# N
347
348 fossil mv --hard f1 f1-tmp
349 fossil mv --hard f2 f1
350 fossil mv --hard f1-tmp f2
351 fossil commit -b b -m "swap f1, f2" ;# P
352
353 fossil update trunk
354 fossil merge b
355 test_status_list merge_renames-10-1 $RESULT {
356 RENAME f1 -> f2
357 RENAME f2 -> f1
358 }
359 test_file_contents merge_renames-10-2 f1 "f2"
360 test_file_contents merge_renames-10-3 f2 "f1"
361 fossil commit -m "merge b"
362
363 fossil update b
364 write_file f1 f1.1
365 write_file f2 f2.1
366 fossil commit -m "edit" ;# M
367
368 fossil update trunk
369 fossil merge --backout trunk
370 test_status_list merge_renames-10-4 $RESULT {
371 RENAME f1 -> f2
372 RENAME f2 -> f1
373 }
374 test_file_contents merge_renames-10-5 f1 "f1"
375 test_file_contents merge_renames-10-6 f2 "f2"
376 test_status_list merge_renames-10-7 [fossil changes] "
377 RENAMED f1
378 RENAMED f2
379 BACKOUT [commit_id trunk]
380 "
381 fossil commit -m "swap back" ;# V
382
383 fossil merge b
384 test_status_list merge_renames-10-8 $RESULT {
385 UPDATE f1
386 UPDATE f2
387 }
388
389 test_file_contents merge_renames-10-9 f1 "f2.1"
390 test_file_contents merge_renames-10-10 f2 "f1.1"
391
392 ######################################
393 #
394 # Tests for troubles not specifically linked with renames but that I'd like to
395 # write:
396

Keyboard Shortcuts

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