Fossil SCM
Warn user of before merging private to public, or afterwards with --force.
Commit
f3fef43c2e317bbd2837f8ae7167e5d5a6b0fa2f6c9b5c7331547df56b73069b
Parent
c07679128e44390…
1 file changed
+16
-60
+16
-60
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -337,11 +337,10 @@ | ||
| 337 | 337 | int showVfileFlag; /* True if the --show-vfile flag is present */ |
| 338 | 338 | int keepMergeFlag; /* True if --keep-merge-files is present */ |
| 339 | 339 | int nConflict = 0; /* Number of conflicts seen */ |
| 340 | 340 | int nOverwrite = 0; /* Number of unmanaged files overwritten */ |
| 341 | 341 | char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */ |
| 342 | - char *zRefName = 0; /* Name of branch being merged, or fork reference. */ | |
| 343 | 342 | Stmt q; |
| 344 | 343 | |
| 345 | 344 | |
| 346 | 345 | /* Notation: |
| 347 | 346 | ** |
| @@ -410,11 +409,10 @@ | ||
| 410 | 409 | /* Mid is specified as an argument on the command-line */ |
| 411 | 410 | mid = name_to_typed_rid(g.argv[2], "ci"); |
| 412 | 411 | if( mid==0 || !is_a_version(mid) ){ |
| 413 | 412 | fossil_fatal("not a version: %s", g.argv[2]); |
| 414 | 413 | } |
| 415 | - zRefName = mprintf("%s", g.argv[2]); | |
| 416 | 414 | }else if( g.argc==2 ){ |
| 417 | 415 | /* No version specified on the command-line so pick the most recent |
| 418 | 416 | ** leaf that is (1) not the version currently checked out and (2) |
| 419 | 417 | ** has not already been merged into the current check-out and (3) |
| 420 | 418 | ** the leaf is not closed and (4) the leaf is in the same branch |
| @@ -446,66 +444,17 @@ | ||
| 446 | 444 | char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", |
| 447 | 445 | db_column_text(&q, 0), db_column_text(&q, 1), |
| 448 | 446 | db_column_text(&q, 3), db_column_text(&q, 2)); |
| 449 | 447 | comment_print(zCom, db_column_text(&q,2), 0, -1, get_comment_format()); |
| 450 | 448 | fossil_free(zCom); |
| 451 | - zRefName = mprintf("%s", db_column_text(&q, 0)); | |
| 452 | 449 | } |
| 453 | 450 | db_finalize(&q); |
| 454 | 451 | }else{ |
| 455 | 452 | usage("?OPTIONS? ?VERSION?"); |
| 456 | 453 | return; |
| 457 | 454 | } |
| 458 | 455 | |
| 459 | - db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY);"); | |
| 460 | - | |
| 461 | - if( forceFlag==0 && content_is_private(mid) && !content_is_private(vid) ){ | |
| 462 | - Blob ans; | |
| 463 | - char cReply; | |
| 464 | - fossil_warning("Merging UNPUBLISHED %s", zRefName); | |
| 465 | - prompt_user("Publish history before merging (y/n/Abort)? ", &ans); | |
| 466 | - cReply = blob_str(&ans)[0]; | |
| 467 | - blob_reset(&ans); | |
| 468 | - switch( cReply ){ | |
| 469 | - case 'n': | |
| 470 | - case 'N': { | |
| 471 | - break; | |
| 472 | - } | |
| 473 | - | |
| 474 | - case 'y': | |
| 475 | - case 'Y': { | |
| 476 | - db_begin_transaction(); | |
| 477 | - if( db_exists("SELECT 1 FROM tagxref" | |
| 478 | - " WHERE rid=%d AND tagid=%d" | |
| 479 | - " AND tagtype>0 AND value=%Q", | |
| 480 | - mid, TAG_BRANCH, zRefName) ){ | |
| 481 | - int rid = start_of_branch(mid, 1); | |
| 482 | - compute_descendants(rid, 1000000000); | |
| 483 | - }else{ | |
| 484 | - db_multi_exec("INSERT OR IGNORE INTO ok VALUES(%d)", mid); | |
| 485 | - } | |
| 486 | - db_end_transaction(0); | |
| 487 | - fossil_warning("The following artifacts will be published:"); | |
| 488 | - describe_artifacts_to_stdout("IN ok", 0); | |
| 489 | - prompt_user("Publish the listed artifacts (y/N)? ", &ans); | |
| 490 | - cReply = blob_str(&ans)[0]; | |
| 491 | - blob_reset(&ans); | |
| 492 | - if( cReply!='y' && cReply!='Y' ){ | |
| 493 | - fossil_free(zRefName); | |
| 494 | - return; | |
| 495 | - } | |
| 496 | - break; | |
| 497 | - } | |
| 498 | - | |
| 499 | - default: { | |
| 500 | - fossil_free(zRefName); | |
| 501 | - return; | |
| 502 | - } | |
| 503 | - } | |
| 504 | - } | |
| 505 | - fossil_free(zRefName); | |
| 506 | - | |
| 507 | 456 | if( zPivot ){ |
| 508 | 457 | pid = name_to_typed_rid(zPivot, "ci"); |
| 509 | 458 | if( pid==0 || !is_a_version(pid) ){ |
| 510 | 459 | fossil_fatal("not a version: %s", zPivot); |
| 511 | 460 | } |
| @@ -575,27 +524,30 @@ | ||
| 575 | 524 | print_checkin_description(mid, 12, |
| 576 | 525 | integrateFlag ? "integrate:" : "merge-from:"); |
| 577 | 526 | print_checkin_description(pid, 12, "baseline:"); |
| 578 | 527 | } |
| 579 | 528 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 529 | + | |
| 530 | + if( forceFlag==0 && content_is_private(mid) && !content_is_private(vid) ){ | |
| 531 | + Blob ans; | |
| 532 | + char cReply; | |
| 533 | + fossil_warning("Merging UNPUBLISHED artifacts." | |
| 534 | + " Consider using \"fossil publish\" first."); | |
| 535 | + prompt_user("Continue with merge (y/N)? ", &ans); | |
| 536 | + cReply = blob_str(&ans)[0]; | |
| 537 | + blob_reset(&ans); | |
| 538 | + if( cReply!='y' && cReply!='Y' ) return; | |
| 539 | + } | |
| 540 | + | |
| 580 | 541 | db_begin_transaction(); |
| 581 | 542 | if( !dryRunFlag ) undo_begin(); |
| 582 | 543 | if( load_vfile_from_rid(mid) && !forceMissingFlag ){ |
| 583 | 544 | fossil_fatal("missing content, unable to merge"); |
| 584 | 545 | } |
| 585 | 546 | if( load_vfile_from_rid(pid) && !forceMissingFlag ){ |
| 586 | 547 | fossil_fatal("missing content, unable to merge"); |
| 587 | 548 | } |
| 588 | - | |
| 589 | - /* Publish artifacts from private branches if selected above. */ | |
| 590 | - db_multi_exec( | |
| 591 | - "DELETE FROM ok WHERE rid NOT IN private;" | |
| 592 | - "DELETE FROM private WHERE rid IN ok;" | |
| 593 | - "INSERT OR IGNORE INTO unsent SELECT rid FROM ok;" | |
| 594 | - "INSERT OR IGNORE INTO unclustered SELECT rid FROM ok;" | |
| 595 | - ); | |
| 596 | - | |
| 597 | 549 | if( zPivot ){ |
| 598 | 550 | vAncestor = db_exists( |
| 599 | 551 | "WITH RECURSIVE ancestor(id) AS (" |
| 600 | 552 | " VALUES(%d)" |
| 601 | 553 | " UNION" |
| @@ -1107,6 +1059,10 @@ | ||
| 1107 | 1059 | }else{ |
| 1108 | 1060 | vmerge_insert(0, mid); |
| 1109 | 1061 | } |
| 1110 | 1062 | if( !dryRunFlag ) undo_finish(); |
| 1111 | 1063 | db_end_transaction(dryRunFlag); |
| 1064 | + | |
| 1065 | + if( forceFlag==1 && content_is_private(mid) && !content_is_private(vid) ){ | |
| 1066 | + fossil_warning("WARNING: Merged private artifacts to public branch."); | |
| 1067 | + } | |
| 1112 | 1068 | } |
| 1113 | 1069 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -337,11 +337,10 @@ | |
| 337 | int showVfileFlag; /* True if the --show-vfile flag is present */ |
| 338 | int keepMergeFlag; /* True if --keep-merge-files is present */ |
| 339 | int nConflict = 0; /* Number of conflicts seen */ |
| 340 | int nOverwrite = 0; /* Number of unmanaged files overwritten */ |
| 341 | char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */ |
| 342 | char *zRefName = 0; /* Name of branch being merged, or fork reference. */ |
| 343 | Stmt q; |
| 344 | |
| 345 | |
| 346 | /* Notation: |
| 347 | ** |
| @@ -410,11 +409,10 @@ | |
| 410 | /* Mid is specified as an argument on the command-line */ |
| 411 | mid = name_to_typed_rid(g.argv[2], "ci"); |
| 412 | if( mid==0 || !is_a_version(mid) ){ |
| 413 | fossil_fatal("not a version: %s", g.argv[2]); |
| 414 | } |
| 415 | zRefName = mprintf("%s", g.argv[2]); |
| 416 | }else if( g.argc==2 ){ |
| 417 | /* No version specified on the command-line so pick the most recent |
| 418 | ** leaf that is (1) not the version currently checked out and (2) |
| 419 | ** has not already been merged into the current check-out and (3) |
| 420 | ** the leaf is not closed and (4) the leaf is in the same branch |
| @@ -446,66 +444,17 @@ | |
| 446 | char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", |
| 447 | db_column_text(&q, 0), db_column_text(&q, 1), |
| 448 | db_column_text(&q, 3), db_column_text(&q, 2)); |
| 449 | comment_print(zCom, db_column_text(&q,2), 0, -1, get_comment_format()); |
| 450 | fossil_free(zCom); |
| 451 | zRefName = mprintf("%s", db_column_text(&q, 0)); |
| 452 | } |
| 453 | db_finalize(&q); |
| 454 | }else{ |
| 455 | usage("?OPTIONS? ?VERSION?"); |
| 456 | return; |
| 457 | } |
| 458 | |
| 459 | db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY);"); |
| 460 | |
| 461 | if( forceFlag==0 && content_is_private(mid) && !content_is_private(vid) ){ |
| 462 | Blob ans; |
| 463 | char cReply; |
| 464 | fossil_warning("Merging UNPUBLISHED %s", zRefName); |
| 465 | prompt_user("Publish history before merging (y/n/Abort)? ", &ans); |
| 466 | cReply = blob_str(&ans)[0]; |
| 467 | blob_reset(&ans); |
| 468 | switch( cReply ){ |
| 469 | case 'n': |
| 470 | case 'N': { |
| 471 | break; |
| 472 | } |
| 473 | |
| 474 | case 'y': |
| 475 | case 'Y': { |
| 476 | db_begin_transaction(); |
| 477 | if( db_exists("SELECT 1 FROM tagxref" |
| 478 | " WHERE rid=%d AND tagid=%d" |
| 479 | " AND tagtype>0 AND value=%Q", |
| 480 | mid, TAG_BRANCH, zRefName) ){ |
| 481 | int rid = start_of_branch(mid, 1); |
| 482 | compute_descendants(rid, 1000000000); |
| 483 | }else{ |
| 484 | db_multi_exec("INSERT OR IGNORE INTO ok VALUES(%d)", mid); |
| 485 | } |
| 486 | db_end_transaction(0); |
| 487 | fossil_warning("The following artifacts will be published:"); |
| 488 | describe_artifacts_to_stdout("IN ok", 0); |
| 489 | prompt_user("Publish the listed artifacts (y/N)? ", &ans); |
| 490 | cReply = blob_str(&ans)[0]; |
| 491 | blob_reset(&ans); |
| 492 | if( cReply!='y' && cReply!='Y' ){ |
| 493 | fossil_free(zRefName); |
| 494 | return; |
| 495 | } |
| 496 | break; |
| 497 | } |
| 498 | |
| 499 | default: { |
| 500 | fossil_free(zRefName); |
| 501 | return; |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | fossil_free(zRefName); |
| 506 | |
| 507 | if( zPivot ){ |
| 508 | pid = name_to_typed_rid(zPivot, "ci"); |
| 509 | if( pid==0 || !is_a_version(pid) ){ |
| 510 | fossil_fatal("not a version: %s", zPivot); |
| 511 | } |
| @@ -575,27 +524,30 @@ | |
| 575 | print_checkin_description(mid, 12, |
| 576 | integrateFlag ? "integrate:" : "merge-from:"); |
| 577 | print_checkin_description(pid, 12, "baseline:"); |
| 578 | } |
| 579 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 580 | db_begin_transaction(); |
| 581 | if( !dryRunFlag ) undo_begin(); |
| 582 | if( load_vfile_from_rid(mid) && !forceMissingFlag ){ |
| 583 | fossil_fatal("missing content, unable to merge"); |
| 584 | } |
| 585 | if( load_vfile_from_rid(pid) && !forceMissingFlag ){ |
| 586 | fossil_fatal("missing content, unable to merge"); |
| 587 | } |
| 588 | |
| 589 | /* Publish artifacts from private branches if selected above. */ |
| 590 | db_multi_exec( |
| 591 | "DELETE FROM ok WHERE rid NOT IN private;" |
| 592 | "DELETE FROM private WHERE rid IN ok;" |
| 593 | "INSERT OR IGNORE INTO unsent SELECT rid FROM ok;" |
| 594 | "INSERT OR IGNORE INTO unclustered SELECT rid FROM ok;" |
| 595 | ); |
| 596 | |
| 597 | if( zPivot ){ |
| 598 | vAncestor = db_exists( |
| 599 | "WITH RECURSIVE ancestor(id) AS (" |
| 600 | " VALUES(%d)" |
| 601 | " UNION" |
| @@ -1107,6 +1059,10 @@ | |
| 1107 | }else{ |
| 1108 | vmerge_insert(0, mid); |
| 1109 | } |
| 1110 | if( !dryRunFlag ) undo_finish(); |
| 1111 | db_end_transaction(dryRunFlag); |
| 1112 | } |
| 1113 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -337,11 +337,10 @@ | |
| 337 | int showVfileFlag; /* True if the --show-vfile flag is present */ |
| 338 | int keepMergeFlag; /* True if --keep-merge-files is present */ |
| 339 | int nConflict = 0; /* Number of conflicts seen */ |
| 340 | int nOverwrite = 0; /* Number of unmanaged files overwritten */ |
| 341 | char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */ |
| 342 | Stmt q; |
| 343 | |
| 344 | |
| 345 | /* Notation: |
| 346 | ** |
| @@ -410,11 +409,10 @@ | |
| 409 | /* Mid is specified as an argument on the command-line */ |
| 410 | mid = name_to_typed_rid(g.argv[2], "ci"); |
| 411 | if( mid==0 || !is_a_version(mid) ){ |
| 412 | fossil_fatal("not a version: %s", g.argv[2]); |
| 413 | } |
| 414 | }else if( g.argc==2 ){ |
| 415 | /* No version specified on the command-line so pick the most recent |
| 416 | ** leaf that is (1) not the version currently checked out and (2) |
| 417 | ** has not already been merged into the current check-out and (3) |
| 418 | ** the leaf is not closed and (4) the leaf is in the same branch |
| @@ -446,66 +444,17 @@ | |
| 444 | char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", |
| 445 | db_column_text(&q, 0), db_column_text(&q, 1), |
| 446 | db_column_text(&q, 3), db_column_text(&q, 2)); |
| 447 | comment_print(zCom, db_column_text(&q,2), 0, -1, get_comment_format()); |
| 448 | fossil_free(zCom); |
| 449 | } |
| 450 | db_finalize(&q); |
| 451 | }else{ |
| 452 | usage("?OPTIONS? ?VERSION?"); |
| 453 | return; |
| 454 | } |
| 455 | |
| 456 | if( zPivot ){ |
| 457 | pid = name_to_typed_rid(zPivot, "ci"); |
| 458 | if( pid==0 || !is_a_version(pid) ){ |
| 459 | fossil_fatal("not a version: %s", zPivot); |
| 460 | } |
| @@ -575,27 +524,30 @@ | |
| 524 | print_checkin_description(mid, 12, |
| 525 | integrateFlag ? "integrate:" : "merge-from:"); |
| 526 | print_checkin_description(pid, 12, "baseline:"); |
| 527 | } |
| 528 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 529 | |
| 530 | if( forceFlag==0 && content_is_private(mid) && !content_is_private(vid) ){ |
| 531 | Blob ans; |
| 532 | char cReply; |
| 533 | fossil_warning("Merging UNPUBLISHED artifacts." |
| 534 | " Consider using \"fossil publish\" first."); |
| 535 | prompt_user("Continue with merge (y/N)? ", &ans); |
| 536 | cReply = blob_str(&ans)[0]; |
| 537 | blob_reset(&ans); |
| 538 | if( cReply!='y' && cReply!='Y' ) return; |
| 539 | } |
| 540 | |
| 541 | db_begin_transaction(); |
| 542 | if( !dryRunFlag ) undo_begin(); |
| 543 | if( load_vfile_from_rid(mid) && !forceMissingFlag ){ |
| 544 | fossil_fatal("missing content, unable to merge"); |
| 545 | } |
| 546 | if( load_vfile_from_rid(pid) && !forceMissingFlag ){ |
| 547 | fossil_fatal("missing content, unable to merge"); |
| 548 | } |
| 549 | if( zPivot ){ |
| 550 | vAncestor = db_exists( |
| 551 | "WITH RECURSIVE ancestor(id) AS (" |
| 552 | " VALUES(%d)" |
| 553 | " UNION" |
| @@ -1107,6 +1059,10 @@ | |
| 1059 | }else{ |
| 1060 | vmerge_insert(0, mid); |
| 1061 | } |
| 1062 | if( !dryRunFlag ) undo_finish(); |
| 1063 | db_end_transaction(dryRunFlag); |
| 1064 | |
| 1065 | if( forceFlag==1 && content_is_private(mid) && !content_is_private(vid) ){ |
| 1066 | fossil_warning("WARNING: Merged private artifacts to public branch."); |
| 1067 | } |
| 1068 | } |
| 1069 |