| | @@ -565,13 +565,12 @@ |
| 565 | 565 | ** parent_rid is the recordid of the parent check-in. |
| 566 | 566 | */ |
| 567 | 567 | static void prepare_commit_comment( |
| 568 | 568 | Blob *pComment, |
| 569 | 569 | char *zInit, |
| 570 | | - const char *zBranch, |
| 571 | | - int parent_rid, |
| 572 | | - const char *zUserOvrd |
| 570 | + CheckinInfo *p, |
| 571 | + int parent_rid |
| 573 | 572 | ){ |
| 574 | 573 | Blob prompt; |
| 575 | 574 | #ifdef _WIN32 |
| 576 | 575 | int bomSize; |
| 577 | 576 | const unsigned char *bom = get_utf8_bom(&bomSize); |
| | @@ -585,13 +584,13 @@ |
| 585 | 584 | blob_append(&prompt, |
| 586 | 585 | "\n" |
| 587 | 586 | "# Enter comments on this check-in. Lines beginning with # are ignored.\n" |
| 588 | 587 | "#\n", -1 |
| 589 | 588 | ); |
| 590 | | - blob_appendf(&prompt, "# user: %s\n", zUserOvrd ? zUserOvrd : g.zLogin); |
| 591 | | - if( zBranch && zBranch[0] ){ |
| 592 | | - blob_appendf(&prompt, "# tags: %s\n#\n", zBranch); |
| 589 | + blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin); |
| 590 | + if( p->zBranch && p->zBranch[0] ){ |
| 591 | + blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch); |
| 593 | 592 | }else{ |
| 594 | 593 | char *zTags = info_tags_of_checkin(parent_rid, 1); |
| 595 | 594 | if( zTags ) blob_appendf(&prompt, "# tags: %z\n#\n", zTags); |
| 596 | 595 | } |
| 597 | 596 | status_report(&prompt, "# ", 1, 0); |
| | @@ -706,28 +705,39 @@ |
| 706 | 705 | for(i=2; i<g.argc; i++){ |
| 707 | 706 | fossil_print("%s -> %s\n", g.argv[i], date_in_standard_format(g.argv[i])); |
| 708 | 707 | } |
| 709 | 708 | } |
| 710 | 709 | |
| 710 | +#if INTERFACE |
| 711 | +/* |
| 712 | +** The following structure holds some of the information needed to construct a |
| 713 | +** check-in manifest. |
| 714 | +*/ |
| 715 | +struct CheckinInfo { |
| 716 | + Blob *pComment; /* Check-in comment text */ |
| 717 | + const char *zMimetype; /* Mimetype of check-in command. May be NULL */ |
| 718 | + int verifyDate; /* Verify that child is younger */ |
| 719 | + Blob *pCksum; /* Repository checksum. May be 0 */ |
| 720 | + const char *zDateOvrd; /* Date override. If 0 then use 'now' */ |
| 721 | + const char *zUserOvrd; /* User override. If 0 then use g.zLogin */ |
| 722 | + const char *zBranch; /* Branch name. May be 0 */ |
| 723 | + const char *zColor; /* One-time background color. May be 0 */ |
| 724 | + const char *zBrClr; /* Persistent branch color. May be 0 */ |
| 725 | + const char **azTag; /* Tags to apply to this check-in */ |
| 726 | +}; |
| 727 | +#endif /* INTERFACE */ |
| 728 | + |
| 711 | 729 | /* |
| 712 | 730 | ** Create a manifest. |
| 713 | 731 | */ |
| 714 | 732 | static void create_manifest( |
| 715 | 733 | Blob *pOut, /* Write the manifest here */ |
| 716 | 734 | const char *zBaselineUuid, /* UUID of baseline, or zero */ |
| 717 | 735 | Manifest *pBaseline, /* Make it a delta manifest if not zero */ |
| 718 | | - Blob *pComment, /* Check-in comment text */ |
| 719 | | - int vid, /* blob-id of the parent manifest */ |
| 720 | | - int verifyDate, /* Verify that child is younger */ |
| 721 | | - Blob *pCksum, /* Repository checksum. May be 0 */ |
| 722 | | - const char *zDateOvrd, /* Date override. If 0 then use 'now' */ |
| 723 | | - const char *zUserOvrd, /* User override. If 0 then use g.zLogin */ |
| 724 | | - const char *zBranch, /* Branch name. May be 0 */ |
| 725 | | - const char *zColor, /* One-time background color. May be 0 */ |
| 726 | | - const char *zBrClr, /* Persistent branch color. May be 0 */ |
| 727 | | - const char **azTag, /* Tags to apply to this check-in */ |
| 728 | | - int *pnFBcard /* Number of generated B- and F-cards */ |
| 736 | + int vid, /* BLOB.id for the parent check-in */ |
| 737 | + CheckinInfo *p, /* Information about the check-in */ |
| 738 | + int *pnFBcard /* OUT: Number of generated B- and F-cards */ |
| 729 | 739 | ){ |
| 730 | 740 | char *zDate; /* Date of the check-in */ |
| 731 | 741 | char *zParentUuid; /* UUID of parent check-in */ |
| 732 | 742 | Blob filename; /* A single filename */ |
| 733 | 743 | int nBasename; /* Size of base filename */ |
| | @@ -735,10 +745,11 @@ |
| 735 | 745 | Stmt q2; /* Query of merge parents */ |
| 736 | 746 | Blob mcksum; /* Manifest checksum */ |
| 737 | 747 | ManifestFile *pFile; /* File from the baseline */ |
| 738 | 748 | int nFBcard = 0; /* Number of B-cards and F-cards */ |
| 739 | 749 | int i; /* Loop counter */ |
| 750 | + const char *zColor; /* Modified value of p->zColor */ |
| 740 | 751 | |
| 741 | 752 | assert( pBaseline==0 || pBaseline->zBaseline==0 ); |
| 742 | 753 | assert( pBaseline==0 || zBaselineUuid!=0 ); |
| 743 | 754 | blob_zero(pOut); |
| 744 | 755 | zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); |
| | @@ -748,12 +759,12 @@ |
| 748 | 759 | pFile = manifest_file_next(pBaseline, 0); |
| 749 | 760 | nFBcard++; |
| 750 | 761 | }else{ |
| 751 | 762 | pFile = 0; |
| 752 | 763 | } |
| 753 | | - blob_appendf(pOut, "C %F\n", blob_str(pComment)); |
| 754 | | - zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now"); |
| 764 | + blob_appendf(pOut, "C %F\n", blob_str(p->pComment)); |
| 765 | + zDate = date_in_standard_format(p->zDateOvrd ? p->zDateOvrd : "now"); |
| 755 | 766 | blob_appendf(pOut, "D %s\n", zDate); |
| 756 | 767 | zDate[10] = ' '; |
| 757 | 768 | db_prepare(&q, |
| 758 | 769 | "SELECT pathname, uuid, origname, blob.rid, isexe, islink," |
| 759 | 770 | " is_selected(vfile.id)" |
| | @@ -827,67 +838,72 @@ |
| 827 | 838 | while( pFile ){ |
| 828 | 839 | blob_appendf(pOut, "F %F\n", pFile->zName); |
| 829 | 840 | pFile = manifest_file_next(pBaseline, 0); |
| 830 | 841 | nFBcard++; |
| 831 | 842 | } |
| 843 | + if( p->zMimetype && p->zMimetype[0] ){ |
| 844 | + blob_appendf(pOut, "N %F\n", p->zMimetype); |
| 845 | + } |
| 832 | 846 | blob_appendf(pOut, "P %s", zParentUuid); |
| 833 | | - if( verifyDate ) checkin_verify_younger(vid, zParentUuid, zDate); |
| 847 | + if( p->verifyDate ) checkin_verify_younger(vid, zParentUuid, zDate); |
| 834 | 848 | free(zParentUuid); |
| 835 | 849 | db_prepare(&q2, "SELECT merge FROM vmerge WHERE id=0"); |
| 836 | 850 | while( db_step(&q2)==SQLITE_ROW ){ |
| 837 | 851 | char *zMergeUuid; |
| 838 | 852 | int mid = db_column_int(&q2, 0); |
| 839 | 853 | if( !g.markPrivate && content_is_private(mid) ) continue; |
| 840 | 854 | zMergeUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid); |
| 841 | 855 | if( zMergeUuid ){ |
| 842 | 856 | blob_appendf(pOut, " %s", zMergeUuid); |
| 843 | | - if( verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate); |
| 857 | + if( p->verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate); |
| 844 | 858 | free(zMergeUuid); |
| 845 | 859 | } |
| 846 | 860 | } |
| 847 | 861 | db_finalize(&q2); |
| 848 | 862 | free(zDate); |
| 849 | 863 | |
| 850 | 864 | blob_appendf(pOut, "\n"); |
| 851 | | - if( pCksum ) blob_appendf(pOut, "R %b\n", pCksum); |
| 852 | | - if( zBranch && zBranch[0] ){ |
| 865 | + if( p->pCksum ) blob_appendf(pOut, "R %b\n", p->pCksum); |
| 866 | + zColor = p->zColor; |
| 867 | + if( p->zBranch && p->zBranch[0] ){ |
| 853 | 868 | /* Set tags for the new branch */ |
| 854 | | - if( zBrClr && zBrClr[0] ){ |
| 869 | + if( p->zBrClr && p->zBrClr[0] ){ |
| 855 | 870 | zColor = 0; |
| 856 | | - blob_appendf(pOut, "T *bgcolor * %F\n", zBrClr); |
| 871 | + blob_appendf(pOut, "T *bgcolor * %F\n", p->zBrClr); |
| 857 | 872 | } |
| 858 | | - blob_appendf(pOut, "T *branch * %F\n", zBranch); |
| 859 | | - blob_appendf(pOut, "T *sym-%F *\n", zBranch); |
| 873 | + blob_appendf(pOut, "T *branch * %F\n", p->zBranch); |
| 874 | + blob_appendf(pOut, "T *sym-%F *\n", p->zBranch); |
| 860 | 875 | } |
| 861 | 876 | if( zColor && zColor[0] ){ |
| 862 | 877 | /* One-time background color */ |
| 863 | 878 | blob_appendf(pOut, "T +bgcolor * %F\n", zColor); |
| 864 | 879 | } |
| 865 | | - if( azTag ){ |
| 866 | | - for(i=0; azTag[i]; i++){ |
| 880 | + if( p->azTag ){ |
| 881 | + for(i=0; p->azTag[i]; i++){ |
| 867 | 882 | /* Add a symbolic tag to this check-in. The tag names have already |
| 868 | 883 | ** been sorted and converted using the %F format */ |
| 869 | | - blob_appendf(pOut, "T +sym-%s *\n", azTag[i]); |
| 884 | + assert( i==0 || strcmp(p->azTag[i-1], p->azTag[i])<=0 ); |
| 885 | + blob_appendf(pOut, "T +sym-%s *\n", p->azTag[i]); |
| 870 | 886 | } |
| 871 | 887 | } |
| 872 | | - if( zBranch && zBranch[0] ){ |
| 888 | + if( p->zBranch && p->zBranch[0] ){ |
| 873 | 889 | /* For a new branch, cancel all prior propagating tags */ |
| 874 | 890 | Stmt q; |
| 875 | 891 | db_prepare(&q, |
| 876 | 892 | "SELECT tagname FROM tagxref, tag" |
| 877 | 893 | " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" |
| 878 | 894 | " AND tagtype==2 AND tagname GLOB 'sym-*'" |
| 879 | 895 | " AND tagname!='sym-'||%Q" |
| 880 | 896 | " ORDER BY tagname", |
| 881 | | - vid, zBranch); |
| 897 | + vid, p->zBranch); |
| 882 | 898 | while( db_step(&q)==SQLITE_ROW ){ |
| 883 | 899 | const char *zBrTag = db_column_text(&q, 0); |
| 884 | 900 | blob_appendf(pOut, "T -%F *\n", zBrTag); |
| 885 | 901 | } |
| 886 | 902 | db_finalize(&q); |
| 887 | 903 | } |
| 888 | | - blob_appendf(pOut, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); |
| 904 | + blob_appendf(pOut, "U %F\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin); |
| 889 | 905 | md5sum_blob(pOut, &mcksum); |
| 890 | 906 | blob_appendf(pOut, "Z %b\n", &mcksum); |
| 891 | 907 | if( pnFBcard ) *pnFBcard = nFBcard; |
| 892 | 908 | } |
| 893 | 909 | |
| | @@ -1092,10 +1108,11 @@ |
| 1092 | 1108 | ** --branch NEW-BRANCH-NAME check in to this new branch |
| 1093 | 1109 | ** --branchcolor COLOR apply given COLOR to the branch |
| 1094 | 1110 | ** --comment|-m COMMENT-TEXT use COMMENT-TEXT as commit comment |
| 1095 | 1111 | ** --delta use a delta manifest in the commit process |
| 1096 | 1112 | ** --message-file|-M FILE read the commit comment from given file |
| 1113 | +** --mimetype MIMETYPE mimetype of check-in comment |
| 1097 | 1114 | ** --no-warnings omit all warnings about file contents |
| 1098 | 1115 | ** --nosign do not attempt to sign this commit with gpg |
| 1099 | 1116 | ** --private do not sync changes and their descendants |
| 1100 | 1117 | ** --tag TAG-NAME assign given tag TAG-NAME to the checkin |
| 1101 | 1118 | ** |
| | @@ -1122,15 +1139,11 @@ |
| 1122 | 1139 | int allowOlder = 0; /* Allow a commit older than its ancestor */ |
| 1123 | 1140 | char *zManifestFile; /* Name of the manifest file */ |
| 1124 | 1141 | int useCksum; /* True if checksums should be computed and verified */ |
| 1125 | 1142 | int outputManifest; /* True to output "manifest" and "manifest.uuid" */ |
| 1126 | 1143 | int testRun; /* True for a test run. Debugging only */ |
| 1127 | | - const char *zBranch; /* Create a new branch with this name */ |
| 1128 | | - const char *zBrClr; /* Set background color when branching */ |
| 1129 | | - const char *zColor; /* One-time check-in color */ |
| 1130 | | - const char *zDateOvrd; /* Override date string */ |
| 1131 | | - const char *zUserOvrd; /* Override user name */ |
| 1144 | + CheckinInfo sCiInfo; /* Information about this check-in */ |
| 1132 | 1145 | const char *zComFile; /* Read commit message from this file */ |
| 1133 | 1146 | int nTag = 0; /* Number of --tag arguments */ |
| 1134 | 1147 | const char *zTag; /* A single --tag argument */ |
| 1135 | 1148 | const char **azTag = 0;/* Array of all --tag arguments */ |
| 1136 | 1149 | Blob manifest; /* Manifest in baseline form */ |
| | @@ -1142,10 +1155,11 @@ |
| 1142 | 1155 | int nConflict = 0; /* Number of unresolved merge conflicts */ |
| 1143 | 1156 | int abortCommit = 0; |
| 1144 | 1157 | Blob ans; |
| 1145 | 1158 | char cReply; |
| 1146 | 1159 | |
| 1160 | + memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 1147 | 1161 | url_proxy_options(); |
| 1148 | 1162 | noSign = find_option("nosign",0,0)!=0; |
| 1149 | 1163 | forceDelta = find_option("delta",0,0)!=0; |
| 1150 | 1164 | forceBaseline = find_option("baseline",0,0)!=0; |
| 1151 | 1165 | if( forceDelta && forceBaseline ){ |
| | @@ -1157,27 +1171,30 @@ |
| 1157 | 1171 | allowConflict = find_option("allow-conflict",0,0)!=0; |
| 1158 | 1172 | allowEmpty = find_option("allow-empty",0,0)!=0; |
| 1159 | 1173 | allowFork = find_option("allow-fork",0,0)!=0; |
| 1160 | 1174 | allowOlder = find_option("allow-older",0,0)!=0; |
| 1161 | 1175 | noWarningFlag = find_option("no-warnings", 0, 0)!=0; |
| 1162 | | - zBranch = find_option("branch","b",1); |
| 1163 | | - zColor = find_option("bgcolor",0,1); |
| 1164 | | - zBrClr = find_option("branchcolor",0,1); |
| 1176 | + sCiInfo.zBranch = find_option("branch","b",1); |
| 1177 | + sCiInfo.zColor = find_option("bgcolor",0,1); |
| 1178 | + sCiInfo.zBrClr = find_option("branchcolor",0,1); |
| 1179 | + sCiInfo.zMimetype = find_option("mimetype",0,1); |
| 1165 | 1180 | while( (zTag = find_option("tag",0,1))!=0 ){ |
| 1166 | 1181 | if( zTag[0]==0 ) continue; |
| 1167 | | - azTag = fossil_realloc((void *)azTag, sizeof(char*)*(nTag+2)); |
| 1168 | | - azTag[nTag++] = zTag; |
| 1169 | | - azTag[nTag] = 0; |
| 1182 | + sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag, sizeof(char*)*(nTag+2)); |
| 1183 | + sCiInfo.azTag[nTag++] = zTag; |
| 1184 | + sCiInfo.azTag[nTag] = 0; |
| 1170 | 1185 | } |
| 1171 | 1186 | zComFile = find_option("message-file", "M", 1); |
| 1172 | 1187 | if( find_option("private",0,0) ){ |
| 1173 | 1188 | g.markPrivate = 1; |
| 1174 | | - if( zBranch==0 ) zBranch = "private"; |
| 1175 | | - if( zBrClr==0 && zColor==0 ) zBrClr = "#fec084"; /* Orange */ |
| 1189 | + if( sCiInfo.zBranch==0 ) sCiInfo.zBranch = "private"; |
| 1190 | + if( sCiInfo.zBrClr==0 && sCiInfo.zColor==0 ){ |
| 1191 | + sCiInfo.zBrClr = "#fec084"; /* Orange */ |
| 1192 | + } |
| 1176 | 1193 | } |
| 1177 | | - zDateOvrd = find_option("date-override",0,1); |
| 1178 | | - zUserOvrd = find_option("user-override",0,1); |
| 1194 | + sCiInfo.zDateOvrd = find_option("date-override",0,1); |
| 1195 | + sCiInfo.zUserOvrd = find_option("user-override",0,1); |
| 1179 | 1196 | db_must_be_within_tree(); |
| 1180 | 1197 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 1181 | 1198 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 1182 | 1199 | useCksum = db_get_boolean("repo-cksum", 1); |
| 1183 | 1200 | outputManifest = db_get_boolean("manifest", 0); |
| | @@ -1309,11 +1326,11 @@ |
| 1309 | 1326 | |
| 1310 | 1327 | /* |
| 1311 | 1328 | ** Do not allow a commit that will cause a fork unless the --allow-fork |
| 1312 | 1329 | ** or --force flags is used, or unless this is a private check-in. |
| 1313 | 1330 | */ |
| 1314 | | - if( zBranch==0 && allowFork==0 && forceFlag==0 |
| 1331 | + if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0 |
| 1315 | 1332 | && g.markPrivate==0 && !is_a_leaf(vid) |
| 1316 | 1333 | ){ |
| 1317 | 1334 | fossil_fatal("would fork. \"update\" first or use --allow-fork."); |
| 1318 | 1335 | } |
| 1319 | 1336 | |
| | @@ -1334,11 +1351,11 @@ |
| 1334 | 1351 | blob_zero(&comment); |
| 1335 | 1352 | blob_read_from_file(&comment, zComFile); |
| 1336 | 1353 | blob_to_utf8_no_bom(&comment, 1); |
| 1337 | 1354 | }else{ |
| 1338 | 1355 | char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); |
| 1339 | | - prepare_commit_comment(&comment, zInit, zBranch, vid, zUserOvrd); |
| 1356 | + prepare_commit_comment(&comment, zInit, &sCiInfo, vid); |
| 1340 | 1357 | if( zInit && zInit[0] && fossil_strcmp(zInit, blob_str(&comment))==0 ){ |
| 1341 | 1358 | blob_zero(&ans); |
| 1342 | 1359 | prompt_user("unchanged check-in comment. continue (y/N)? ", &ans); |
| 1343 | 1360 | cReply = blob_str(&ans)[0]; |
| 1344 | 1361 | if( cReply!='y' && cReply!='Y' ) fossil_exit(1);; |
| | @@ -1424,17 +1441,21 @@ |
| 1424 | 1441 | |
| 1425 | 1442 | /* Create the new manifest */ |
| 1426 | 1443 | if( blob_size(&comment)==0 ){ |
| 1427 | 1444 | blob_append(&comment, "(no comment)", -1); |
| 1428 | 1445 | } |
| 1446 | + sCiInfo.pComment = &comment; |
| 1447 | + sCiInfo.pCksum = useCksum ? &cksum1 : 0; |
| 1429 | 1448 | if( forceDelta ){ |
| 1430 | 1449 | blob_zero(&manifest); |
| 1431 | 1450 | }else{ |
| 1432 | | - create_manifest(&manifest, 0, 0, &comment, vid, |
| 1451 | + create_manifest(&manifest, 0, 0, vid, &sCiInfo, &szB); |
| 1452 | +#if 0 |
| 1433 | 1453 | !allowOlder && !forceFlag, useCksum ? &cksum1 : 0, |
| 1434 | 1454 | zDateOvrd, zUserOvrd, zBranch, zColor, zBrClr, |
| 1435 | 1455 | azTag, &szB); |
| 1456 | +#endif |
| 1436 | 1457 | } |
| 1437 | 1458 | |
| 1438 | 1459 | /* See if a delta-manifest would be more appropriate */ |
| 1439 | 1460 | if( !forceBaseline ){ |
| 1440 | 1461 | const char *zBaselineUuid; |
| | @@ -1448,14 +1469,17 @@ |
| 1448 | 1469 | zBaselineUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); |
| 1449 | 1470 | pBaseline = pParent; |
| 1450 | 1471 | } |
| 1451 | 1472 | if( pBaseline ){ |
| 1452 | 1473 | Blob delta; |
| 1453 | | - create_manifest(&delta, zBaselineUuid, pBaseline, &comment, vid, |
| 1474 | + create_manifest(&delta, zBaselineUuid, pBaseline, vid, &sCiInfo, &szD); |
| 1475 | + |
| 1476 | +#if 0 |
| 1454 | 1477 | !allowOlder && !forceFlag, useCksum ? &cksum1 : 0, |
| 1455 | 1478 | zDateOvrd, zUserOvrd, zBranch, zColor, zBrClr, |
| 1456 | 1479 | azTag, &szD); |
| 1480 | +#endif |
| 1457 | 1481 | /* |
| 1458 | 1482 | ** At this point, two manifests have been constructed, either of |
| 1459 | 1483 | ** which would work for this checkin. The first manifest (held |
| 1460 | 1484 | ** in the "manifest" variable) is a baseline manifest and the second |
| 1461 | 1485 | ** (held in variable named "delta") is a delta manifest. The |
| 1462 | 1486 | |