Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the --mimetype option to the "commit" command. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | markdown |
| Files: | files | file ages | folders |
| SHA1: |
6d4339bb09133406ce211a83b6ee165f |
| User & Date: | drh 2013-04-01 13:50:28.905 |
Context
|
2013-04-01
| ||
| 13:59 | The markdown formatter is now always turned on and cannot be omitted. Add the ability to store mimetype information in control artifacts. Add the --mimetype option to the "commit" command. As the new N-cards used to store mimetype will not be recognized by older fossils, it is recommended that no use be made of mimetype until all users have upgraded. check-in: 4dcea80236 user: drh tags: trunk | |
| 13:50 | Add the --mimetype option to the "commit" command. Closed-Leaf check-in: 6d4339bb09 user: drh tags: markdown | |
|
2013-03-29
| ||
| 16:38 | Add the N-card to control artifacts for wiki, checkins, events, and attachments, which opens up the possibility (not yet implemented) of being able to save wiki text, check-in comments, event text, and attachment descriptions in a variety of formats, such as text/plain, text/html, or text/x-markdown. check-in: 2336a2d86e user: drh tags: markdown | |
Changes
Changes to src/checkin.c.
| ︙ | ︙ | |||
563 564 565 566 567 568 569 | ** zBranch might be NULL or an empty string if no forcing occurs. ** ** parent_rid is the recordid of the parent check-in. */ static void prepare_commit_comment( Blob *pComment, char *zInit, | | | < | | | | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
** zBranch might be NULL or an empty string if no forcing occurs.
**
** parent_rid is the recordid of the parent check-in.
*/
static void prepare_commit_comment(
Blob *pComment,
char *zInit,
CheckinInfo *p,
int parent_rid
){
Blob prompt;
#ifdef _WIN32
int bomSize;
const unsigned char *bom = get_utf8_bom(&bomSize);
blob_init(&prompt, (const char *) bom, bomSize);
if( zInit && zInit[0]) {
blob_append(&prompt, zInit, -1);
}
#else
blob_init(&prompt, zInit, -1);
#endif
blob_append(&prompt,
"\n"
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
"#\n", -1
);
blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin);
if( p->zBranch && p->zBranch[0] ){
blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
}else{
char *zTags = info_tags_of_checkin(parent_rid, 1);
if( zTags ) blob_appendf(&prompt, "# tags: %z\n#\n", zTags);
}
status_report(&prompt, "# ", 1, 0);
if( g.markPrivate ){
blob_append(&prompt,
|
| ︙ | ︙ | |||
704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
int i;
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
for(i=2; i<g.argc; i++){
fossil_print("%s -> %s\n", g.argv[i], date_in_standard_format(g.argv[i]));
}
}
/*
** Create a manifest.
*/
static void create_manifest(
Blob *pOut, /* Write the manifest here */
const char *zBaselineUuid, /* UUID of baseline, or zero */
Manifest *pBaseline, /* Make it a delta manifest if not zero */
| > > > > > > > > > > > > > > > > > > > < | | < < < < < < < | > | | | 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
int i;
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
for(i=2; i<g.argc; i++){
fossil_print("%s -> %s\n", g.argv[i], date_in_standard_format(g.argv[i]));
}
}
#if INTERFACE
/*
** The following structure holds some of the information needed to construct a
** check-in manifest.
*/
struct CheckinInfo {
Blob *pComment; /* Check-in comment text */
const char *zMimetype; /* Mimetype of check-in command. May be NULL */
int verifyDate; /* Verify that child is younger */
Blob *pCksum; /* Repository checksum. May be 0 */
const char *zDateOvrd; /* Date override. If 0 then use 'now' */
const char *zUserOvrd; /* User override. If 0 then use g.zLogin */
const char *zBranch; /* Branch name. May be 0 */
const char *zColor; /* One-time background color. May be 0 */
const char *zBrClr; /* Persistent branch color. May be 0 */
const char **azTag; /* Tags to apply to this check-in */
};
#endif /* INTERFACE */
/*
** Create a manifest.
*/
static void create_manifest(
Blob *pOut, /* Write the manifest here */
const char *zBaselineUuid, /* UUID of baseline, or zero */
Manifest *pBaseline, /* Make it a delta manifest if not zero */
int vid, /* BLOB.id for the parent check-in */
CheckinInfo *p, /* Information about the check-in */
int *pnFBcard /* OUT: Number of generated B- and F-cards */
){
char *zDate; /* Date of the check-in */
char *zParentUuid; /* UUID of parent check-in */
Blob filename; /* A single filename */
int nBasename; /* Size of base filename */
Stmt q; /* Query of files changed */
Stmt q2; /* Query of merge parents */
Blob mcksum; /* Manifest checksum */
ManifestFile *pFile; /* File from the baseline */
int nFBcard = 0; /* Number of B-cards and F-cards */
int i; /* Loop counter */
const char *zColor; /* Modified value of p->zColor */
assert( pBaseline==0 || pBaseline->zBaseline==0 );
assert( pBaseline==0 || zBaselineUuid!=0 );
blob_zero(pOut);
zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
if( pBaseline ){
blob_appendf(pOut, "B %s\n", zBaselineUuid);
manifest_file_rewind(pBaseline);
pFile = manifest_file_next(pBaseline, 0);
nFBcard++;
}else{
pFile = 0;
}
blob_appendf(pOut, "C %F\n", blob_str(p->pComment));
zDate = date_in_standard_format(p->zDateOvrd ? p->zDateOvrd : "now");
blob_appendf(pOut, "D %s\n", zDate);
zDate[10] = ' ';
db_prepare(&q,
"SELECT pathname, uuid, origname, blob.rid, isexe, islink,"
" is_selected(vfile.id)"
" FROM vfile JOIN blob ON vfile.mrid=blob.rid"
" WHERE (NOT deleted OR NOT is_selected(vfile.id))"
|
| ︙ | ︙ | |||
825 826 827 828 829 830 831 832 |
blob_reset(&filename);
db_finalize(&q);
while( pFile ){
blob_appendf(pOut, "F %F\n", pFile->zName);
pFile = manifest_file_next(pBaseline, 0);
nFBcard++;
}
blob_appendf(pOut, "P %s", zParentUuid);
| > > > | | | > | | | | | | | > | | | | | 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 |
blob_reset(&filename);
db_finalize(&q);
while( pFile ){
blob_appendf(pOut, "F %F\n", pFile->zName);
pFile = manifest_file_next(pBaseline, 0);
nFBcard++;
}
if( p->zMimetype && p->zMimetype[0] ){
blob_appendf(pOut, "N %F\n", p->zMimetype);
}
blob_appendf(pOut, "P %s", zParentUuid);
if( p->verifyDate ) checkin_verify_younger(vid, zParentUuid, zDate);
free(zParentUuid);
db_prepare(&q2, "SELECT merge FROM vmerge WHERE id=0");
while( db_step(&q2)==SQLITE_ROW ){
char *zMergeUuid;
int mid = db_column_int(&q2, 0);
if( !g.markPrivate && content_is_private(mid) ) continue;
zMergeUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
if( zMergeUuid ){
blob_appendf(pOut, " %s", zMergeUuid);
if( p->verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate);
free(zMergeUuid);
}
}
db_finalize(&q2);
free(zDate);
blob_appendf(pOut, "\n");
if( p->pCksum ) blob_appendf(pOut, "R %b\n", p->pCksum);
zColor = p->zColor;
if( p->zBranch && p->zBranch[0] ){
/* Set tags for the new branch */
if( p->zBrClr && p->zBrClr[0] ){
zColor = 0;
blob_appendf(pOut, "T *bgcolor * %F\n", p->zBrClr);
}
blob_appendf(pOut, "T *branch * %F\n", p->zBranch);
blob_appendf(pOut, "T *sym-%F *\n", p->zBranch);
}
if( zColor && zColor[0] ){
/* One-time background color */
blob_appendf(pOut, "T +bgcolor * %F\n", zColor);
}
if( p->azTag ){
for(i=0; p->azTag[i]; i++){
/* Add a symbolic tag to this check-in. The tag names have already
** been sorted and converted using the %F format */
assert( i==0 || strcmp(p->azTag[i-1], p->azTag[i])<=0 );
blob_appendf(pOut, "T +sym-%s *\n", p->azTag[i]);
}
}
if( p->zBranch && p->zBranch[0] ){
/* For a new branch, cancel all prior propagating tags */
Stmt q;
db_prepare(&q,
"SELECT tagname FROM tagxref, tag"
" WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
" AND tagtype==2 AND tagname GLOB 'sym-*'"
" AND tagname!='sym-'||%Q"
" ORDER BY tagname",
vid, p->zBranch);
while( db_step(&q)==SQLITE_ROW ){
const char *zBrTag = db_column_text(&q, 0);
blob_appendf(pOut, "T -%F *\n", zBrTag);
}
db_finalize(&q);
}
blob_appendf(pOut, "U %F\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin);
md5sum_blob(pOut, &mcksum);
blob_appendf(pOut, "Z %b\n", &mcksum);
if( pnFBcard ) *pnFBcard = nFBcard;
}
/*
** Issue a warning and give the user an opportunity to abandon out
|
| ︙ | ︙ | |||
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 | ** --baseline use a baseline manifest in the commit process ** --bgcolor COLOR apply COLOR to this one check-in only ** --branch NEW-BRANCH-NAME check in to this new branch ** --branchcolor COLOR apply given COLOR to the branch ** --comment|-m COMMENT-TEXT use COMMENT-TEXT as commit comment ** --delta use a delta manifest in the commit process ** --message-file|-M FILE read the commit comment from given file ** --no-warnings omit all warnings about file contents ** --nosign do not attempt to sign this commit with gpg ** --private do not sync changes and their descendants ** --tag TAG-NAME assign given tag TAG-NAME to the checkin ** ** See also: branch, changes, checkout, extra, sync */ | > | 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | ** --baseline use a baseline manifest in the commit process ** --bgcolor COLOR apply COLOR to this one check-in only ** --branch NEW-BRANCH-NAME check in to this new branch ** --branchcolor COLOR apply given COLOR to the branch ** --comment|-m COMMENT-TEXT use COMMENT-TEXT as commit comment ** --delta use a delta manifest in the commit process ** --message-file|-M FILE read the commit comment from given file ** --mimetype MIMETYPE mimetype of check-in comment ** --no-warnings omit all warnings about file contents ** --nosign do not attempt to sign this commit with gpg ** --private do not sync changes and their descendants ** --tag TAG-NAME assign given tag TAG-NAME to the checkin ** ** See also: branch, changes, checkout, extra, sync */ |
| ︙ | ︙ | |||
1120 1121 1122 1123 1124 1125 1126 | int allowEmpty = 0; /* Allow a commit with no changes */ int allowFork = 0; /* Allow the commit to fork */ int allowOlder = 0; /* Allow a commit older than its ancestor */ char *zManifestFile; /* Name of the manifest file */ int useCksum; /* True if checksums should be computed and verified */ int outputManifest; /* True to output "manifest" and "manifest.uuid" */ int testRun; /* True for a test run. Debugging only */ | | < < < < > | | | > | | | | > | | > | | | 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 |
int allowEmpty = 0; /* Allow a commit with no changes */
int allowFork = 0; /* Allow the commit to fork */
int allowOlder = 0; /* Allow a commit older than its ancestor */
char *zManifestFile; /* Name of the manifest file */
int useCksum; /* True if checksums should be computed and verified */
int outputManifest; /* True to output "manifest" and "manifest.uuid" */
int testRun; /* True for a test run. Debugging only */
CheckinInfo sCiInfo; /* Information about this check-in */
const char *zComFile; /* Read commit message from this file */
int nTag = 0; /* Number of --tag arguments */
const char *zTag; /* A single --tag argument */
const char **azTag = 0;/* Array of all --tag arguments */
Blob manifest; /* Manifest in baseline form */
Blob muuid; /* Manifest uuid */
Blob cksum1, cksum2; /* Before and after commit checksums */
Blob cksum1b; /* Checksum recorded in the manifest */
int szD; /* Size of the delta manifest */
int szB; /* Size of the baseline manifest */
int nConflict = 0; /* Number of unresolved merge conflicts */
int abortCommit = 0;
Blob ans;
char cReply;
memset(&sCiInfo, 0, sizeof(sCiInfo));
url_proxy_options();
noSign = find_option("nosign",0,0)!=0;
forceDelta = find_option("delta",0,0)!=0;
forceBaseline = find_option("baseline",0,0)!=0;
if( forceDelta && forceBaseline ){
fossil_fatal("cannot use --delta and --baseline together");
}
testRun = find_option("test",0,0)!=0;
zComment = find_option("comment","m",1);
forceFlag = find_option("force", "f", 0)!=0;
allowConflict = find_option("allow-conflict",0,0)!=0;
allowEmpty = find_option("allow-empty",0,0)!=0;
allowFork = find_option("allow-fork",0,0)!=0;
allowOlder = find_option("allow-older",0,0)!=0;
noWarningFlag = find_option("no-warnings", 0, 0)!=0;
sCiInfo.zBranch = find_option("branch","b",1);
sCiInfo.zColor = find_option("bgcolor",0,1);
sCiInfo.zBrClr = find_option("branchcolor",0,1);
sCiInfo.zMimetype = find_option("mimetype",0,1);
while( (zTag = find_option("tag",0,1))!=0 ){
if( zTag[0]==0 ) continue;
sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag, sizeof(char*)*(nTag+2));
sCiInfo.azTag[nTag++] = zTag;
sCiInfo.azTag[nTag] = 0;
}
zComFile = find_option("message-file", "M", 1);
if( find_option("private",0,0) ){
g.markPrivate = 1;
if( sCiInfo.zBranch==0 ) sCiInfo.zBranch = "private";
if( sCiInfo.zBrClr==0 && sCiInfo.zColor==0 ){
sCiInfo.zBrClr = "#fec084"; /* Orange */
}
}
sCiInfo.zDateOvrd = find_option("date-override",0,1);
sCiInfo.zUserOvrd = find_option("user-override",0,1);
db_must_be_within_tree();
noSign = db_get_boolean("omitsign", 0)|noSign;
if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; }
useCksum = db_get_boolean("repo-cksum", 1);
outputManifest = db_get_boolean("manifest", 0);
verify_all_options();
|
| ︙ | ︙ | |||
1307 1308 1309 1310 1311 1312 1313 |
"--allow-empty to override.");
}
/*
** Do not allow a commit that will cause a fork unless the --allow-fork
** or --force flags is used, or unless this is a private check-in.
*/
| | | 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 |
"--allow-empty to override.");
}
/*
** Do not allow a commit that will cause a fork unless the --allow-fork
** or --force flags is used, or unless this is a private check-in.
*/
if( sCiInfo.zBranch==0 && allowFork==0 && forceFlag==0
&& g.markPrivate==0 && !is_a_leaf(vid)
){
fossil_fatal("would fork. \"update\" first or use --allow-fork.");
}
/*
** Do not allow a commit against a closed leaf
|
| ︙ | ︙ | |||
1332 1333 1334 1335 1336 1337 1338 |
blob_append(&comment, zComment, -1);
}else if( zComFile ){
blob_zero(&comment);
blob_read_from_file(&comment, zComFile);
blob_to_utf8_no_bom(&comment, 1);
}else{
char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
| | | 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 |
blob_append(&comment, zComment, -1);
}else if( zComFile ){
blob_zero(&comment);
blob_read_from_file(&comment, zComFile);
blob_to_utf8_no_bom(&comment, 1);
}else{
char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
prepare_commit_comment(&comment, zInit, &sCiInfo, vid);
if( zInit && zInit[0] && fossil_strcmp(zInit, blob_str(&comment))==0 ){
blob_zero(&ans);
prompt_user("unchanged check-in comment. continue (y/N)? ", &ans);
cReply = blob_str(&ans)[0];
if( cReply!='y' && cReply!='Y' ) fossil_exit(1);;
}
free(zInit);
|
| ︙ | ︙ | |||
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 |
"please re-test before committing");
}
/* Create the new manifest */
if( blob_size(&comment)==0 ){
blob_append(&comment, "(no comment)", -1);
}
if( forceDelta ){
blob_zero(&manifest);
}else{
| > > | > > | > > > | 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 |
"please re-test before committing");
}
/* Create the new manifest */
if( blob_size(&comment)==0 ){
blob_append(&comment, "(no comment)", -1);
}
sCiInfo.pComment = &comment;
sCiInfo.pCksum = useCksum ? &cksum1 : 0;
if( forceDelta ){
blob_zero(&manifest);
}else{
create_manifest(&manifest, 0, 0, vid, &sCiInfo, &szB);
#if 0
!allowOlder && !forceFlag, useCksum ? &cksum1 : 0,
zDateOvrd, zUserOvrd, zBranch, zColor, zBrClr,
azTag, &szB);
#endif
}
/* See if a delta-manifest would be more appropriate */
if( !forceBaseline ){
const char *zBaselineUuid;
Manifest *pParent;
Manifest *pBaseline;
pParent = manifest_get(vid, CFTYPE_MANIFEST);
if( pParent && pParent->zBaseline ){
zBaselineUuid = pParent->zBaseline;
pBaseline = manifest_get_by_name(zBaselineUuid, 0);
}else{
zBaselineUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
pBaseline = pParent;
}
if( pBaseline ){
Blob delta;
create_manifest(&delta, zBaselineUuid, pBaseline, vid, &sCiInfo, &szD);
#if 0
!allowOlder && !forceFlag, useCksum ? &cksum1 : 0,
zDateOvrd, zUserOvrd, zBranch, zColor, zBrClr,
azTag, &szD);
#endif
/*
** At this point, two manifests have been constructed, either of
** which would work for this checkin. The first manifest (held
** in the "manifest" variable) is a baseline manifest and the second
** (held in variable named "delta") is a delta manifest. The
** question now is: which manifest should we use?
**
|
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
**
** An N-line identifies the mimetype of wiki or comment text.
*/
case 'N': {
if( p->zMimetype!=0 ) SYNTAX("more than one N-card");
p->zMimetype = next_token(&x,0);
if( p->zMimetype==0 ) SYNTAX("missing mimetype on N-card");
break;
}
/*
** P <uuid> ...
**
** Specify one or more other artifacts where are the parents of
| > | 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
**
** An N-line identifies the mimetype of wiki or comment text.
*/
case 'N': {
if( p->zMimetype!=0 ) SYNTAX("more than one N-card");
p->zMimetype = next_token(&x,0);
if( p->zMimetype==0 ) SYNTAX("missing mimetype on N-card");
defossilize(p->zMimetype);
break;
}
/*
** P <uuid> ...
**
** Specify one or more other artifacts where are the parents of
|
| ︙ | ︙ |
Changes to www/fileformat.wiki.
| ︙ | ︙ | |||
97 98 99 100 101 102 103 | Allowed cards in the manifest are as follows: <blockquote> <b>B</b> <i>baseline-manifest</i><br> <b>C</b> <i>checkin-comment</i><br> <b>D</b> <i>time-and-date-stamp</i><br> <b>F</b> <i>filename</i> <i>SHA1-hash</i> <i>permissions</i> <i>old-name</i><br> | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | Allowed cards in the manifest are as follows: <blockquote> <b>B</b> <i>baseline-manifest</i><br> <b>C</b> <i>checkin-comment</i><br> <b>D</b> <i>time-and-date-stamp</i><br> <b>F</b> <i>filename</i> <i>SHA1-hash</i> <i>permissions</i> <i>old-name</i><br> <b>N</b> <i>mimetype</i><br> <b>P</b> <i>SHA1-hash</i>+<br> <b>Q</b> (<b>+</b>|<b>-</b>)<i>SHA1-hash ?SHA1-hash?</i><br> <b>R</b> <i>repository-checksum</i><br> <b>T</b> (<b>+</b>|<b>-</b>|<b>*</b>)<i>tag-name <b>*</b> ?value?</i><br> <b>U</b> <i>user-login</i><br> <b>Z</b> <i>manifest-checksum</i> </blockquote> |
| ︙ | ︙ |