Fossil SCM
Show check-ins that mention a ticket in the ticket timeline.
Commit
611b3b206bdfea6d2c71f4ff13a369918d5181ec
Parent
f2181f5e45b62da…
1 file changed
+15
-36
+15
-36
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -165,32 +165,10 @@ | ||
| 165 | 165 | for(i=0; (z = cgi_parameter_name(i))!=0; i++){ |
| 166 | 166 | Th_Store(z, P(z)); |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | -/* | |
| 171 | -** Rebuild all tickets named in the _pending_ticket table. | |
| 172 | -** | |
| 173 | -** This routine is called just prior to commit after new | |
| 174 | -** out-of-sequence ticket changes have been added. | |
| 175 | -*/ | |
| 176 | -static int ticket_rebuild_at_commit(void){ | |
| 177 | - Stmt q; | |
| 178 | - db_multi_exec( | |
| 179 | - "DELETE FROM ticket WHERE tkt_uuid IN _pending_ticket" | |
| 180 | - ); | |
| 181 | - db_prepare(&q, "SELECT uuid FROM _pending_ticket"); | |
| 182 | - while( db_step(&q)==SQLITE_ROW ){ | |
| 183 | - const char *zUuid = db_column_text(&q, 0); | |
| 184 | - ticket_rebuild_entry(zUuid); | |
| 185 | - } | |
| 186 | - db_multi_exec( | |
| 187 | - "DELETE FROM _pending_ticket" | |
| 188 | - ); | |
| 189 | - return 0; | |
| 190 | -} | |
| 191 | - | |
| 192 | 170 | /* |
| 193 | 171 | ** Update an entry of the TICKET table according to the information |
| 194 | 172 | ** in the control file given in p. Attempt to create the appropriate |
| 195 | 173 | ** TICKET table entry if createFlag is true. If createFlag is false, |
| 196 | 174 | ** that means we already know the entry exists and so we can save the |
| @@ -197,11 +175,11 @@ | ||
| 197 | 175 | ** work of trying to create it. |
| 198 | 176 | ** |
| 199 | 177 | ** Return TRUE if a new TICKET entry was created and FALSE if an |
| 200 | 178 | ** existing entry was revised. |
| 201 | 179 | */ |
| 202 | -int ticket_insert(const Manifest *p, int createFlag, int checkTime){ | |
| 180 | +int ticket_insert(const Manifest *p, int createFlag, int rid){ | |
| 203 | 181 | Blob sql; |
| 204 | 182 | Stmt q; |
| 205 | 183 | int i; |
| 206 | 184 | const char *zSep; |
| 207 | 185 | int rc = 0; |
| @@ -224,27 +202,20 @@ | ||
| 224 | 202 | zName, zName, p->aField[i].zValue); |
| 225 | 203 | }else{ |
| 226 | 204 | if( fieldId(zName)<0 ) continue; |
| 227 | 205 | blob_appendf(&sql,", %s=%Q", zName, p->aField[i].zValue); |
| 228 | 206 | } |
| 207 | + if( rid>0 ){ | |
| 208 | + wiki_extract_links(p->aField[i].zValue, rid, 1, p->rDate, i==0, 0); | |
| 209 | + } | |
| 229 | 210 | } |
| 230 | 211 | blob_appendf(&sql, " WHERE tkt_uuid='%s' AND tkt_mtime<:mtime", |
| 231 | 212 | p->zTicketUuid); |
| 232 | 213 | db_prepare(&q, "%s", blob_str(&sql)); |
| 233 | 214 | db_bind_double(&q, ":mtime", p->rDate); |
| 234 | 215 | db_step(&q); |
| 235 | 216 | db_finalize(&q); |
| 236 | - if( checkTime && db_changes()==0 ){ | |
| 237 | - static int isInit = 0; | |
| 238 | - if( !isInit ){ | |
| 239 | - db_multi_exec("CREATE TEMP TABLE _pending_ticket(uuid TEXT UNIQUE)"); | |
| 240 | - db_commit_hook(ticket_rebuild_at_commit, 1); | |
| 241 | - isInit = 1; | |
| 242 | - } | |
| 243 | - db_multi_exec("INSERT OR IGNORE INTO _pending_ticket " | |
| 244 | - "VALUES(%Q)", p->zTicketUuid); | |
| 245 | - } | |
| 246 | 217 | blob_reset(&sql); |
| 247 | 218 | return rc; |
| 248 | 219 | } |
| 249 | 220 | |
| 250 | 221 | /* |
| @@ -264,11 +235,11 @@ | ||
| 264 | 235 | db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid); |
| 265 | 236 | while( db_step(&q)==SQLITE_ROW ){ |
| 266 | 237 | int rid = db_column_int(&q, 0); |
| 267 | 238 | content_get(rid, &content); |
| 268 | 239 | manifest_parse(&manifest, &content); |
| 269 | - ticket_insert(&manifest, createFlag, 0); | |
| 240 | + ticket_insert(&manifest, createFlag, rid); | |
| 270 | 241 | manifest_ticket_event(rid, &manifest, createFlag, tagid); |
| 271 | 242 | manifest_clear(&manifest); |
| 272 | 243 | createFlag = 0; |
| 273 | 244 | } |
| 274 | 245 | db_finalize(&q); |
| @@ -619,11 +590,13 @@ | ||
| 619 | 590 | void tkttimeline_page(void){ |
| 620 | 591 | Stmt q; |
| 621 | 592 | char *zTitle; |
| 622 | 593 | char *zSQL; |
| 623 | 594 | const char *zUuid; |
| 595 | + char *zFullUuid; | |
| 624 | 596 | int tagid; |
| 597 | + char zGlobPattern[50]; | |
| 625 | 598 | |
| 626 | 599 | login_check_credentials(); |
| 627 | 600 | if( !g.okHistory || !g.okRdTkt ){ login_needed(); return; } |
| 628 | 601 | zUuid = PD("name",""); |
| 629 | 602 | style_submenu_element("History", "History", |
| @@ -632,20 +605,26 @@ | ||
| 632 | 605 | "%s/info/%s", g.zTop, zUuid); |
| 633 | 606 | zTitle = mprintf("Timeline Of Ticket %h", zUuid); |
| 634 | 607 | style_header(zTitle); |
| 635 | 608 | free(zTitle); |
| 636 | 609 | |
| 610 | + sqlite3_snprintf(6, zGlobPattern, "%s", zUuid); | |
| 611 | + canonical16(zGlobPattern, strlen(zGlobPattern)); | |
| 637 | 612 | tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",zUuid); |
| 638 | 613 | if( tagid==0 ){ |
| 639 | 614 | @ No such ticket: %h(zUuid) |
| 640 | 615 | style_footer(); |
| 641 | 616 | return; |
| 642 | 617 | } |
| 618 | + zFullUuid = db_text(0, "SELECT substr(tagname, 5) FROM tag WHERE tagid=%d", | |
| 619 | + tagid); | |
| 643 | 620 | zSQL = mprintf("%s AND event.objid IN " |
| 644 | - " (SELECT rid FROM tagxref WHERE tagid=%d) " | |
| 621 | + " (SELECT rid FROM tagxref WHERE tagid=%d UNION" | |
| 622 | + " SELECT srcid FROM backlink WHERE target GLOB '%.4s*' " | |
| 623 | + "AND '%s' GLOB (target||'*')) " | |
| 645 | 624 | "ORDER BY mtime DESC", |
| 646 | - timeline_query_for_www(), tagid); | |
| 625 | + timeline_query_for_www(), tagid, zFullUuid, zFullUuid); | |
| 647 | 626 | db_prepare(&q, zSQL); |
| 648 | 627 | free(zSQL); |
| 649 | 628 | www_print_timeline(&q, TIMELINE_ARTID, 0); |
| 650 | 629 | db_finalize(&q); |
| 651 | 630 | style_footer(); |
| 652 | 631 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -165,32 +165,10 @@ | |
| 165 | for(i=0; (z = cgi_parameter_name(i))!=0; i++){ |
| 166 | Th_Store(z, P(z)); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | /* |
| 171 | ** Rebuild all tickets named in the _pending_ticket table. |
| 172 | ** |
| 173 | ** This routine is called just prior to commit after new |
| 174 | ** out-of-sequence ticket changes have been added. |
| 175 | */ |
| 176 | static int ticket_rebuild_at_commit(void){ |
| 177 | Stmt q; |
| 178 | db_multi_exec( |
| 179 | "DELETE FROM ticket WHERE tkt_uuid IN _pending_ticket" |
| 180 | ); |
| 181 | db_prepare(&q, "SELECT uuid FROM _pending_ticket"); |
| 182 | while( db_step(&q)==SQLITE_ROW ){ |
| 183 | const char *zUuid = db_column_text(&q, 0); |
| 184 | ticket_rebuild_entry(zUuid); |
| 185 | } |
| 186 | db_multi_exec( |
| 187 | "DELETE FROM _pending_ticket" |
| 188 | ); |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | /* |
| 193 | ** Update an entry of the TICKET table according to the information |
| 194 | ** in the control file given in p. Attempt to create the appropriate |
| 195 | ** TICKET table entry if createFlag is true. If createFlag is false, |
| 196 | ** that means we already know the entry exists and so we can save the |
| @@ -197,11 +175,11 @@ | |
| 197 | ** work of trying to create it. |
| 198 | ** |
| 199 | ** Return TRUE if a new TICKET entry was created and FALSE if an |
| 200 | ** existing entry was revised. |
| 201 | */ |
| 202 | int ticket_insert(const Manifest *p, int createFlag, int checkTime){ |
| 203 | Blob sql; |
| 204 | Stmt q; |
| 205 | int i; |
| 206 | const char *zSep; |
| 207 | int rc = 0; |
| @@ -224,27 +202,20 @@ | |
| 224 | zName, zName, p->aField[i].zValue); |
| 225 | }else{ |
| 226 | if( fieldId(zName)<0 ) continue; |
| 227 | blob_appendf(&sql,", %s=%Q", zName, p->aField[i].zValue); |
| 228 | } |
| 229 | } |
| 230 | blob_appendf(&sql, " WHERE tkt_uuid='%s' AND tkt_mtime<:mtime", |
| 231 | p->zTicketUuid); |
| 232 | db_prepare(&q, "%s", blob_str(&sql)); |
| 233 | db_bind_double(&q, ":mtime", p->rDate); |
| 234 | db_step(&q); |
| 235 | db_finalize(&q); |
| 236 | if( checkTime && db_changes()==0 ){ |
| 237 | static int isInit = 0; |
| 238 | if( !isInit ){ |
| 239 | db_multi_exec("CREATE TEMP TABLE _pending_ticket(uuid TEXT UNIQUE)"); |
| 240 | db_commit_hook(ticket_rebuild_at_commit, 1); |
| 241 | isInit = 1; |
| 242 | } |
| 243 | db_multi_exec("INSERT OR IGNORE INTO _pending_ticket " |
| 244 | "VALUES(%Q)", p->zTicketUuid); |
| 245 | } |
| 246 | blob_reset(&sql); |
| 247 | return rc; |
| 248 | } |
| 249 | |
| 250 | /* |
| @@ -264,11 +235,11 @@ | |
| 264 | db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid); |
| 265 | while( db_step(&q)==SQLITE_ROW ){ |
| 266 | int rid = db_column_int(&q, 0); |
| 267 | content_get(rid, &content); |
| 268 | manifest_parse(&manifest, &content); |
| 269 | ticket_insert(&manifest, createFlag, 0); |
| 270 | manifest_ticket_event(rid, &manifest, createFlag, tagid); |
| 271 | manifest_clear(&manifest); |
| 272 | createFlag = 0; |
| 273 | } |
| 274 | db_finalize(&q); |
| @@ -619,11 +590,13 @@ | |
| 619 | void tkttimeline_page(void){ |
| 620 | Stmt q; |
| 621 | char *zTitle; |
| 622 | char *zSQL; |
| 623 | const char *zUuid; |
| 624 | int tagid; |
| 625 | |
| 626 | login_check_credentials(); |
| 627 | if( !g.okHistory || !g.okRdTkt ){ login_needed(); return; } |
| 628 | zUuid = PD("name",""); |
| 629 | style_submenu_element("History", "History", |
| @@ -632,20 +605,26 @@ | |
| 632 | "%s/info/%s", g.zTop, zUuid); |
| 633 | zTitle = mprintf("Timeline Of Ticket %h", zUuid); |
| 634 | style_header(zTitle); |
| 635 | free(zTitle); |
| 636 | |
| 637 | tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",zUuid); |
| 638 | if( tagid==0 ){ |
| 639 | @ No such ticket: %h(zUuid) |
| 640 | style_footer(); |
| 641 | return; |
| 642 | } |
| 643 | zSQL = mprintf("%s AND event.objid IN " |
| 644 | " (SELECT rid FROM tagxref WHERE tagid=%d) " |
| 645 | "ORDER BY mtime DESC", |
| 646 | timeline_query_for_www(), tagid); |
| 647 | db_prepare(&q, zSQL); |
| 648 | free(zSQL); |
| 649 | www_print_timeline(&q, TIMELINE_ARTID, 0); |
| 650 | db_finalize(&q); |
| 651 | style_footer(); |
| 652 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -165,32 +165,10 @@ | |
| 165 | for(i=0; (z = cgi_parameter_name(i))!=0; i++){ |
| 166 | Th_Store(z, P(z)); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | /* |
| 171 | ** Update an entry of the TICKET table according to the information |
| 172 | ** in the control file given in p. Attempt to create the appropriate |
| 173 | ** TICKET table entry if createFlag is true. If createFlag is false, |
| 174 | ** that means we already know the entry exists and so we can save the |
| @@ -197,11 +175,11 @@ | |
| 175 | ** work of trying to create it. |
| 176 | ** |
| 177 | ** Return TRUE if a new TICKET entry was created and FALSE if an |
| 178 | ** existing entry was revised. |
| 179 | */ |
| 180 | int ticket_insert(const Manifest *p, int createFlag, int rid){ |
| 181 | Blob sql; |
| 182 | Stmt q; |
| 183 | int i; |
| 184 | const char *zSep; |
| 185 | int rc = 0; |
| @@ -224,27 +202,20 @@ | |
| 202 | zName, zName, p->aField[i].zValue); |
| 203 | }else{ |
| 204 | if( fieldId(zName)<0 ) continue; |
| 205 | blob_appendf(&sql,", %s=%Q", zName, p->aField[i].zValue); |
| 206 | } |
| 207 | if( rid>0 ){ |
| 208 | wiki_extract_links(p->aField[i].zValue, rid, 1, p->rDate, i==0, 0); |
| 209 | } |
| 210 | } |
| 211 | blob_appendf(&sql, " WHERE tkt_uuid='%s' AND tkt_mtime<:mtime", |
| 212 | p->zTicketUuid); |
| 213 | db_prepare(&q, "%s", blob_str(&sql)); |
| 214 | db_bind_double(&q, ":mtime", p->rDate); |
| 215 | db_step(&q); |
| 216 | db_finalize(&q); |
| 217 | blob_reset(&sql); |
| 218 | return rc; |
| 219 | } |
| 220 | |
| 221 | /* |
| @@ -264,11 +235,11 @@ | |
| 235 | db_prepare(&q, "SELECT rid FROM tagxref WHERE tagid=%d ORDER BY mtime",tagid); |
| 236 | while( db_step(&q)==SQLITE_ROW ){ |
| 237 | int rid = db_column_int(&q, 0); |
| 238 | content_get(rid, &content); |
| 239 | manifest_parse(&manifest, &content); |
| 240 | ticket_insert(&manifest, createFlag, rid); |
| 241 | manifest_ticket_event(rid, &manifest, createFlag, tagid); |
| 242 | manifest_clear(&manifest); |
| 243 | createFlag = 0; |
| 244 | } |
| 245 | db_finalize(&q); |
| @@ -619,11 +590,13 @@ | |
| 590 | void tkttimeline_page(void){ |
| 591 | Stmt q; |
| 592 | char *zTitle; |
| 593 | char *zSQL; |
| 594 | const char *zUuid; |
| 595 | char *zFullUuid; |
| 596 | int tagid; |
| 597 | char zGlobPattern[50]; |
| 598 | |
| 599 | login_check_credentials(); |
| 600 | if( !g.okHistory || !g.okRdTkt ){ login_needed(); return; } |
| 601 | zUuid = PD("name",""); |
| 602 | style_submenu_element("History", "History", |
| @@ -632,20 +605,26 @@ | |
| 605 | "%s/info/%s", g.zTop, zUuid); |
| 606 | zTitle = mprintf("Timeline Of Ticket %h", zUuid); |
| 607 | style_header(zTitle); |
| 608 | free(zTitle); |
| 609 | |
| 610 | sqlite3_snprintf(6, zGlobPattern, "%s", zUuid); |
| 611 | canonical16(zGlobPattern, strlen(zGlobPattern)); |
| 612 | tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",zUuid); |
| 613 | if( tagid==0 ){ |
| 614 | @ No such ticket: %h(zUuid) |
| 615 | style_footer(); |
| 616 | return; |
| 617 | } |
| 618 | zFullUuid = db_text(0, "SELECT substr(tagname, 5) FROM tag WHERE tagid=%d", |
| 619 | tagid); |
| 620 | zSQL = mprintf("%s AND event.objid IN " |
| 621 | " (SELECT rid FROM tagxref WHERE tagid=%d UNION" |
| 622 | " SELECT srcid FROM backlink WHERE target GLOB '%.4s*' " |
| 623 | "AND '%s' GLOB (target||'*')) " |
| 624 | "ORDER BY mtime DESC", |
| 625 | timeline_query_for_www(), tagid, zFullUuid, zFullUuid); |
| 626 | db_prepare(&q, zSQL); |
| 627 | free(zSQL); |
| 628 | www_print_timeline(&q, TIMELINE_ARTID, 0); |
| 629 | db_finalize(&q); |
| 630 | style_footer(); |
| 631 |