| | @@ -3881,25 +3881,26 @@ |
| 3881 | 3881 | ** Usage: %fossil amend HASH OPTION ?OPTION ...? |
| 3882 | 3882 | ** |
| 3883 | 3883 | ** Amend the tags on check-in HASH to change how it displays in the timeline. |
| 3884 | 3884 | ** |
| 3885 | 3885 | ** Options: |
| 3886 | | -** --author USER Make USER the author for check-in |
| 3887 | | -** -m|--comment COMMENT Make COMMENT the check-in comment |
| 3888 | | -** -M|--message-file FILE Read the amended comment from FILE |
| 3889 | | -** -e|--edit-comment Launch editor to revise comment |
| 3890 | | -** --date DATETIME Make DATETIME the check-in time |
| 3891 | | -** --bgcolor COLOR Apply COLOR to this check-in |
| 3892 | | -** --branchcolor COLOR Apply and propagate COLOR to the branch |
| 3893 | | -** --tag TAG Add new TAG to this check-in |
| 3894 | | -** --cancel TAG Cancel TAG from this check-in |
| 3895 | | -** --branch NAME Rename branch of check-in to NAME |
| 3896 | | -** --hide Hide branch starting from this check-in |
| 3897 | | -** --close Mark this "leaf" as closed |
| 3898 | | -** -n|--dry-run Print control artifact, but make no changes |
| 3899 | | -** --date-override DATETIME Set the change time on the control artifact |
| 3900 | | -** --user-override USER Set the user name on the control artifact |
| 3886 | +** --author USER Make USER the author for check-in |
| 3887 | +** --bgcolor COLOR Apply COLOR to this check-in |
| 3888 | +** --branch NAME Rename branch of check-in to NAME |
| 3889 | +** --branchcolor COLOR Apply and propagate COLOR to the branch |
| 3890 | +** --cancel TAG Cancel TAG from this check-in |
| 3891 | +** --close Mark this "leaf" as closed |
| 3892 | +** --date DATETIME Make DATETIME the check-in time |
| 3893 | +** --date-override DATETIME Set the change time on the control artifact |
| 3894 | +** -e|--edit-comment Launch editor to revise comment |
| 3895 | +** --hide Hide branch starting from this check-in |
| 3896 | +** -m|--comment COMMENT Make COMMENT the check-in comment |
| 3897 | +** -M|--message-file FILE Read the amended comment from FILE |
| 3898 | +** -n|--dry-run Print control artifact, but make no changes |
| 3899 | +** --no-verify-comment Do not validate the check-in comment |
| 3900 | +** --tag TAG Add new TAG to this check-in |
| 3901 | +** --user-override USER Set the user name on the control artifact |
| 3901 | 3902 | ** |
| 3902 | 3903 | ** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in |
| 3903 | 3904 | ** year-month-day form, it may be truncated, the "T" may be replaced by |
| 3904 | 3905 | ** a space, and it may also name a timezone offset from UTC as "-HH:MM" |
| 3905 | 3906 | ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" |
| | @@ -3926,19 +3927,22 @@ |
| 3926 | 3927 | int fNewPropagateColor = 0; /* True if color propagates after amend */ |
| 3927 | 3928 | int fHasHidden = 0; /* True if hidden tag already set */ |
| 3928 | 3929 | int fHasClosed = 0; /* True if closed tag already set */ |
| 3929 | 3930 | int fEditComment; /* True if editor to be used for comment */ |
| 3930 | 3931 | int fDryRun; /* Print control artifact, make no changes */ |
| 3932 | + int noVerifyCom = 0; /* Allow suspicious check-in comments */ |
| 3931 | 3933 | const char *zChngTime; /* The change time on the control artifact */ |
| 3932 | 3934 | const char *zUserOvrd; /* The user name on the control artifact */ |
| 3933 | 3935 | const char *zUuid; |
| 3934 | 3936 | Blob ctrl; |
| 3935 | 3937 | Blob comment; |
| 3936 | 3938 | char *zNow; |
| 3937 | 3939 | int nTags, nCancels; |
| 3938 | 3940 | int i; |
| 3939 | 3941 | Stmt q; |
| 3942 | + int ckComFlgs; /* Flags passed to suspicious_comment() */ |
| 3943 | + |
| 3940 | 3944 | |
| 3941 | 3945 | fEditComment = find_option("edit-comment","e",0)!=0; |
| 3942 | 3946 | zNewComment = find_option("comment","m",1); |
| 3943 | 3947 | zComFile = find_option("message-file","M",1); |
| 3944 | 3948 | zNewBranch = find_option("branch",0,1); |
| | @@ -3956,10 +3960,11 @@ |
| 3956 | 3960 | fHide = find_option("hide",0,0)!=0; |
| 3957 | 3961 | fDryRun = find_option("dry-run","n",0)!=0; |
| 3958 | 3962 | zChngTime = find_option("date-override",0,1); |
| 3959 | 3963 | if( zChngTime==0 ) zChngTime = find_option("chngtime",0,1); |
| 3960 | 3964 | zUserOvrd = find_option("user-override",0,1); |
| 3965 | + noVerifyCom = find_option("no-verify-comment",0,0)!=0; |
| 3961 | 3966 | db_find_and_open_repository(0,0); |
| 3962 | 3967 | user_select(); |
| 3963 | 3968 | verify_all_options(); |
| 3964 | 3969 | if( g.argc<3 || g.argc>=4 ) usage(AMEND_USAGE_STMT); |
| 3965 | 3970 | rid = name_to_typed_rid(g.argv[2], "ci"); |
| | @@ -4014,21 +4019,74 @@ |
| 4014 | 4019 | ); |
| 4015 | 4020 | } |
| 4016 | 4021 | if( (zNewColor!=0 && zNewColor[0]==0) && (zColor && zColor[0] ) ){ |
| 4017 | 4022 | cancel_color(); |
| 4018 | 4023 | } |
| 4019 | | - if( fEditComment ){ |
| 4020 | | - prepare_amend_comment(&comment, zComment, zUuid); |
| 4021 | | - zNewComment = blob_str(&comment); |
| 4022 | | - }else if( zComFile ){ |
| 4023 | | - blob_zero(&comment); |
| 4024 | | - blob_read_from_file(&comment, zComFile, ExtFILE); |
| 4025 | | - blob_to_utf8_no_bom(&comment, 1); |
| 4026 | | - zNewComment = blob_str(&comment); |
| 4027 | | - } |
| 4028 | | - if( zNewComment && zNewComment[0] |
| 4029 | | - && comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment); |
| 4024 | + if( fEditComment || zNewComment || zComFile ){ |
| 4025 | + blob_init(&comment, 0, 0); |
| 4026 | + |
| 4027 | + /* Figure out how much comment verification is requested */ |
| 4028 | + if( noVerifyCom ){ |
| 4029 | + ckComFlgs = 0; |
| 4030 | + }else{ |
| 4031 | + const char *zVerComs = db_get("verify-comments","on"); |
| 4032 | + if( is_false(zVerComs) ){ |
| 4033 | + ckComFlgs = 0; |
| 4034 | + }else if( strcmp(zVerComs,"preview")==0 ){ |
| 4035 | + ckComFlgs = COMCK_PREVIEW | COMCK_LINKS | COMCK_MARKUP; |
| 4036 | + }else if( strcmp(zVerComs,"links")==0 ){ |
| 4037 | + ckComFlgs = COMCK_LINKS; |
| 4038 | + }else{ |
| 4039 | + ckComFlgs = COMCK_LINKS | COMCK_MARKUP; |
| 4040 | + } |
| 4041 | + if( zNewComment || zComFile ){ |
| 4042 | + ckComFlgs = (ckComFlgs & COMCK_LINKS) | COMCK_NOPREVIEW; |
| 4043 | + } |
| 4044 | + } |
| 4045 | + if( fEditComment ){ |
| 4046 | + prepare_amend_comment(&comment, zComment, zUuid); |
| 4047 | + }else if( zComFile ){ |
| 4048 | + blob_read_from_file(&comment, zComFile, ExtFILE); |
| 4049 | + blob_to_utf8_no_bom(&comment, 1); |
| 4050 | + }else if( zNewComment ){ |
| 4051 | + blob_init(&comment, zNewComment, -1); |
| 4052 | + } |
| 4053 | + if( blob_size(&comment)>0 |
| 4054 | + && comment_compare(zComment, blob_str(&comment))==0 |
| 4055 | + ){ |
| 4056 | + int rc; |
| 4057 | + while( (rc = suspicious_comment(&comment, ckComFlgs))!=0 ){ |
| 4058 | + char cReply; |
| 4059 | + Blob ans; |
| 4060 | + if( !fEditComment ){ |
| 4061 | + fossil_fatal("Amend aborted; " |
| 4062 | + "use --no-verify-comment to override"); |
| 4063 | + } |
| 4064 | + if( rc==COMCK_PREVIEW ){ |
| 4065 | + prompt_user("\nContinue (Y/n/e=edit)? ", &ans); |
| 4066 | + }else{ |
| 4067 | + prompt_user("\nContinue (y/n/E=edit)? ", &ans); |
| 4068 | + } |
| 4069 | + cReply = blob_str(&ans)[0]; |
| 4070 | + cReply = fossil_tolower(cReply); |
| 4071 | + blob_reset(&ans); |
| 4072 | + if( cReply=='n' ){ |
| 4073 | + fossil_fatal("Amend aborted."); |
| 4074 | + } |
| 4075 | + if( cReply=='e' || (cReply!='y' && rc!=COMCK_PREVIEW) ){ |
| 4076 | + char *zPrior = blob_materialize(&comment); |
| 4077 | + blob_init(&comment, 0, 0); |
| 4078 | + prepare_amend_comment(&comment, zPrior, zUuid); |
| 4079 | + fossil_free(zPrior); |
| 4080 | + continue; |
| 4081 | + }else{ |
| 4082 | + break; |
| 4083 | + } |
| 4084 | + } |
| 4085 | + } |
| 4086 | + add_comment(blob_str(&comment)); |
| 4087 | + } |
| 4030 | 4088 | if( zNewDate && zNewDate[0] && fossil_strcmp(zDate,zNewDate)!=0 ){ |
| 4031 | 4089 | if( is_datetime(zNewDate) ){ |
| 4032 | 4090 | add_date(zNewDate); |
| 4033 | 4091 | }else{ |
| 4034 | 4092 | fossil_fatal("Unsupported date format, use YYYY-MM-DD HH:MM:SS"); |
| 4035 | 4093 | |