Fossil SCM
Add the ability to have a C-card on a wiki page. The current implementation does not use or generate wiki page artifacts with a C-card.
Commit
cad57db96e8c4c5c6b857ce6119c22c4b6b0a2c22468c8072dce257b522328fe
Parent
f5f4471323d44a8…
2 files changed
+8
-5
+9
-1
+8
-5
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -130,11 +130,11 @@ | ||
| 130 | 130 | /* CFTYPE_MANIFEST 1 */ { "BCDFNPQRTUZ", "DZ" }, |
| 131 | 131 | /* Wants to be "CDUZ" ----^^^^ |
| 132 | 132 | ** but we must limit for historical compatibility */ |
| 133 | 133 | /* CFTYPE_CLUSTER 2 */ { "MZ", "MZ" }, |
| 134 | 134 | /* CFTYPE_CONTROL 3 */ { "DTUZ", "DTUZ" }, |
| 135 | - /* CFTYPE_WIKI 4 */ { "DLNPUWZ", "DLUWZ" }, | |
| 135 | + /* CFTYPE_WIKI 4 */ { "CDLNPUWZ", "DLUWZ" }, | |
| 136 | 136 | /* CFTYPE_TICKET 5 */ { "DJKUZ", "DJKUZ" }, |
| 137 | 137 | /* CFTYPE_ATTACHMENT 6 */ { "ACDNUZ", "ADZ" }, |
| 138 | 138 | /* CFTYPE_EVENT 7 */ { "CDENPTUWZ", "DEWZ" }, |
| 139 | 139 | /* CFTYPE_FORUM 8 */ { "DGHINPUWZ", "DUWZ" }, |
| 140 | 140 | }; |
| @@ -318,18 +318,21 @@ | ||
| 318 | 318 | ** value. |
| 319 | 319 | ** |
| 320 | 320 | ** 0123456789 123456789 123456789 123456789 |
| 321 | 321 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 322 | 322 | */ |
| 323 | -static int verify_z_card(const char *z, int n){ | |
| 323 | +static int verify_z_card(const char *z, int n, Blob *pErr){ | |
| 324 | + const char *zHash; | |
| 324 | 325 | if( n<35 ) return 0; |
| 325 | 326 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| 326 | 327 | md5sum_init(); |
| 327 | 328 | md5sum_step_text(z, n-35); |
| 328 | - if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){ | |
| 329 | + zHash = md5sum_finish(0); | |
| 330 | + if( memcmp(&z[n-33], zHash, 32)==0 ){ | |
| 329 | 331 | return 1; |
| 330 | 332 | }else{ |
| 333 | + blob_appendf(pErr, "incorrect Z-card cksum: expected %.32s", zHash); | |
| 331 | 334 | return 2; |
| 332 | 335 | } |
| 333 | 336 | } |
| 334 | 337 | |
| 335 | 338 | /* |
| @@ -466,13 +469,12 @@ | ||
| 466 | 469 | blob_appendf(pErr, "line 1 not recognized"); |
| 467 | 470 | return 0; |
| 468 | 471 | } |
| 469 | 472 | /* Then verify the Z-card. |
| 470 | 473 | */ |
| 471 | - if( verify_z_card(z, n)==2 ){ | |
| 474 | + if( verify_z_card(z, n, pErr)==2 ){ | |
| 472 | 475 | blob_reset(pContent); |
| 473 | - blob_appendf(pErr, "incorrect Z-card cksum"); | |
| 474 | 476 | return 0; |
| 475 | 477 | } |
| 476 | 478 | |
| 477 | 479 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 478 | 480 | */ |
| @@ -1141,10 +1143,11 @@ | ||
| 1141 | 1143 | p = manifest_parse(&b2, 0, &err); |
| 1142 | 1144 | if( p==0 ) fossil_print("ERROR: %s\n", blob_str(&err)); |
| 1143 | 1145 | blob_reset(&err); |
| 1144 | 1146 | manifest_destroy(p); |
| 1145 | 1147 | } |
| 1148 | + blob_reset(&b); | |
| 1146 | 1149 | } |
| 1147 | 1150 | |
| 1148 | 1151 | /* |
| 1149 | 1152 | ** COMMAND: test-parse-all-blobs |
| 1150 | 1153 | ** |
| 1151 | 1154 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -130,11 +130,11 @@ | |
| 130 | /* CFTYPE_MANIFEST 1 */ { "BCDFNPQRTUZ", "DZ" }, |
| 131 | /* Wants to be "CDUZ" ----^^^^ |
| 132 | ** but we must limit for historical compatibility */ |
| 133 | /* CFTYPE_CLUSTER 2 */ { "MZ", "MZ" }, |
| 134 | /* CFTYPE_CONTROL 3 */ { "DTUZ", "DTUZ" }, |
| 135 | /* CFTYPE_WIKI 4 */ { "DLNPUWZ", "DLUWZ" }, |
| 136 | /* CFTYPE_TICKET 5 */ { "DJKUZ", "DJKUZ" }, |
| 137 | /* CFTYPE_ATTACHMENT 6 */ { "ACDNUZ", "ADZ" }, |
| 138 | /* CFTYPE_EVENT 7 */ { "CDENPTUWZ", "DEWZ" }, |
| 139 | /* CFTYPE_FORUM 8 */ { "DGHINPUWZ", "DUWZ" }, |
| 140 | }; |
| @@ -318,18 +318,21 @@ | |
| 318 | ** value. |
| 319 | ** |
| 320 | ** 0123456789 123456789 123456789 123456789 |
| 321 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 322 | */ |
| 323 | static int verify_z_card(const char *z, int n){ |
| 324 | if( n<35 ) return 0; |
| 325 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| 326 | md5sum_init(); |
| 327 | md5sum_step_text(z, n-35); |
| 328 | if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){ |
| 329 | return 1; |
| 330 | }else{ |
| 331 | return 2; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | /* |
| @@ -466,13 +469,12 @@ | |
| 466 | blob_appendf(pErr, "line 1 not recognized"); |
| 467 | return 0; |
| 468 | } |
| 469 | /* Then verify the Z-card. |
| 470 | */ |
| 471 | if( verify_z_card(z, n)==2 ){ |
| 472 | blob_reset(pContent); |
| 473 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 474 | return 0; |
| 475 | } |
| 476 | |
| 477 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 478 | */ |
| @@ -1141,10 +1143,11 @@ | |
| 1141 | p = manifest_parse(&b2, 0, &err); |
| 1142 | if( p==0 ) fossil_print("ERROR: %s\n", blob_str(&err)); |
| 1143 | blob_reset(&err); |
| 1144 | manifest_destroy(p); |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | /* |
| 1149 | ** COMMAND: test-parse-all-blobs |
| 1150 | ** |
| 1151 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -130,11 +130,11 @@ | |
| 130 | /* CFTYPE_MANIFEST 1 */ { "BCDFNPQRTUZ", "DZ" }, |
| 131 | /* Wants to be "CDUZ" ----^^^^ |
| 132 | ** but we must limit for historical compatibility */ |
| 133 | /* CFTYPE_CLUSTER 2 */ { "MZ", "MZ" }, |
| 134 | /* CFTYPE_CONTROL 3 */ { "DTUZ", "DTUZ" }, |
| 135 | /* CFTYPE_WIKI 4 */ { "CDLNPUWZ", "DLUWZ" }, |
| 136 | /* CFTYPE_TICKET 5 */ { "DJKUZ", "DJKUZ" }, |
| 137 | /* CFTYPE_ATTACHMENT 6 */ { "ACDNUZ", "ADZ" }, |
| 138 | /* CFTYPE_EVENT 7 */ { "CDENPTUWZ", "DEWZ" }, |
| 139 | /* CFTYPE_FORUM 8 */ { "DGHINPUWZ", "DUWZ" }, |
| 140 | }; |
| @@ -318,18 +318,21 @@ | |
| 318 | ** value. |
| 319 | ** |
| 320 | ** 0123456789 123456789 123456789 123456789 |
| 321 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 322 | */ |
| 323 | static int verify_z_card(const char *z, int n, Blob *pErr){ |
| 324 | const char *zHash; |
| 325 | if( n<35 ) return 0; |
| 326 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| 327 | md5sum_init(); |
| 328 | md5sum_step_text(z, n-35); |
| 329 | zHash = md5sum_finish(0); |
| 330 | if( memcmp(&z[n-33], zHash, 32)==0 ){ |
| 331 | return 1; |
| 332 | }else{ |
| 333 | blob_appendf(pErr, "incorrect Z-card cksum: expected %.32s", zHash); |
| 334 | return 2; |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | /* |
| @@ -466,13 +469,12 @@ | |
| 469 | blob_appendf(pErr, "line 1 not recognized"); |
| 470 | return 0; |
| 471 | } |
| 472 | /* Then verify the Z-card. |
| 473 | */ |
| 474 | if( verify_z_card(z, n, pErr)==2 ){ |
| 475 | blob_reset(pContent); |
| 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 480 | */ |
| @@ -1141,10 +1143,11 @@ | |
| 1143 | p = manifest_parse(&b2, 0, &err); |
| 1144 | if( p==0 ) fossil_print("ERROR: %s\n", blob_str(&err)); |
| 1145 | blob_reset(&err); |
| 1146 | manifest_destroy(p); |
| 1147 | } |
| 1148 | blob_reset(&b); |
| 1149 | } |
| 1150 | |
| 1151 | /* |
| 1152 | ** COMMAND: test-parse-all-blobs |
| 1153 | ** |
| 1154 |
+9
-1
| --- www/fileformat.wiki | ||
| +++ www/fileformat.wiki | ||
| @@ -343,10 +343,11 @@ | ||
| 343 | 343 | single wiki page. |
| 344 | 344 | Wiki artifacts accept |
| 345 | 345 | the following card types: |
| 346 | 346 | |
| 347 | 347 | <blockquote> |
| 348 | +<b>C</b> <i>change-comment</i><br> | |
| 348 | 349 | <b>D</b> <i>time-and-date-stamp</i><br /> |
| 349 | 350 | <b>L</b> <i>wiki-title</i><br /> |
| 350 | 351 | <b>N</b> <i>mimetype</i><br /> |
| 351 | 352 | <b>P</b> <i>parent-artifact-id</i>+<br /> |
| 352 | 353 | <b>U</b> <i>user-name</i><br /> |
| @@ -366,10 +367,17 @@ | ||
| 366 | 367 | The <b>W</b> card is used to specify the text of the wiki page. The |
| 367 | 368 | argument to the <b>W</b> card is an integer which is the number of bytes |
| 368 | 369 | of text in the wiki page. That text follows the newline character |
| 369 | 370 | that terminates the <b>W</b> card. The wiki text is always followed by one |
| 370 | 371 | extra newline. |
| 372 | + | |
| 373 | +The <b>C</b> card on a wiki page is optional. The argument is a comment | |
| 374 | +that explains why the changes was made. The ability to have a <b>C</b> | |
| 375 | +card on a wiki page artifact was added on 2019-12-02 at the suggestion | |
| 376 | +of user George Krivov and is not currently used or generated by the | |
| 377 | +implementation. Older versions of Fossil will reject a wiki-page | |
| 378 | +artifact that includes a <b>C</b> card. | |
| 371 | 379 | |
| 372 | 380 | An example wiki artifact can be seen |
| 373 | 381 | [/artifact?name=7b2f5fd0e0&txt=1 | here]. |
| 374 | 382 | |
| 375 | 383 | <a name="tktchng"></a> |
| @@ -653,11 +661,11 @@ | ||
| 653 | 661 | <tr> |
| 654 | 662 | <td><b>C</b> <i>comment-text</i></td> |
| 655 | 663 | <td align=center><b>1</b></td> |
| 656 | 664 | <td> </td> |
| 657 | 665 | <td> </td> |
| 658 | -<td> </td> | |
| 666 | +<td align=center><b>0-1</b></td> | |
| 659 | 667 | <td> </td> |
| 660 | 668 | <td align=center><b>0-1</b></td> |
| 661 | 669 | <td align=center><b>0-1</b></td> |
| 662 | 670 | <td> </td> |
| 663 | 671 | </tr> |
| 664 | 672 |
| --- www/fileformat.wiki | |
| +++ www/fileformat.wiki | |
| @@ -343,10 +343,11 @@ | |
| 343 | single wiki page. |
| 344 | Wiki artifacts accept |
| 345 | the following card types: |
| 346 | |
| 347 | <blockquote> |
| 348 | <b>D</b> <i>time-and-date-stamp</i><br /> |
| 349 | <b>L</b> <i>wiki-title</i><br /> |
| 350 | <b>N</b> <i>mimetype</i><br /> |
| 351 | <b>P</b> <i>parent-artifact-id</i>+<br /> |
| 352 | <b>U</b> <i>user-name</i><br /> |
| @@ -366,10 +367,17 @@ | |
| 366 | The <b>W</b> card is used to specify the text of the wiki page. The |
| 367 | argument to the <b>W</b> card is an integer which is the number of bytes |
| 368 | of text in the wiki page. That text follows the newline character |
| 369 | that terminates the <b>W</b> card. The wiki text is always followed by one |
| 370 | extra newline. |
| 371 | |
| 372 | An example wiki artifact can be seen |
| 373 | [/artifact?name=7b2f5fd0e0&txt=1 | here]. |
| 374 | |
| 375 | <a name="tktchng"></a> |
| @@ -653,11 +661,11 @@ | |
| 653 | <tr> |
| 654 | <td><b>C</b> <i>comment-text</i></td> |
| 655 | <td align=center><b>1</b></td> |
| 656 | <td> </td> |
| 657 | <td> </td> |
| 658 | <td> </td> |
| 659 | <td> </td> |
| 660 | <td align=center><b>0-1</b></td> |
| 661 | <td align=center><b>0-1</b></td> |
| 662 | <td> </td> |
| 663 | </tr> |
| 664 |
| --- www/fileformat.wiki | |
| +++ www/fileformat.wiki | |
| @@ -343,10 +343,11 @@ | |
| 343 | single wiki page. |
| 344 | Wiki artifacts accept |
| 345 | the following card types: |
| 346 | |
| 347 | <blockquote> |
| 348 | <b>C</b> <i>change-comment</i><br> |
| 349 | <b>D</b> <i>time-and-date-stamp</i><br /> |
| 350 | <b>L</b> <i>wiki-title</i><br /> |
| 351 | <b>N</b> <i>mimetype</i><br /> |
| 352 | <b>P</b> <i>parent-artifact-id</i>+<br /> |
| 353 | <b>U</b> <i>user-name</i><br /> |
| @@ -366,10 +367,17 @@ | |
| 367 | The <b>W</b> card is used to specify the text of the wiki page. The |
| 368 | argument to the <b>W</b> card is an integer which is the number of bytes |
| 369 | of text in the wiki page. That text follows the newline character |
| 370 | that terminates the <b>W</b> card. The wiki text is always followed by one |
| 371 | extra newline. |
| 372 | |
| 373 | The <b>C</b> card on a wiki page is optional. The argument is a comment |
| 374 | that explains why the changes was made. The ability to have a <b>C</b> |
| 375 | card on a wiki page artifact was added on 2019-12-02 at the suggestion |
| 376 | of user George Krivov and is not currently used or generated by the |
| 377 | implementation. Older versions of Fossil will reject a wiki-page |
| 378 | artifact that includes a <b>C</b> card. |
| 379 | |
| 380 | An example wiki artifact can be seen |
| 381 | [/artifact?name=7b2f5fd0e0&txt=1 | here]. |
| 382 | |
| 383 | <a name="tktchng"></a> |
| @@ -653,11 +661,11 @@ | |
| 661 | <tr> |
| 662 | <td><b>C</b> <i>comment-text</i></td> |
| 663 | <td align=center><b>1</b></td> |
| 664 | <td> </td> |
| 665 | <td> </td> |
| 666 | <td align=center><b>0-1</b></td> |
| 667 | <td> </td> |
| 668 | <td align=center><b>0-1</b></td> |
| 669 | <td align=center><b>0-1</b></td> |
| 670 | <td> </td> |
| 671 | </tr> |
| 672 |