Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | General enhancements to the "amend", "tag", and "reparent" command, including adding flags like --override-date, --override-user, and --dry-run. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
5c9955710fc68466e3818f768fc8bebb |
| User & Date: | drh 2018-12-27 20:41:17.267 |
Context
|
2018-12-27
| ||
| 21:56 | Much faster rendering of branch timelines. ... (check-in: fe40b652fe user: drh tags: trunk) | |
| 20:41 | General enhancements to the "amend", "tag", and "reparent" command, including adding flags like --override-date, --override-user, and --dry-run. ... (check-in: 5c9955710f user: drh tags: trunk) | |
| 20:37 | Updates to the /brtimeline and /tagtimeline pages. ... (check-in: efb903f939 user: drh tags: trunk) | |
| 12:36 | Remove two unused variables (introduced by [2efcd19f14] through copy-and-paste) ... (Closed-Leaf check-in: cf0f6fc80b user: florian tags: cmd-options-amend) | |
Changes
Changes to src/info.c.
| ︙ | ︙ | |||
2509 2510 2511 2512 2513 2514 2515 | change_sym_tag(zNewBranch,"*"); } /* ** The apply_newtags method is called after all newtags have been added ** and the control artifact is completed and then written to the DB. */ | | > > > > > > > > > | > > > > > > | | | | < | > > | 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 |
change_sym_tag(zNewBranch,"*");
}
/*
** The apply_newtags method is called after all newtags have been added
** and the control artifact is completed and then written to the DB.
*/
static void apply_newtags(
Blob *ctrl,
int rid,
const char *zUuid,
const char *zUserOvrd, /* The user name on the control artifact */
int fDryRun /* Print control artifact, but make no changes */
){
Stmt q;
int nChng = 0;
db_prepare(&q, "SELECT tag, prefix, value FROM newtags"
" ORDER BY prefix || tag");
while( db_step(&q)==SQLITE_ROW ){
const char *zTag = db_column_text(&q, 0);
const char *zPrefix = db_column_text(&q, 1);
const char *zValue = db_column_text(&q, 2);
nChng++;
if( zValue ){
blob_appendf(ctrl, "T %s%F %s %F\n", zPrefix, zTag, zUuid, zValue);
}else{
blob_appendf(ctrl, "T %s%F %s\n", zPrefix, zTag, zUuid);
}
}
db_finalize(&q);
if( nChng>0 ){
int nrid;
Blob cksum;
if( zUserOvrd && zUserOvrd[0] ){
blob_appendf(ctrl, "U %F\n", zUserOvrd);
}else{
blob_appendf(ctrl, "U %F\n", login_name());
}
md5sum_blob(ctrl, &cksum);
blob_appendf(ctrl, "Z %b\n", &cksum);
if( fDryRun ){
assert( g.isHTTP==0 ); /* Only print control artifact in console mode. */
fossil_print("%s", blob_str(ctrl));
blob_reset(ctrl);
}else{
db_begin_transaction();
g.markPrivate = content_is_private(rid);
nrid = content_put(ctrl);
manifest_crosslink(nrid, ctrl, MC_PERMIT_HOOKS);
db_end_transaction(0);
}
assert( blob_is_reset(ctrl) );
}
}
/*
** This method checks that the date can be parsed.
** Returns 1 if datetime() can validate, 0 otherwise.
*/
|
| ︙ | ︙ | |||
2678 2679 2680 2681 2682 2683 2684 |
if( P(zLabel) ) cancel_special(zTag);
}
db_finalize(&q);
if( zHideFlag[0] ) hide_branch();
if( zCloseFlag[0] ) close_leaf(rid);
if( zNewTagFlag[0] && zNewTag[0] ) add_tag(zNewTag);
if( zNewBrFlag[0] && zNewBranch[0] ) change_branch(rid,zNewBranch);
| | | 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 |
if( P(zLabel) ) cancel_special(zTag);
}
db_finalize(&q);
if( zHideFlag[0] ) hide_branch();
if( zCloseFlag[0] ) close_leaf(rid);
if( zNewTagFlag[0] && zNewTag[0] ) add_tag(zNewTag);
if( zNewBrFlag[0] && zNewBranch[0] ) change_branch(rid,zNewBranch);
apply_newtags(&ctrl, rid, zUuid, 0, 0);
cgi_redirectf("%R/ci/%S", zUuid);
}
blob_zero(&comment);
blob_append(&comment, zNewComment, -1);
zUuid[10] = 0;
style_header("Edit Check-in [%s]", zUuid);
if( P("preview") ){
|
| ︙ | ︙ | |||
2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 | ** --bgcolor COLOR Apply COLOR to this check-in ** --branchcolor COLOR Apply and propagate COLOR to the branch ** --tag TAG Add new TAG to this check-in ** --cancel TAG Cancel TAG from this check-in ** --branch NAME Make this check-in the start of branch NAME ** --hide Hide branch starting from this check-in ** --close Mark this "leaf" as closed ** ** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in ** year-month-day form, it may be truncated, the "T" may be replaced by ** a space, and it may also name a timezone offset from UTC as "-HH:MM" ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" ** means UTC. */ | > > > | 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 | ** --bgcolor COLOR Apply COLOR to this check-in ** --branchcolor COLOR Apply and propagate COLOR to the branch ** --tag TAG Add new TAG to this check-in ** --cancel TAG Cancel TAG from this check-in ** --branch NAME Make this check-in the start of branch NAME ** --hide Hide branch starting from this check-in ** --close Mark this "leaf" as closed ** -n|--dry-run Print control artifact, but make no changes ** --date-override DATETIME Set the change time on the control artifact ** --user-override USER Set the user name on the control artifact ** ** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in ** year-month-day form, it may be truncated, the "T" may be replaced by ** a space, and it may also name a timezone offset from UTC as "-HH:MM" ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" ** means UTC. */ |
| ︙ | ︙ | |||
2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 | int fClose; /* True if leaf should be closed */ int fHide; /* True if branch should be hidden */ int fPropagateColor; /* True if color propagates before amend */ int fNewPropagateColor = 0; /* True if color propagates after amend */ int fHasHidden = 0; /* True if hidden tag already set */ int fHasClosed = 0; /* True if closed tag already set */ int fEditComment; /* True if editor to be used for comment */ const char *zChngTime; /* The change time on the control artifact */ const char *zUuid; Blob ctrl; Blob comment; char *zNow; int nTags, nCancels; int i; Stmt q; | > > | 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 | int fClose; /* True if leaf should be closed */ int fHide; /* True if branch should be hidden */ int fPropagateColor; /* True if color propagates before amend */ int fNewPropagateColor = 0; /* True if color propagates after amend */ int fHasHidden = 0; /* True if hidden tag already set */ int fHasClosed = 0; /* True if closed tag already set */ int fEditComment; /* True if editor to be used for comment */ int fDryRun; /* Print control artifact, make no changes */ const char *zChngTime; /* The change time on the control artifact */ const char *zUserOvrd; /* The user name on the control artifact */ const char *zUuid; Blob ctrl; Blob comment; char *zNow; int nTags, nCancels; int i; Stmt q; |
| ︙ | ︙ | |||
2987 2988 2989 2990 2991 2992 2993 |
}
zNewDate = find_option("date",0,1);
zNewUser = find_option("author",0,1);
pzNewTags = find_repeatable_option("tag",0,&nTags);
pzCancelTags = find_repeatable_option("cancel",0,&nCancels);
fClose = find_option("close",0,0)!=0;
fHide = find_option("hide",0,0)!=0;
| > > | > > | 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 |
}
zNewDate = find_option("date",0,1);
zNewUser = find_option("author",0,1);
pzNewTags = find_repeatable_option("tag",0,&nTags);
pzCancelTags = find_repeatable_option("cancel",0,&nCancels);
fClose = find_option("close",0,0)!=0;
fHide = find_option("hide",0,0)!=0;
fDryRun = find_option("dry-run","n",0)!=0;
if( fDryRun==0 ) fDryRun = find_option("dryrun","n",0)!=0;
zChngTime = find_option("date-override",0,1);
if( zChngTime==0 ) zChngTime = find_option("chngtime",0,1);
zUserOvrd = find_option("user-override",0,1);
db_find_and_open_repository(0,0);
user_select();
verify_all_options();
if( g.argc<3 || g.argc>=4 ) usage(AMEND_USAGE_STMT);
rid = name_to_typed_rid(g.argv[2], "ci");
if( rid==0 && !is_a_version(rid) ) fossil_fatal("no such check-in");
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
|
| ︙ | ︙ | |||
3083 3084 3085 3086 3087 3088 3089 |
cancel_tag(rid,pzCancelTags[i]);
}
fossil_free((void *)pzCancelTags);
}
if( fHide && !fHasHidden ) hide_branch();
if( fClose && !fHasClosed ) close_leaf(rid);
if( zNewBranch && zNewBranch[0] ) change_branch(rid,zNewBranch);
| | > | | > | 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 |
cancel_tag(rid,pzCancelTags[i]);
}
fossil_free((void *)pzCancelTags);
}
if( fHide && !fHasHidden ) hide_branch();
if( fClose && !fHasClosed ) close_leaf(rid);
if( zNewBranch && zNewBranch[0] ) change_branch(rid,zNewBranch);
apply_newtags(&ctrl, rid, zUuid, zUserOvrd, fDryRun);
if( fDryRun==0 ){
show_common_info(rid, "uuid:", 1, 0);
}
}
|
Changes to src/tag.c.
| ︙ | ︙ | |||
392 393 394 395 396 397 398 399 400 401 402 403 404 405 | ** ** %fossil tag cancel ?--raw? TAGNAME CHECK-IN ** ** Remove the tag TAGNAME from CHECK-IN, and also remove ** the propagation of the tag to any descendants. Use the ** the --dryrun or -n options to see what would have happened. ** ** %fossil tag find ?OPTIONS? TAGNAME ** ** List all objects that use TAGNAME. TYPE can be "ci" for ** check-ins or "e" for events. The limit option limits the number ** of results to the given value. ** ** Options: | > > > > > > > | 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | ** ** %fossil tag cancel ?--raw? TAGNAME CHECK-IN ** ** Remove the tag TAGNAME from CHECK-IN, and also remove ** the propagation of the tag to any descendants. Use the ** the --dryrun or -n options to see what would have happened. ** ** Options: ** --raw Raw tag name. ** --date-override DATETIME Set date and time deleted. ** --user-override USER Name USER when deleting the tag. ** --dryrun|-n Display the control artifact, but do ** not insert it into the database. ** ** %fossil tag find ?OPTIONS? TAGNAME ** ** List all objects that use TAGNAME. TYPE can be "ci" for ** check-ins or "e" for events. The limit option limits the number ** of results to the given value. ** ** Options: |
| ︙ | ︙ | |||
430 431 432 433 434 435 436 |
** fossil update tag:decaf
**
** will assume that "decaf" is a tag/branch name.
**
*/
void tag_cmd(void){
int n;
| < < < < < > > > > > > > | > > > > | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
** fossil update tag:decaf
**
** will assume that "decaf" is a tag/branch name.
**
*/
void tag_cmd(void){
int n;
db_find_and_open_repository(0, 0);
if( g.argc<3 ){
goto tag_cmd_usage;
}
n = strlen(g.argv[2]);
if( n==0 ){
goto tag_cmd_usage;
}
if( strncmp(g.argv[2],"add",n)==0 ){
char *zValue;
int dryRun = 0;
int fRaw = find_option("raw","",0)!=0;
const char *zPrefix = fRaw ? "" : "sym-";
int fPropagate = find_option("propagate","",0)!=0;
const char *zDateOvrd = find_option("date-override",0,1);
const char *zUserOvrd = find_option("user-override",0,1);
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
if( g.argc!=5 && g.argc!=6 ){
usage("add ?options? TAGNAME CHECK-IN ?VALUE?");
}
zValue = g.argc==6 ? g.argv[5] : 0;
db_begin_transaction();
tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue,
1+fPropagate+dryRun,zDateOvrd,zUserOvrd);
db_end_transaction(0);
}else
if( strncmp(g.argv[2],"branch",n)==0 ){
fossil_fatal("the \"fossil tag branch\" command is discontinued\n"
"Use the \"fossil branch new\" command instead.");
}else
if( strncmp(g.argv[2],"cancel",n)==0 ){
int dryRun = 0;
int fRaw = find_option("raw","",0)!=0;
const char *zPrefix = fRaw ? "" : "sym-";
const char *zDateOvrd = find_option("date-override",0,1);
const char *zUserOvrd = find_option("user-override",0,1);
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
if( g.argc!=5 ){
usage("cancel ?options? TAGNAME CHECK-IN");
}
db_begin_transaction();
tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, dryRun,
zDateOvrd, zUserOvrd);
db_end_transaction(0);
}else
if( strncmp(g.argv[2],"find",n)==0 ){
Stmt q;
int fRaw = find_option("raw","",0)!=0;
const char *zFindLimit = find_option("limit","n",1);
const int nFindLimit = zFindLimit ? atoi(zFindLimit) : -2000;
const char *zType = find_option("type","t",1);
Blob sql = empty_blob;
if( zType==0 || zType[0]==0 ) zType = "*";
if( g.argc!=4 ){
usage("find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME");
}
if( fRaw ){
|
| ︙ | ︙ | |||
526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
db_finalize(&q);
}
}
}else
if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
Stmt q;
if( g.argc==3 ){
db_prepare(&q,
"SELECT tagname FROM tag"
" WHERE EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=tag.tagid"
" AND tagtype>0)"
" ORDER BY tagname"
| > | 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
db_finalize(&q);
}
}
}else
if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
Stmt q;
int fRaw = find_option("raw","",0)!=0;
if( g.argc==3 ){
db_prepare(&q,
"SELECT tagname FROM tag"
" WHERE EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=tag.tagid"
" AND tagtype>0)"
" ORDER BY tagname"
|
| ︙ | ︙ | |||
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
** reparenting operation, simply delete the tag.
**
** --test Make database entries but do not add the tag artifact.
** So the reparent operation will be undone by the next
** "fossil rebuild" command.
** --dryrun | -n Print the tag that would have been created but do not
** actually change the database in any way.
*/
void reparent_cmd(void){
int bTest = find_option("test","",0)!=0;
int rid;
int i;
Blob value;
char *zUuid;
int dryRun = 0;
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
db_find_and_open_repository(0, 0);
verify_all_options();
if( g.argc<4 ){
usage("[OPTIONS] CHECK-IN PARENT ...");
}
rid = name_to_typed_rid(g.argv[2], "ci");
blob_init(&value, 0, 0);
for(i=3; i<g.argc; i++){
int pid = name_to_typed_rid(g.argv[i], "ci");
if( i>3 ) blob_append(&value, " ", 1);
zUuid = rid_to_uuid(pid);
blob_append(&value, zUuid, strlen(zUuid));
fossil_free(zUuid);
}
if( bTest && !dryRun ){
tag_insert("parent", 1, blob_str(&value), -1, 0.0, rid);
}else{
zUuid = rid_to_uuid(rid);
| > > > > > > | > | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
** reparenting operation, simply delete the tag.
**
** --test Make database entries but do not add the tag artifact.
** So the reparent operation will be undone by the next
** "fossil rebuild" command.
** --dryrun | -n Print the tag that would have been created but do not
** actually change the database in any way.
** --date-override DATETIME Set the change time on the control artifact
** --user-override USER Set the user name on the control artifact
*/
void reparent_cmd(void){
int bTest = find_option("test","",0)!=0;
int rid;
int i;
Blob value;
char *zUuid;
int dryRun = 0;
const char *zDateOvrd; /* The change time on the control artifact */
const char *zUserOvrd; /* The user name on the control artifact */
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
zDateOvrd = find_option("date-override",0,1);
zUserOvrd = find_option("user-override",0,1);
db_find_and_open_repository(0, 0);
verify_all_options();
if( g.argc<4 ){
usage("[OPTIONS] CHECK-IN PARENT ...");
}
rid = name_to_typed_rid(g.argv[2], "ci");
blob_init(&value, 0, 0);
for(i=3; i<g.argc; i++){
int pid = name_to_typed_rid(g.argv[i], "ci");
if( i>3 ) blob_append(&value, " ", 1);
zUuid = rid_to_uuid(pid);
blob_append(&value, zUuid, strlen(zUuid));
fossil_free(zUuid);
}
if( bTest && !dryRun ){
tag_insert("parent", 1, blob_str(&value), -1, 0.0, rid);
}else{
zUuid = rid_to_uuid(rid);
tag_add_artifact("","parent",zUuid,blob_str(&value),1|dryRun,
zDateOvrd,zUserOvrd);
}
}
/*
** WEBPAGE: taglist
**
|
| ︙ | ︙ |