Fossil SCM
Change the way that wiki edits are stored in the Event table in order to address ticket [4e558dbf3d2511ce]. The Event.comment field for a wiki page change now stores just the raw name of the wiki page prefixed with a single character "+", "-", or ":" to indicate if the page was added, deleted, or modified, respectively. Formatting is handled by the timeline rendering. <b>A "fossil rebuild" is required.</b> The "timeline" command is not yet fixed.
Commit
1a9b1c4de7abfcb49c6493b975882d45c68263d461a8367f69e450c7eb0353ec
Parent
34f5ea44038583f…
2 files changed
+8
-37
+14
-13
+8
-37
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -2358,14 +2358,14 @@ | ||
| 2358 | 2358 | } |
| 2359 | 2359 | if( p->type==CFTYPE_WIKI ){ |
| 2360 | 2360 | char *zTag = mprintf("wiki-%s", p->zWikiTitle); |
| 2361 | 2361 | int tagid = tag_findid(zTag, 1); |
| 2362 | 2362 | int prior; |
| 2363 | - char *zComment; | |
| 2364 | - const char *zPrefix; | |
| 2363 | + char cPrefix; | |
| 2365 | 2364 | int nWiki; |
| 2366 | 2365 | char zLength[40]; |
| 2366 | + | |
| 2367 | 2367 | while( fossil_isspace(p->zWiki[0]) ) p->zWiki++; |
| 2368 | 2368 | nWiki = strlen(p->zWiki); |
| 2369 | 2369 | sqlite3_snprintf(sizeof(zLength), zLength, "%d", nWiki); |
| 2370 | 2370 | tag_insert(zTag, 1, zLength, rid, p->rDate, rid); |
| 2371 | 2371 | fossil_free(zTag); |
| @@ -2377,56 +2377,27 @@ | ||
| 2377 | 2377 | ); |
| 2378 | 2378 | if( prior ){ |
| 2379 | 2379 | content_deltify(prior, &rid, 1, 0); |
| 2380 | 2380 | } |
| 2381 | 2381 | if( nWiki<=0 ){ |
| 2382 | - zPrefix = "Deleted"; | |
| 2382 | + cPrefix = '-'; | |
| 2383 | 2383 | }else if( !prior ){ |
| 2384 | - zPrefix = "Added"; | |
| 2384 | + cPrefix = '+'; | |
| 2385 | 2385 | }else{ |
| 2386 | - zPrefix = "Changes to"; | |
| 2387 | - } | |
| 2388 | - switch( wiki_page_type(p->zWikiTitle) ){ | |
| 2389 | - case WIKITYPE_CHECKIN: { | |
| 2390 | - zComment = mprintf("%s wiki for check-in [%S]", zPrefix, | |
| 2391 | - p->zWikiTitle+8); | |
| 2392 | - break; | |
| 2393 | - } | |
| 2394 | - case WIKITYPE_BRANCH: { | |
| 2395 | - zComment = mprintf("%s wiki for branch [/timeline?r=%t|%h]", | |
| 2396 | - zPrefix, p->zWikiTitle+7, p->zWikiTitle+7); | |
| 2397 | - break; | |
| 2398 | - } | |
| 2399 | - case WIKITYPE_TAG: { | |
| 2400 | - zComment = mprintf("%s wiki for tag [/timeline?t=%t|%h]", | |
| 2401 | - zPrefix, p->zWikiTitle+4, p->zWikiTitle+4); | |
| 2402 | - break; | |
| 2403 | - } | |
| 2404 | - default: { | |
| 2405 | - zComment = mprintf("%s wiki page [%h]", zPrefix, p->zWikiTitle); | |
| 2406 | - break; | |
| 2407 | - } | |
| 2386 | + cPrefix = ':'; | |
| 2408 | 2387 | } |
| 2409 | 2388 | search_doc_touch('w',rid,p->zWikiTitle); |
| 2410 | 2389 | if( manifest_crosslink_busy ){ |
| 2411 | 2390 | add_pending_crosslink('w',p->zWikiTitle); |
| 2412 | 2391 | }else{ |
| 2413 | 2392 | backlink_wiki_refresh(p->zWikiTitle); |
| 2414 | 2393 | } |
| 2415 | 2394 | db_multi_exec( |
| 2416 | - "REPLACE INTO event(type,mtime,objid,user,comment," | |
| 2417 | - " bgcolor,euser,ecomment)" | |
| 2418 | - "VALUES('w',%.17g,%d,%Q,%Q," | |
| 2419 | - " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1)," | |
| 2420 | - " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)," | |
| 2421 | - " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));", | |
| 2422 | - p->rDate, rid, p->zUser, zComment, | |
| 2423 | - TAG_BGCOLOR, rid, | |
| 2424 | - TAG_USER, rid, | |
| 2425 | - TAG_COMMENT, rid | |
| 2395 | + "REPLACE INTO event(type,mtime,objid,user,comment)" | |
| 2396 | + "VALUES('w',%.17g,%d,%Q,'%c%q');", | |
| 2397 | + p->rDate, rid, p->zUser, cPrefix, p->zWikiTitle | |
| 2426 | 2398 | ); |
| 2427 | - fossil_free(zComment); | |
| 2428 | 2399 | } |
| 2429 | 2400 | if( p->type==CFTYPE_EVENT ){ |
| 2430 | 2401 | char *zTag = mprintf("event-%s", p->zEventId); |
| 2431 | 2402 | int tagid = tag_findid(zTag, 1); |
| 2432 | 2403 | int prior, subsequent; |
| 2433 | 2404 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2358,14 +2358,14 @@ | |
| 2358 | } |
| 2359 | if( p->type==CFTYPE_WIKI ){ |
| 2360 | char *zTag = mprintf("wiki-%s", p->zWikiTitle); |
| 2361 | int tagid = tag_findid(zTag, 1); |
| 2362 | int prior; |
| 2363 | char *zComment; |
| 2364 | const char *zPrefix; |
| 2365 | int nWiki; |
| 2366 | char zLength[40]; |
| 2367 | while( fossil_isspace(p->zWiki[0]) ) p->zWiki++; |
| 2368 | nWiki = strlen(p->zWiki); |
| 2369 | sqlite3_snprintf(sizeof(zLength), zLength, "%d", nWiki); |
| 2370 | tag_insert(zTag, 1, zLength, rid, p->rDate, rid); |
| 2371 | fossil_free(zTag); |
| @@ -2377,56 +2377,27 @@ | |
| 2377 | ); |
| 2378 | if( prior ){ |
| 2379 | content_deltify(prior, &rid, 1, 0); |
| 2380 | } |
| 2381 | if( nWiki<=0 ){ |
| 2382 | zPrefix = "Deleted"; |
| 2383 | }else if( !prior ){ |
| 2384 | zPrefix = "Added"; |
| 2385 | }else{ |
| 2386 | zPrefix = "Changes to"; |
| 2387 | } |
| 2388 | switch( wiki_page_type(p->zWikiTitle) ){ |
| 2389 | case WIKITYPE_CHECKIN: { |
| 2390 | zComment = mprintf("%s wiki for check-in [%S]", zPrefix, |
| 2391 | p->zWikiTitle+8); |
| 2392 | break; |
| 2393 | } |
| 2394 | case WIKITYPE_BRANCH: { |
| 2395 | zComment = mprintf("%s wiki for branch [/timeline?r=%t|%h]", |
| 2396 | zPrefix, p->zWikiTitle+7, p->zWikiTitle+7); |
| 2397 | break; |
| 2398 | } |
| 2399 | case WIKITYPE_TAG: { |
| 2400 | zComment = mprintf("%s wiki for tag [/timeline?t=%t|%h]", |
| 2401 | zPrefix, p->zWikiTitle+4, p->zWikiTitle+4); |
| 2402 | break; |
| 2403 | } |
| 2404 | default: { |
| 2405 | zComment = mprintf("%s wiki page [%h]", zPrefix, p->zWikiTitle); |
| 2406 | break; |
| 2407 | } |
| 2408 | } |
| 2409 | search_doc_touch('w',rid,p->zWikiTitle); |
| 2410 | if( manifest_crosslink_busy ){ |
| 2411 | add_pending_crosslink('w',p->zWikiTitle); |
| 2412 | }else{ |
| 2413 | backlink_wiki_refresh(p->zWikiTitle); |
| 2414 | } |
| 2415 | db_multi_exec( |
| 2416 | "REPLACE INTO event(type,mtime,objid,user,comment," |
| 2417 | " bgcolor,euser,ecomment)" |
| 2418 | "VALUES('w',%.17g,%d,%Q,%Q," |
| 2419 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1)," |
| 2420 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)," |
| 2421 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));", |
| 2422 | p->rDate, rid, p->zUser, zComment, |
| 2423 | TAG_BGCOLOR, rid, |
| 2424 | TAG_USER, rid, |
| 2425 | TAG_COMMENT, rid |
| 2426 | ); |
| 2427 | fossil_free(zComment); |
| 2428 | } |
| 2429 | if( p->type==CFTYPE_EVENT ){ |
| 2430 | char *zTag = mprintf("event-%s", p->zEventId); |
| 2431 | int tagid = tag_findid(zTag, 1); |
| 2432 | int prior, subsequent; |
| 2433 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2358,14 +2358,14 @@ | |
| 2358 | } |
| 2359 | if( p->type==CFTYPE_WIKI ){ |
| 2360 | char *zTag = mprintf("wiki-%s", p->zWikiTitle); |
| 2361 | int tagid = tag_findid(zTag, 1); |
| 2362 | int prior; |
| 2363 | char cPrefix; |
| 2364 | int nWiki; |
| 2365 | char zLength[40]; |
| 2366 | |
| 2367 | while( fossil_isspace(p->zWiki[0]) ) p->zWiki++; |
| 2368 | nWiki = strlen(p->zWiki); |
| 2369 | sqlite3_snprintf(sizeof(zLength), zLength, "%d", nWiki); |
| 2370 | tag_insert(zTag, 1, zLength, rid, p->rDate, rid); |
| 2371 | fossil_free(zTag); |
| @@ -2377,56 +2377,27 @@ | |
| 2377 | ); |
| 2378 | if( prior ){ |
| 2379 | content_deltify(prior, &rid, 1, 0); |
| 2380 | } |
| 2381 | if( nWiki<=0 ){ |
| 2382 | cPrefix = '-'; |
| 2383 | }else if( !prior ){ |
| 2384 | cPrefix = '+'; |
| 2385 | }else{ |
| 2386 | cPrefix = ':'; |
| 2387 | } |
| 2388 | search_doc_touch('w',rid,p->zWikiTitle); |
| 2389 | if( manifest_crosslink_busy ){ |
| 2390 | add_pending_crosslink('w',p->zWikiTitle); |
| 2391 | }else{ |
| 2392 | backlink_wiki_refresh(p->zWikiTitle); |
| 2393 | } |
| 2394 | db_multi_exec( |
| 2395 | "REPLACE INTO event(type,mtime,objid,user,comment)" |
| 2396 | "VALUES('w',%.17g,%d,%Q,'%c%q');", |
| 2397 | p->rDate, rid, p->zUser, cPrefix, p->zWikiTitle |
| 2398 | ); |
| 2399 | } |
| 2400 | if( p->type==CFTYPE_EVENT ){ |
| 2401 | char *zTag = mprintf("event-%s", p->zEventId); |
| 2402 | int tagid = tag_findid(zTag, 1); |
| 2403 | int prior, subsequent; |
| 2404 |
+14
-13
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -595,26 +595,27 @@ | ||
| 595 | 595 | if( zType[0]!='c' ){ |
| 596 | 596 | /* Comments for anything other than a check-in are generated by |
| 597 | 597 | ** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */ |
| 598 | 598 | if( zType[0]=='w' ){ |
| 599 | 599 | const char *zCom = blob_str(&comment); |
| 600 | - char *zWiki; | |
| 600 | + /* Except, the comments generated by "fossil rebuild" for a wiki | |
| 601 | + ** page edit consist of a single character '-', '+', or ':' (to | |
| 602 | + ** indicate "deleted", "added", or "edited") followed by the | |
| 603 | + ** raw wiki page name. We have to generate an appropriate | |
| 604 | + ** comment on-the-fly | |
| 605 | + */ | |
| 601 | 606 | wiki_hyperlink_override(zUuid); |
| 602 | - if( (tmFlags & TIMELINE_REFS)!=0 | |
| 603 | - && (zWiki = strstr(zCom,"wiki"))!=0 | |
| 604 | - ){ | |
| 605 | - /* The TIMELINE_REFS flag causes timeline comments of the | |
| 606 | - ** form "Changes to wiki..." or "Added wiki" to be changed | |
| 607 | - ** into just "Wiki..." */ | |
| 608 | - Blob rcom; | |
| 609 | - blob_init(&rcom, 0, 0); | |
| 610 | - blob_appendf(&rcom, "W%s", zWiki+1); | |
| 611 | - wiki_convert(&rcom, 0, WIKI_INLINE); | |
| 612 | - blob_reset(&rcom); | |
| 607 | + if( zCom[0]=='-' ){ | |
| 608 | + @ Deleted wiki page "%z(href("%R/whistory?name=%t",zCom+1))\ | |
| 609 | + }else if( (tmFlags & TIMELINE_REFS)!=0 ){ | |
| 610 | + @ Wiki page "%z(href("%R/wiki?name=%t",zCom+1))\ | |
| 611 | + }else if( zCom[0]=='+' ){ | |
| 612 | + @ Added wiki page "%z(href("%R/wiki?name=%t",zCom+1))\ | |
| 613 | 613 | }else{ |
| 614 | - wiki_convert(&comment, 0, WIKI_INLINE); | |
| 614 | + @ Changes to wiki page "%z(href("%R/wiki?name=%t",zCom+1))\ | |
| 615 | 615 | } |
| 616 | + @ %h(zCom+1)</a>" | |
| 616 | 617 | wiki_hyperlink_override(0); |
| 617 | 618 | }else{ |
| 618 | 619 | wiki_convert(&comment, 0, WIKI_INLINE); |
| 619 | 620 | } |
| 620 | 621 | }else{ |
| 621 | 622 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -595,26 +595,27 @@ | |
| 595 | if( zType[0]!='c' ){ |
| 596 | /* Comments for anything other than a check-in are generated by |
| 597 | ** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */ |
| 598 | if( zType[0]=='w' ){ |
| 599 | const char *zCom = blob_str(&comment); |
| 600 | char *zWiki; |
| 601 | wiki_hyperlink_override(zUuid); |
| 602 | if( (tmFlags & TIMELINE_REFS)!=0 |
| 603 | && (zWiki = strstr(zCom,"wiki"))!=0 |
| 604 | ){ |
| 605 | /* The TIMELINE_REFS flag causes timeline comments of the |
| 606 | ** form "Changes to wiki..." or "Added wiki" to be changed |
| 607 | ** into just "Wiki..." */ |
| 608 | Blob rcom; |
| 609 | blob_init(&rcom, 0, 0); |
| 610 | blob_appendf(&rcom, "W%s", zWiki+1); |
| 611 | wiki_convert(&rcom, 0, WIKI_INLINE); |
| 612 | blob_reset(&rcom); |
| 613 | }else{ |
| 614 | wiki_convert(&comment, 0, WIKI_INLINE); |
| 615 | } |
| 616 | wiki_hyperlink_override(0); |
| 617 | }else{ |
| 618 | wiki_convert(&comment, 0, WIKI_INLINE); |
| 619 | } |
| 620 | }else{ |
| 621 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -595,26 +595,27 @@ | |
| 595 | if( zType[0]!='c' ){ |
| 596 | /* Comments for anything other than a check-in are generated by |
| 597 | ** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */ |
| 598 | if( zType[0]=='w' ){ |
| 599 | const char *zCom = blob_str(&comment); |
| 600 | /* Except, the comments generated by "fossil rebuild" for a wiki |
| 601 | ** page edit consist of a single character '-', '+', or ':' (to |
| 602 | ** indicate "deleted", "added", or "edited") followed by the |
| 603 | ** raw wiki page name. We have to generate an appropriate |
| 604 | ** comment on-the-fly |
| 605 | */ |
| 606 | wiki_hyperlink_override(zUuid); |
| 607 | if( zCom[0]=='-' ){ |
| 608 | @ Deleted wiki page "%z(href("%R/whistory?name=%t",zCom+1))\ |
| 609 | }else if( (tmFlags & TIMELINE_REFS)!=0 ){ |
| 610 | @ Wiki page "%z(href("%R/wiki?name=%t",zCom+1))\ |
| 611 | }else if( zCom[0]=='+' ){ |
| 612 | @ Added wiki page "%z(href("%R/wiki?name=%t",zCom+1))\ |
| 613 | }else{ |
| 614 | @ Changes to wiki page "%z(href("%R/wiki?name=%t",zCom+1))\ |
| 615 | } |
| 616 | @ %h(zCom+1)</a>" |
| 617 | wiki_hyperlink_override(0); |
| 618 | }else{ |
| 619 | wiki_convert(&comment, 0, WIKI_INLINE); |
| 620 | } |
| 621 | }else{ |
| 622 |