Fossil SCM

Warn user of before merging private to public, or afterwards with --force.

preben 2023-10-02 12:46 warn-on-merging-private-branch
Commit f3fef43c2e317bbd2837f8ae7167e5d5a6b0fa2f6c9b5c7331547df56b73069b
1 file changed +16 -60
+16 -60
--- src/merge.c
+++ src/merge.c
@@ -337,11 +337,10 @@
337337
int showVfileFlag; /* True if the --show-vfile flag is present */
338338
int keepMergeFlag; /* True if --keep-merge-files is present */
339339
int nConflict = 0; /* Number of conflicts seen */
340340
int nOverwrite = 0; /* Number of unmanaged files overwritten */
341341
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. */
343342
Stmt q;
344343
345344
346345
/* Notation:
347346
**
@@ -410,11 +409,10 @@
410409
/* Mid is specified as an argument on the command-line */
411410
mid = name_to_typed_rid(g.argv[2], "ci");
412411
if( mid==0 || !is_a_version(mid) ){
413412
fossil_fatal("not a version: %s", g.argv[2]);
414413
}
415
- zRefName = mprintf("%s", g.argv[2]);
416414
}else if( g.argc==2 ){
417415
/* No version specified on the command-line so pick the most recent
418416
** leaf that is (1) not the version currently checked out and (2)
419417
** has not already been merged into the current check-out and (3)
420418
** the leaf is not closed and (4) the leaf is in the same branch
@@ -446,66 +444,17 @@
446444
char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
447445
db_column_text(&q, 0), db_column_text(&q, 1),
448446
db_column_text(&q, 3), db_column_text(&q, 2));
449447
comment_print(zCom, db_column_text(&q,2), 0, -1, get_comment_format());
450448
fossil_free(zCom);
451
- zRefName = mprintf("%s", db_column_text(&q, 0));
452449
}
453450
db_finalize(&q);
454451
}else{
455452
usage("?OPTIONS? ?VERSION?");
456453
return;
457454
}
458455
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
-
507456
if( zPivot ){
508457
pid = name_to_typed_rid(zPivot, "ci");
509458
if( pid==0 || !is_a_version(pid) ){
510459
fossil_fatal("not a version: %s", zPivot);
511460
}
@@ -575,27 +524,30 @@
575524
print_checkin_description(mid, 12,
576525
integrateFlag ? "integrate:" : "merge-from:");
577526
print_checkin_description(pid, 12, "baseline:");
578527
}
579528
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
+
580541
db_begin_transaction();
581542
if( !dryRunFlag ) undo_begin();
582543
if( load_vfile_from_rid(mid) && !forceMissingFlag ){
583544
fossil_fatal("missing content, unable to merge");
584545
}
585546
if( load_vfile_from_rid(pid) && !forceMissingFlag ){
586547
fossil_fatal("missing content, unable to merge");
587548
}
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
-
597549
if( zPivot ){
598550
vAncestor = db_exists(
599551
"WITH RECURSIVE ancestor(id) AS ("
600552
" VALUES(%d)"
601553
" UNION"
@@ -1107,6 +1059,10 @@
11071059
}else{
11081060
vmerge_insert(0, mid);
11091061
}
11101062
if( !dryRunFlag ) undo_finish();
11111063
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
+ }
11121068
}
11131069
--- 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

Keyboard Shortcuts

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