Fossil SCM
Add the --dryrun option to "reparent" and "tag add" and "tag cancel". Fix a typo in the command-line help for "reparent".
Commit
9cf12e655fdb03f3d583097182817c22adacd1cd
Parent
1d2e740798a43ce…
1 file changed
+51
-17
+51
-17
| --- src/tag.c | ||
| +++ src/tag.c | ||
| @@ -279,13 +279,26 @@ | ||
| 279 | 279 | db_begin_transaction(); |
| 280 | 280 | tag_insert(zTag, tagtype, zValue, -1, 0.0, rid); |
| 281 | 281 | db_end_transaction(0); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | +/* | |
| 285 | +** OR this value into the tagtype argument to tag_add_artifact to | |
| 286 | +** cause the tag to be displayed on standard output rather than be | |
| 287 | +** inserted. Used for --dryrun options and debugging. | |
| 288 | +*/ | |
| 289 | +#if INTERFACE | |
| 290 | +#define TAG_ADD_DRYRUN 0x04 | |
| 291 | +#endif | |
| 292 | + | |
| 284 | 293 | /* |
| 285 | 294 | ** Add a control record to the repository that either creates |
| 286 | 295 | ** or cancels a tag. |
| 296 | +** | |
| 297 | +** tagtype should normally be 0, 1, or 2. But if the TAG_ADD_DRYRUN bit | |
| 298 | +** is also set, then simply print the text of the tag on standard output | |
| 299 | +** (for testing purposes) rather than create the tag. | |
| 287 | 300 | */ |
| 288 | 301 | void tag_add_artifact( |
| 289 | 302 | const char *zPrefix, /* Prefix to prepend to tag name */ |
| 290 | 303 | const char *zTagname, /* The tag to add or cancel */ |
| 291 | 304 | const char *zObjName, /* Name of object attached to */ |
| @@ -299,11 +312,16 @@ | ||
| 299 | 312 | char *zDate; |
| 300 | 313 | Blob uuid; |
| 301 | 314 | Blob ctrl; |
| 302 | 315 | Blob cksum; |
| 303 | 316 | static const char zTagtype[] = { '-', '+', '*' }; |
| 317 | + int dryRun = 0; | |
| 304 | 318 | |
| 319 | + if( tagtype & TAG_ADD_DRYRUN ){ | |
| 320 | + tagtype &= ~TAG_ADD_DRYRUN; | |
| 321 | + dryRun = 1; | |
| 322 | + } | |
| 305 | 323 | assert( tagtype>=0 && tagtype<=2 ); |
| 306 | 324 | user_select(); |
| 307 | 325 | blob_zero(&uuid); |
| 308 | 326 | blob_append(&uuid, zObjName, -1); |
| 309 | 327 | if( name_to_uuid(&uuid, 9, "*") ){ |
| @@ -333,12 +351,17 @@ | ||
| 333 | 351 | blob_appendf(&ctrl, "\n"); |
| 334 | 352 | } |
| 335 | 353 | blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : login_name()); |
| 336 | 354 | md5sum_blob(&ctrl, &cksum); |
| 337 | 355 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 338 | - nrid = content_put(&ctrl); | |
| 339 | - manifest_crosslink(nrid, &ctrl, MC_PERMIT_HOOKS); | |
| 356 | + if( dryRun ){ | |
| 357 | + fossil_print("%s", blob_str(&ctrl)); | |
| 358 | + blob_reset(&ctrl); | |
| 359 | + }else{ | |
| 360 | + nrid = content_put(&ctrl); | |
| 361 | + manifest_crosslink(nrid, &ctrl, MC_PERMIT_HOOKS); | |
| 362 | + } | |
| 340 | 363 | assert( blob_is_reset(&ctrl) ); |
| 341 | 364 | } |
| 342 | 365 | |
| 343 | 366 | /* |
| 344 | 367 | ** COMMAND: tag |
| @@ -353,23 +376,26 @@ | ||
| 353 | 376 | ** be usable instead of a CHECK-IN in commands such as |
| 354 | 377 | ** update and merge. If the --propagate flag is present, |
| 355 | 378 | ** the tag value propagates to all descendants of CHECK-IN |
| 356 | 379 | ** |
| 357 | 380 | ** Options: |
| 358 | -** --raw Raw tag name. | |
| 359 | -** --propagate Propagating tag. | |
| 360 | -** --date-override DATETIME Set date and time added. | |
| 361 | -** --user-override USER Name USER when adding the tag. | |
| 381 | +** --raw Raw tag name. | |
| 382 | +** --propagate Propagating tag. | |
| 383 | +** --date-override DATETIME Set date and time added. | |
| 384 | +** --user-override USER Name USER when adding the tag. | |
| 385 | +** --dryrun|-n Display the tag text, but to not | |
| 386 | +** actually insert it into the database. | |
| 362 | 387 | ** |
| 363 | 388 | ** The --date-override and --user-override options support |
| 364 | 389 | ** importing history from other SCM systems. DATETIME has |
| 365 | 390 | ** the form 'YYYY-MMM-DD HH:MM:SS'. |
| 366 | 391 | ** |
| 367 | 392 | ** %fossil tag cancel ?--raw? TAGNAME CHECK-IN |
| 368 | 393 | ** |
| 369 | 394 | ** Remove the tag TAGNAME from CHECK-IN, and also remove |
| 370 | -** the propagation of the tag to any descendants. | |
| 395 | +** the propagation of the tag to any descendants. Use the | |
| 396 | +** the --dryrun or -n options to see what would have happened. | |
| 371 | 397 | ** |
| 372 | 398 | ** %fossil tag find ?OPTIONS? TAGNAME |
| 373 | 399 | ** |
| 374 | 400 | ** List all objects that use TAGNAME. TYPE can be "ci" for |
| 375 | 401 | ** check-ins or "e" for events. The limit option limits the number |
| @@ -422,33 +448,37 @@ | ||
| 422 | 448 | goto tag_cmd_usage; |
| 423 | 449 | } |
| 424 | 450 | |
| 425 | 451 | if( strncmp(g.argv[2],"add",n)==0 ){ |
| 426 | 452 | char *zValue; |
| 453 | + int dryRun = 0; | |
| 427 | 454 | const char *zDateOvrd = find_option("date-override",0,1); |
| 428 | 455 | const char *zUserOvrd = find_option("user-override",0,1); |
| 456 | + if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN; | |
| 429 | 457 | if( g.argc!=5 && g.argc!=6 ){ |
| 430 | - usage("add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE?"); | |
| 458 | + usage("add ?options? TAGNAME CHECK-IN ?VALUE?"); | |
| 431 | 459 | } |
| 432 | 460 | zValue = g.argc==6 ? g.argv[5] : 0; |
| 433 | 461 | db_begin_transaction(); |
| 434 | 462 | tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue, |
| 435 | - 1+fPropagate,zDateOvrd,zUserOvrd); | |
| 463 | + 1+fPropagate+dryRun,zDateOvrd,zUserOvrd); | |
| 436 | 464 | db_end_transaction(0); |
| 437 | 465 | }else |
| 438 | 466 | |
| 439 | 467 | if( strncmp(g.argv[2],"branch",n)==0 ){ |
| 440 | 468 | fossil_fatal("the \"fossil tag branch\" command is discontinued\n" |
| 441 | 469 | "Use the \"fossil branch new\" command instead."); |
| 442 | 470 | }else |
| 443 | 471 | |
| 444 | 472 | if( strncmp(g.argv[2],"cancel",n)==0 ){ |
| 473 | + int dryRun = 0; | |
| 474 | + if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN; | |
| 445 | 475 | if( g.argc!=5 ){ |
| 446 | - usage("cancel ?--raw? TAGNAME CHECK-IN"); | |
| 476 | + usage("cancel ?options? TAGNAME CHECK-IN"); | |
| 447 | 477 | } |
| 448 | 478 | db_begin_transaction(); |
| 449 | - tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, 0, 0, 0); | |
| 479 | + tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, dryRun, 0, 0); | |
| 450 | 480 | db_end_transaction(0); |
| 451 | 481 | }else |
| 452 | 482 | |
| 453 | 483 | if( strncmp(g.argv[2],"find",n)==0 ){ |
| 454 | 484 | Stmt q; |
| @@ -562,29 +592,33 @@ | ||
| 562 | 592 | ** |
| 563 | 593 | ** Create a "parent" tag that causes CHECK-IN to be interpreted as a |
| 564 | 594 | ** child of PARENT. If multiple PARENTs are listed, then the first is |
| 565 | 595 | ** the primary parent and others are merge ancestors. |
| 566 | 596 | ** |
| 567 | -** This is an experts-only command. It is used to patch of a repository | |
| 597 | +** This is an experts-only command. It is used to patch up a repository | |
| 568 | 598 | ** that has been damaged by a shun or that has been pieced together from |
| 569 | 599 | ** two or more separate repositories. You should never need to reparent |
| 570 | 600 | ** during normal operations. |
| 571 | 601 | ** |
| 572 | 602 | ** Reparenting is accomplished by adding a parent tag. So to undo the |
| 573 | 603 | ** reparenting operation, simply delete the tag. |
| 574 | 604 | ** |
| 575 | -** --test Make database entries but do not add the tag artifact. | |
| 576 | -** So the reparent operation will be undone by the next | |
| 577 | -** "fossil rebuild" command. | |
| 605 | +** --test Make database entries but do not add the tag artifact. | |
| 606 | +** So the reparent operation will be undone by the next | |
| 607 | +** "fossil rebuild" command. | |
| 608 | +** --dryrun | -n Print the tag that would have been created but do not | |
| 609 | +** actually change the database in any way. | |
| 578 | 610 | */ |
| 579 | 611 | void reparent_cmd(void){ |
| 580 | 612 | int bTest = find_option("test","",0)!=0; |
| 581 | 613 | int rid; |
| 582 | 614 | int i; |
| 583 | 615 | Blob value; |
| 584 | 616 | char *zUuid; |
| 617 | + int dryRun = 0; | |
| 585 | 618 | |
| 619 | + if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN; | |
| 586 | 620 | db_find_and_open_repository(0, 0); |
| 587 | 621 | verify_all_options(); |
| 588 | 622 | if( g.argc<4 ){ |
| 589 | 623 | usage("reparent [OPTIONS] PARENT ..."); |
| 590 | 624 | } |
| @@ -595,15 +629,15 @@ | ||
| 595 | 629 | if( i>3 ) blob_append(&value, " ", 1); |
| 596 | 630 | zUuid = rid_to_uuid(pid); |
| 597 | 631 | blob_append(&value, zUuid, UUID_SIZE); |
| 598 | 632 | fossil_free(zUuid); |
| 599 | 633 | } |
| 600 | - if( bTest ){ | |
| 634 | + if( bTest && !dryRun ){ | |
| 601 | 635 | tag_insert("parent", 1, blob_str(&value), -1, 0.0, rid); |
| 602 | 636 | }else{ |
| 603 | 637 | zUuid = rid_to_uuid(rid); |
| 604 | - tag_add_artifact("","parent",zUuid,blob_str(&value),1,0,0); | |
| 638 | + tag_add_artifact("","parent",zUuid,blob_str(&value),1|dryRun,0,0); | |
| 605 | 639 | } |
| 606 | 640 | } |
| 607 | 641 | |
| 608 | 642 | |
| 609 | 643 | /* |
| 610 | 644 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -279,13 +279,26 @@ | |
| 279 | db_begin_transaction(); |
| 280 | tag_insert(zTag, tagtype, zValue, -1, 0.0, rid); |
| 281 | db_end_transaction(0); |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | ** Add a control record to the repository that either creates |
| 286 | ** or cancels a tag. |
| 287 | */ |
| 288 | void tag_add_artifact( |
| 289 | const char *zPrefix, /* Prefix to prepend to tag name */ |
| 290 | const char *zTagname, /* The tag to add or cancel */ |
| 291 | const char *zObjName, /* Name of object attached to */ |
| @@ -299,11 +312,16 @@ | |
| 299 | char *zDate; |
| 300 | Blob uuid; |
| 301 | Blob ctrl; |
| 302 | Blob cksum; |
| 303 | static const char zTagtype[] = { '-', '+', '*' }; |
| 304 | |
| 305 | assert( tagtype>=0 && tagtype<=2 ); |
| 306 | user_select(); |
| 307 | blob_zero(&uuid); |
| 308 | blob_append(&uuid, zObjName, -1); |
| 309 | if( name_to_uuid(&uuid, 9, "*") ){ |
| @@ -333,12 +351,17 @@ | |
| 333 | blob_appendf(&ctrl, "\n"); |
| 334 | } |
| 335 | blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : login_name()); |
| 336 | md5sum_blob(&ctrl, &cksum); |
| 337 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 338 | nrid = content_put(&ctrl); |
| 339 | manifest_crosslink(nrid, &ctrl, MC_PERMIT_HOOKS); |
| 340 | assert( blob_is_reset(&ctrl) ); |
| 341 | } |
| 342 | |
| 343 | /* |
| 344 | ** COMMAND: tag |
| @@ -353,23 +376,26 @@ | |
| 353 | ** be usable instead of a CHECK-IN in commands such as |
| 354 | ** update and merge. If the --propagate flag is present, |
| 355 | ** the tag value propagates to all descendants of CHECK-IN |
| 356 | ** |
| 357 | ** Options: |
| 358 | ** --raw Raw tag name. |
| 359 | ** --propagate Propagating tag. |
| 360 | ** --date-override DATETIME Set date and time added. |
| 361 | ** --user-override USER Name USER when adding the tag. |
| 362 | ** |
| 363 | ** The --date-override and --user-override options support |
| 364 | ** importing history from other SCM systems. DATETIME has |
| 365 | ** the form 'YYYY-MMM-DD HH:MM:SS'. |
| 366 | ** |
| 367 | ** %fossil tag cancel ?--raw? TAGNAME CHECK-IN |
| 368 | ** |
| 369 | ** Remove the tag TAGNAME from CHECK-IN, and also remove |
| 370 | ** the propagation of the tag to any descendants. |
| 371 | ** |
| 372 | ** %fossil tag find ?OPTIONS? TAGNAME |
| 373 | ** |
| 374 | ** List all objects that use TAGNAME. TYPE can be "ci" for |
| 375 | ** check-ins or "e" for events. The limit option limits the number |
| @@ -422,33 +448,37 @@ | |
| 422 | goto tag_cmd_usage; |
| 423 | } |
| 424 | |
| 425 | if( strncmp(g.argv[2],"add",n)==0 ){ |
| 426 | char *zValue; |
| 427 | const char *zDateOvrd = find_option("date-override",0,1); |
| 428 | const char *zUserOvrd = find_option("user-override",0,1); |
| 429 | if( g.argc!=5 && g.argc!=6 ){ |
| 430 | usage("add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE?"); |
| 431 | } |
| 432 | zValue = g.argc==6 ? g.argv[5] : 0; |
| 433 | db_begin_transaction(); |
| 434 | tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue, |
| 435 | 1+fPropagate,zDateOvrd,zUserOvrd); |
| 436 | db_end_transaction(0); |
| 437 | }else |
| 438 | |
| 439 | if( strncmp(g.argv[2],"branch",n)==0 ){ |
| 440 | fossil_fatal("the \"fossil tag branch\" command is discontinued\n" |
| 441 | "Use the \"fossil branch new\" command instead."); |
| 442 | }else |
| 443 | |
| 444 | if( strncmp(g.argv[2],"cancel",n)==0 ){ |
| 445 | if( g.argc!=5 ){ |
| 446 | usage("cancel ?--raw? TAGNAME CHECK-IN"); |
| 447 | } |
| 448 | db_begin_transaction(); |
| 449 | tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, 0, 0, 0); |
| 450 | db_end_transaction(0); |
| 451 | }else |
| 452 | |
| 453 | if( strncmp(g.argv[2],"find",n)==0 ){ |
| 454 | Stmt q; |
| @@ -562,29 +592,33 @@ | |
| 562 | ** |
| 563 | ** Create a "parent" tag that causes CHECK-IN to be interpreted as a |
| 564 | ** child of PARENT. If multiple PARENTs are listed, then the first is |
| 565 | ** the primary parent and others are merge ancestors. |
| 566 | ** |
| 567 | ** This is an experts-only command. It is used to patch of a repository |
| 568 | ** that has been damaged by a shun or that has been pieced together from |
| 569 | ** two or more separate repositories. You should never need to reparent |
| 570 | ** during normal operations. |
| 571 | ** |
| 572 | ** Reparenting is accomplished by adding a parent tag. So to undo the |
| 573 | ** reparenting operation, simply delete the tag. |
| 574 | ** |
| 575 | ** --test Make database entries but do not add the tag artifact. |
| 576 | ** So the reparent operation will be undone by the next |
| 577 | ** "fossil rebuild" command. |
| 578 | */ |
| 579 | void reparent_cmd(void){ |
| 580 | int bTest = find_option("test","",0)!=0; |
| 581 | int rid; |
| 582 | int i; |
| 583 | Blob value; |
| 584 | char *zUuid; |
| 585 | |
| 586 | db_find_and_open_repository(0, 0); |
| 587 | verify_all_options(); |
| 588 | if( g.argc<4 ){ |
| 589 | usage("reparent [OPTIONS] PARENT ..."); |
| 590 | } |
| @@ -595,15 +629,15 @@ | |
| 595 | if( i>3 ) blob_append(&value, " ", 1); |
| 596 | zUuid = rid_to_uuid(pid); |
| 597 | blob_append(&value, zUuid, UUID_SIZE); |
| 598 | fossil_free(zUuid); |
| 599 | } |
| 600 | if( bTest ){ |
| 601 | tag_insert("parent", 1, blob_str(&value), -1, 0.0, rid); |
| 602 | }else{ |
| 603 | zUuid = rid_to_uuid(rid); |
| 604 | tag_add_artifact("","parent",zUuid,blob_str(&value),1,0,0); |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | |
| 609 | /* |
| 610 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -279,13 +279,26 @@ | |
| 279 | db_begin_transaction(); |
| 280 | tag_insert(zTag, tagtype, zValue, -1, 0.0, rid); |
| 281 | db_end_transaction(0); |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | ** OR this value into the tagtype argument to tag_add_artifact to |
| 286 | ** cause the tag to be displayed on standard output rather than be |
| 287 | ** inserted. Used for --dryrun options and debugging. |
| 288 | */ |
| 289 | #if INTERFACE |
| 290 | #define TAG_ADD_DRYRUN 0x04 |
| 291 | #endif |
| 292 | |
| 293 | /* |
| 294 | ** Add a control record to the repository that either creates |
| 295 | ** or cancels a tag. |
| 296 | ** |
| 297 | ** tagtype should normally be 0, 1, or 2. But if the TAG_ADD_DRYRUN bit |
| 298 | ** is also set, then simply print the text of the tag on standard output |
| 299 | ** (for testing purposes) rather than create the tag. |
| 300 | */ |
| 301 | void tag_add_artifact( |
| 302 | const char *zPrefix, /* Prefix to prepend to tag name */ |
| 303 | const char *zTagname, /* The tag to add or cancel */ |
| 304 | const char *zObjName, /* Name of object attached to */ |
| @@ -299,11 +312,16 @@ | |
| 312 | char *zDate; |
| 313 | Blob uuid; |
| 314 | Blob ctrl; |
| 315 | Blob cksum; |
| 316 | static const char zTagtype[] = { '-', '+', '*' }; |
| 317 | int dryRun = 0; |
| 318 | |
| 319 | if( tagtype & TAG_ADD_DRYRUN ){ |
| 320 | tagtype &= ~TAG_ADD_DRYRUN; |
| 321 | dryRun = 1; |
| 322 | } |
| 323 | assert( tagtype>=0 && tagtype<=2 ); |
| 324 | user_select(); |
| 325 | blob_zero(&uuid); |
| 326 | blob_append(&uuid, zObjName, -1); |
| 327 | if( name_to_uuid(&uuid, 9, "*") ){ |
| @@ -333,12 +351,17 @@ | |
| 351 | blob_appendf(&ctrl, "\n"); |
| 352 | } |
| 353 | blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : login_name()); |
| 354 | md5sum_blob(&ctrl, &cksum); |
| 355 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 356 | if( dryRun ){ |
| 357 | fossil_print("%s", blob_str(&ctrl)); |
| 358 | blob_reset(&ctrl); |
| 359 | }else{ |
| 360 | nrid = content_put(&ctrl); |
| 361 | manifest_crosslink(nrid, &ctrl, MC_PERMIT_HOOKS); |
| 362 | } |
| 363 | assert( blob_is_reset(&ctrl) ); |
| 364 | } |
| 365 | |
| 366 | /* |
| 367 | ** COMMAND: tag |
| @@ -353,23 +376,26 @@ | |
| 376 | ** be usable instead of a CHECK-IN in commands such as |
| 377 | ** update and merge. If the --propagate flag is present, |
| 378 | ** the tag value propagates to all descendants of CHECK-IN |
| 379 | ** |
| 380 | ** Options: |
| 381 | ** --raw Raw tag name. |
| 382 | ** --propagate Propagating tag. |
| 383 | ** --date-override DATETIME Set date and time added. |
| 384 | ** --user-override USER Name USER when adding the tag. |
| 385 | ** --dryrun|-n Display the tag text, but to not |
| 386 | ** actually insert it into the database. |
| 387 | ** |
| 388 | ** The --date-override and --user-override options support |
| 389 | ** importing history from other SCM systems. DATETIME has |
| 390 | ** the form 'YYYY-MMM-DD HH:MM:SS'. |
| 391 | ** |
| 392 | ** %fossil tag cancel ?--raw? TAGNAME CHECK-IN |
| 393 | ** |
| 394 | ** Remove the tag TAGNAME from CHECK-IN, and also remove |
| 395 | ** the propagation of the tag to any descendants. Use the |
| 396 | ** the --dryrun or -n options to see what would have happened. |
| 397 | ** |
| 398 | ** %fossil tag find ?OPTIONS? TAGNAME |
| 399 | ** |
| 400 | ** List all objects that use TAGNAME. TYPE can be "ci" for |
| 401 | ** check-ins or "e" for events. The limit option limits the number |
| @@ -422,33 +448,37 @@ | |
| 448 | goto tag_cmd_usage; |
| 449 | } |
| 450 | |
| 451 | if( strncmp(g.argv[2],"add",n)==0 ){ |
| 452 | char *zValue; |
| 453 | int dryRun = 0; |
| 454 | const char *zDateOvrd = find_option("date-override",0,1); |
| 455 | const char *zUserOvrd = find_option("user-override",0,1); |
| 456 | if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN; |
| 457 | if( g.argc!=5 && g.argc!=6 ){ |
| 458 | usage("add ?options? TAGNAME CHECK-IN ?VALUE?"); |
| 459 | } |
| 460 | zValue = g.argc==6 ? g.argv[5] : 0; |
| 461 | db_begin_transaction(); |
| 462 | tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue, |
| 463 | 1+fPropagate+dryRun,zDateOvrd,zUserOvrd); |
| 464 | db_end_transaction(0); |
| 465 | }else |
| 466 | |
| 467 | if( strncmp(g.argv[2],"branch",n)==0 ){ |
| 468 | fossil_fatal("the \"fossil tag branch\" command is discontinued\n" |
| 469 | "Use the \"fossil branch new\" command instead."); |
| 470 | }else |
| 471 | |
| 472 | if( strncmp(g.argv[2],"cancel",n)==0 ){ |
| 473 | int dryRun = 0; |
| 474 | if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN; |
| 475 | if( g.argc!=5 ){ |
| 476 | usage("cancel ?options? TAGNAME CHECK-IN"); |
| 477 | } |
| 478 | db_begin_transaction(); |
| 479 | tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, dryRun, 0, 0); |
| 480 | db_end_transaction(0); |
| 481 | }else |
| 482 | |
| 483 | if( strncmp(g.argv[2],"find",n)==0 ){ |
| 484 | Stmt q; |
| @@ -562,29 +592,33 @@ | |
| 592 | ** |
| 593 | ** Create a "parent" tag that causes CHECK-IN to be interpreted as a |
| 594 | ** child of PARENT. If multiple PARENTs are listed, then the first is |
| 595 | ** the primary parent and others are merge ancestors. |
| 596 | ** |
| 597 | ** This is an experts-only command. It is used to patch up a repository |
| 598 | ** that has been damaged by a shun or that has been pieced together from |
| 599 | ** two or more separate repositories. You should never need to reparent |
| 600 | ** during normal operations. |
| 601 | ** |
| 602 | ** Reparenting is accomplished by adding a parent tag. So to undo the |
| 603 | ** reparenting operation, simply delete the tag. |
| 604 | ** |
| 605 | ** --test Make database entries but do not add the tag artifact. |
| 606 | ** So the reparent operation will be undone by the next |
| 607 | ** "fossil rebuild" command. |
| 608 | ** --dryrun | -n Print the tag that would have been created but do not |
| 609 | ** actually change the database in any way. |
| 610 | */ |
| 611 | void reparent_cmd(void){ |
| 612 | int bTest = find_option("test","",0)!=0; |
| 613 | int rid; |
| 614 | int i; |
| 615 | Blob value; |
| 616 | char *zUuid; |
| 617 | int dryRun = 0; |
| 618 | |
| 619 | if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN; |
| 620 | db_find_and_open_repository(0, 0); |
| 621 | verify_all_options(); |
| 622 | if( g.argc<4 ){ |
| 623 | usage("reparent [OPTIONS] PARENT ..."); |
| 624 | } |
| @@ -595,15 +629,15 @@ | |
| 629 | if( i>3 ) blob_append(&value, " ", 1); |
| 630 | zUuid = rid_to_uuid(pid); |
| 631 | blob_append(&value, zUuid, UUID_SIZE); |
| 632 | fossil_free(zUuid); |
| 633 | } |
| 634 | if( bTest && !dryRun ){ |
| 635 | tag_insert("parent", 1, blob_str(&value), -1, 0.0, rid); |
| 636 | }else{ |
| 637 | zUuid = rid_to_uuid(rid); |
| 638 | tag_add_artifact("","parent",zUuid,blob_str(&value),1|dryRun,0,0); |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | |
| 643 | /* |
| 644 |