Fossil SCM
find_filename_changes() should report a rename even if the file ends up reverting back to its original name.
Commit
0e9d50b1481dc80bbff8ba4a529e52b98c3ed850
Parent
423029b153bed49…
2 files changed
-1
+56
-1
| --- src/path.c | ||
| +++ src/path.c | ||
| @@ -452,11 +452,10 @@ | ||
| 452 | 452 | if( nChng ){ |
| 453 | 453 | aChng = *aiChng = fossil_malloc( nChng*2*sizeof(int) ); |
| 454 | 454 | for(pChng=pAll, i=0; pChng; pChng=pChng->pNext){ |
| 455 | 455 | if( pChng->newName==0 ) continue; |
| 456 | 456 | if( pChng->origName==0 ) continue; |
| 457 | - if( pChng->newName==pChng->origName ) continue; | |
| 458 | 457 | aChng[i] = pChng->origName; |
| 459 | 458 | aChng[i+1] = pChng->newName; |
| 460 | 459 | if( zDebug ){ |
| 461 | 460 | fossil_print("%s summary %d[%z] -> %d[%z]\n", |
| 462 | 461 | zDebug, |
| 463 | 462 |
| --- 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 |
+56
| --- test/merge_renames.test | ||
| +++ test/merge_renames.test | ||
| @@ -330,10 +330,66 @@ | ||
| 330 | 330 | test_status_list merge_renames-9-6 $RESULT " |
| 331 | 331 | $expectedMerge |
| 332 | 332 | REMINDER: this was a dry run - no files were actually changed. |
| 333 | 333 | " |
| 334 | 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" | |
| 335 | 391 | |
| 336 | 392 | ###################################### |
| 337 | 393 | # |
| 338 | 394 | # Tests for troubles not specifically linked with renames but that I'd like to |
| 339 | 395 | # write: |
| 340 | 396 |
| --- 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 |