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.

drh 2019-12-02 13:45 trunk
Commit cad57db96e8c4c5c6b857ce6119c22c4b6b0a2c22468c8072dce257b522328fe
+8 -5
--- src/manifest.c
+++ src/manifest.c
@@ -130,11 +130,11 @@
130130
/* CFTYPE_MANIFEST 1 */ { "BCDFNPQRTUZ", "DZ" },
131131
/* Wants to be "CDUZ" ----^^^^
132132
** but we must limit for historical compatibility */
133133
/* CFTYPE_CLUSTER 2 */ { "MZ", "MZ" },
134134
/* CFTYPE_CONTROL 3 */ { "DTUZ", "DTUZ" },
135
- /* CFTYPE_WIKI 4 */ { "DLNPUWZ", "DLUWZ" },
135
+ /* CFTYPE_WIKI 4 */ { "CDLNPUWZ", "DLUWZ" },
136136
/* CFTYPE_TICKET 5 */ { "DJKUZ", "DJKUZ" },
137137
/* CFTYPE_ATTACHMENT 6 */ { "ACDNUZ", "ADZ" },
138138
/* CFTYPE_EVENT 7 */ { "CDENPTUWZ", "DEWZ" },
139139
/* CFTYPE_FORUM 8 */ { "DGHINPUWZ", "DUWZ" },
140140
};
@@ -318,18 +318,21 @@
318318
** value.
319319
**
320320
** 0123456789 123456789 123456789 123456789
321321
** Z aea84f4f863865a8d59d0384e4d2a41c
322322
*/
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;
324325
if( n<35 ) return 0;
325326
if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0;
326327
md5sum_init();
327328
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 ){
329331
return 1;
330332
}else{
333
+ blob_appendf(pErr, "incorrect Z-card cksum: expected %.32s", zHash);
331334
return 2;
332335
}
333336
}
334337
335338
/*
@@ -466,13 +469,12 @@
466469
blob_appendf(pErr, "line 1 not recognized");
467470
return 0;
468471
}
469472
/* Then verify the Z-card.
470473
*/
471
- if( verify_z_card(z, n)==2 ){
474
+ if( verify_z_card(z, n, pErr)==2 ){
472475
blob_reset(pContent);
473
- blob_appendf(pErr, "incorrect Z-card cksum");
474476
return 0;
475477
}
476478
477479
/* Allocate a Manifest object to hold the parsed control artifact.
478480
*/
@@ -1141,10 +1143,11 @@
11411143
p = manifest_parse(&b2, 0, &err);
11421144
if( p==0 ) fossil_print("ERROR: %s\n", blob_str(&err));
11431145
blob_reset(&err);
11441146
manifest_destroy(p);
11451147
}
1148
+ blob_reset(&b);
11461149
}
11471150
11481151
/*
11491152
** COMMAND: test-parse-all-blobs
11501153
**
11511154
--- 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
--- www/fileformat.wiki
+++ www/fileformat.wiki
@@ -343,10 +343,11 @@
343343
single wiki page.
344344
Wiki artifacts accept
345345
the following card types:
346346
347347
<blockquote>
348
+<b>C</b> <i>change-comment</i><br>
348349
<b>D</b> <i>time-and-date-stamp</i><br />
349350
<b>L</b> <i>wiki-title</i><br />
350351
<b>N</b> <i>mimetype</i><br />
351352
<b>P</b> <i>parent-artifact-id</i>+<br />
352353
<b>U</b> <i>user-name</i><br />
@@ -366,10 +367,17 @@
366367
The <b>W</b> card is used to specify the text of the wiki page. The
367368
argument to the <b>W</b> card is an integer which is the number of bytes
368369
of text in the wiki page. That text follows the newline character
369370
that terminates the <b>W</b> card. The wiki text is always followed by one
370371
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.
371379
372380
An example wiki artifact can be seen
373381
[/artifact?name=7b2f5fd0e0&txt=1 | here].
374382
375383
<a name="tktchng"></a>
@@ -653,11 +661,11 @@
653661
<tr>
654662
<td><b>C</b> <i>comment-text</i></td>
655663
<td align=center><b>1</b></td>
656664
<td>&nbsp;</td>
657665
<td>&nbsp;</td>
658
-<td>&nbsp;</td>
666
+<td align=center><b>0-1</b></td>
659667
<td>&nbsp;</td>
660668
<td align=center><b>0-1</b></td>
661669
<td align=center><b>0-1</b></td>
662670
<td>&nbsp;</td>
663671
</tr>
664672
--- 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>&nbsp;</td>
657 <td>&nbsp;</td>
658 <td>&nbsp;</td>
659 <td>&nbsp;</td>
660 <td align=center><b>0-1</b></td>
661 <td align=center><b>0-1</b></td>
662 <td>&nbsp;</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>&nbsp;</td>
665 <td>&nbsp;</td>
666 <td align=center><b>0-1</b></td>
667 <td>&nbsp;</td>
668 <td align=center><b>0-1</b></td>
669 <td align=center><b>0-1</b></td>
670 <td>&nbsp;</td>
671 </tr>
672

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button