Fossil SCM
Preliminary fix for the issue described at [/forumpost/51a37054|developers forum post 51a37054].
Commit
f381794fd7c90d6e394496594eac17d5288d861e71714a73f5183ea13a013d17
Parent
7f1958acf834743…
1 file changed
+37
+37
| --- src/patch.c | ||
| +++ src/patch.c | ||
| @@ -429,10 +429,11 @@ | ||
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | blob_reset(&cmd); |
| 433 | 433 | if( db_table_exists("patch","patchmerge") ){ |
| 434 | + int nMerge = 0; | |
| 434 | 435 | db_prepare(&q, |
| 435 | 436 | "SELECT type, mhash, upper(type) FROM patch.patchmerge" |
| 436 | 437 | " WHERE type IN ('merge','cherrypick','backout','integrate')" |
| 437 | 438 | " AND mhash NOT GLOB '*[^a-fA-F0-9]*';" |
| 438 | 439 | ); |
| @@ -442,10 +443,11 @@ | ||
| 442 | 443 | if( strcmp(zType,"merge")==0 ){ |
| 443 | 444 | blob_appendf(&cmd, " merge %s\n", db_column_text(&q,1)); |
| 444 | 445 | }else{ |
| 445 | 446 | blob_appendf(&cmd, " merge --%s %s\n", zType, db_column_text(&q,1)); |
| 446 | 447 | } |
| 448 | + nMerge++; | |
| 447 | 449 | if( mFlags & PATCH_VERBOSE ){ |
| 448 | 450 | fossil_print("%-10s %s\n", db_column_text(&q,2), |
| 449 | 451 | db_column_text(&q,0)); |
| 450 | 452 | } |
| 451 | 453 | } |
| @@ -458,10 +460,45 @@ | ||
| 458 | 460 | fossil_fatal("unable to do merges:\n%s", |
| 459 | 461 | blob_str(&cmd)); |
| 460 | 462 | } |
| 461 | 463 | } |
| 462 | 464 | blob_reset(&cmd); |
| 465 | + | |
| 466 | + /* 2024-12-16 https://fossil-scm.org/home/forumpost/51a37054 | |
| 467 | + ** If one or more merge operations occurred in the patch and there are | |
| 468 | + ** files that are marked as "chnged' in the local VFILE but which | |
| 469 | + ** are not mentioned as having been modified in the patch, then | |
| 470 | + ** revert those files. | |
| 471 | + */ | |
| 472 | + if( nMerge ){ | |
| 473 | + int vid = db_lget_int("checkout", 0); | |
| 474 | + int nRevert = 0; | |
| 475 | + blob_append_escaped_arg(&cmd, g.nameOfExe, 1); | |
| 476 | + blob_appendf(&cmd, " revert "); | |
| 477 | + db_prepare(&q, | |
| 478 | + "SELECT pathname FROM vfile WHERE vid=%d AND chnged " | |
| 479 | + "EXCEPT SELECT pathname FROM chng", | |
| 480 | + vid | |
| 481 | + ); | |
| 482 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 483 | + blob_append_escaped_arg(&cmd, db_column_text(&q,0), 1); | |
| 484 | + nRevert++; | |
| 485 | + } | |
| 486 | + db_finalize(&q); | |
| 487 | + if( nRevert ){ | |
| 488 | + if( mFlags & PATCH_DRYRUN ){ | |
| 489 | + fossil_print("%s", blob_str(&cmd)); | |
| 490 | + }else{ | |
| 491 | + int rc = fossil_unsafe_system(blob_str(&cmd)); | |
| 492 | + if( rc ){ | |
| 493 | + fossil_fatal("unable to do reverts:\n%s", | |
| 494 | + blob_str(&cmd)); | |
| 495 | + } | |
| 496 | + } | |
| 497 | + } | |
| 498 | + blob_reset(&cmd); | |
| 499 | + } | |
| 463 | 500 | } |
| 464 | 501 | |
| 465 | 502 | /* Deletions */ |
| 466 | 503 | db_prepare(&q, "SELECT pathname FROM patch.chng" |
| 467 | 504 | " WHERE origname IS NULL AND delta IS NULL"); |
| 468 | 505 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -429,10 +429,11 @@ | |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | blob_reset(&cmd); |
| 433 | if( db_table_exists("patch","patchmerge") ){ |
| 434 | db_prepare(&q, |
| 435 | "SELECT type, mhash, upper(type) FROM patch.patchmerge" |
| 436 | " WHERE type IN ('merge','cherrypick','backout','integrate')" |
| 437 | " AND mhash NOT GLOB '*[^a-fA-F0-9]*';" |
| 438 | ); |
| @@ -442,10 +443,11 @@ | |
| 442 | if( strcmp(zType,"merge")==0 ){ |
| 443 | blob_appendf(&cmd, " merge %s\n", db_column_text(&q,1)); |
| 444 | }else{ |
| 445 | blob_appendf(&cmd, " merge --%s %s\n", zType, db_column_text(&q,1)); |
| 446 | } |
| 447 | if( mFlags & PATCH_VERBOSE ){ |
| 448 | fossil_print("%-10s %s\n", db_column_text(&q,2), |
| 449 | db_column_text(&q,0)); |
| 450 | } |
| 451 | } |
| @@ -458,10 +460,45 @@ | |
| 458 | fossil_fatal("unable to do merges:\n%s", |
| 459 | blob_str(&cmd)); |
| 460 | } |
| 461 | } |
| 462 | blob_reset(&cmd); |
| 463 | } |
| 464 | |
| 465 | /* Deletions */ |
| 466 | db_prepare(&q, "SELECT pathname FROM patch.chng" |
| 467 | " WHERE origname IS NULL AND delta IS NULL"); |
| 468 |
| --- src/patch.c | |
| +++ src/patch.c | |
| @@ -429,10 +429,11 @@ | |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | blob_reset(&cmd); |
| 433 | if( db_table_exists("patch","patchmerge") ){ |
| 434 | int nMerge = 0; |
| 435 | db_prepare(&q, |
| 436 | "SELECT type, mhash, upper(type) FROM patch.patchmerge" |
| 437 | " WHERE type IN ('merge','cherrypick','backout','integrate')" |
| 438 | " AND mhash NOT GLOB '*[^a-fA-F0-9]*';" |
| 439 | ); |
| @@ -442,10 +443,11 @@ | |
| 443 | if( strcmp(zType,"merge")==0 ){ |
| 444 | blob_appendf(&cmd, " merge %s\n", db_column_text(&q,1)); |
| 445 | }else{ |
| 446 | blob_appendf(&cmd, " merge --%s %s\n", zType, db_column_text(&q,1)); |
| 447 | } |
| 448 | nMerge++; |
| 449 | if( mFlags & PATCH_VERBOSE ){ |
| 450 | fossil_print("%-10s %s\n", db_column_text(&q,2), |
| 451 | db_column_text(&q,0)); |
| 452 | } |
| 453 | } |
| @@ -458,10 +460,45 @@ | |
| 460 | fossil_fatal("unable to do merges:\n%s", |
| 461 | blob_str(&cmd)); |
| 462 | } |
| 463 | } |
| 464 | blob_reset(&cmd); |
| 465 | |
| 466 | /* 2024-12-16 https://fossil-scm.org/home/forumpost/51a37054 |
| 467 | ** If one or more merge operations occurred in the patch and there are |
| 468 | ** files that are marked as "chnged' in the local VFILE but which |
| 469 | ** are not mentioned as having been modified in the patch, then |
| 470 | ** revert those files. |
| 471 | */ |
| 472 | if( nMerge ){ |
| 473 | int vid = db_lget_int("checkout", 0); |
| 474 | int nRevert = 0; |
| 475 | blob_append_escaped_arg(&cmd, g.nameOfExe, 1); |
| 476 | blob_appendf(&cmd, " revert "); |
| 477 | db_prepare(&q, |
| 478 | "SELECT pathname FROM vfile WHERE vid=%d AND chnged " |
| 479 | "EXCEPT SELECT pathname FROM chng", |
| 480 | vid |
| 481 | ); |
| 482 | while( db_step(&q)==SQLITE_ROW ){ |
| 483 | blob_append_escaped_arg(&cmd, db_column_text(&q,0), 1); |
| 484 | nRevert++; |
| 485 | } |
| 486 | db_finalize(&q); |
| 487 | if( nRevert ){ |
| 488 | if( mFlags & PATCH_DRYRUN ){ |
| 489 | fossil_print("%s", blob_str(&cmd)); |
| 490 | }else{ |
| 491 | int rc = fossil_unsafe_system(blob_str(&cmd)); |
| 492 | if( rc ){ |
| 493 | fossil_fatal("unable to do reverts:\n%s", |
| 494 | blob_str(&cmd)); |
| 495 | } |
| 496 | } |
| 497 | } |
| 498 | blob_reset(&cmd); |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | /* Deletions */ |
| 503 | db_prepare(&q, "SELECT pathname FROM patch.chng" |
| 504 | " WHERE origname IS NULL AND delta IS NULL"); |
| 505 |