Fossil SCM

Simplify www_print_timeline() so that it uses branch_of_rid() rather than computing the branch name for itself.

drh 2025-03-06 14:35 trunk
Commit 0150eda979ee86735142cc7bf4061606f7d1260caee4c3aae1531b66c6211663
1 file changed +3 -14
+3 -14
--- src/timeline.c
+++ src/timeline.c
@@ -205,11 +205,10 @@
205205
char zPrevDate[20];
206206
GraphContext *pGraph = 0;
207207
int prevWasDivider = 0; /* True if previous output row was <hr> */
208208
int fchngQueryInit = 0; /* True if fchngQuery is initialized */
209209
Stmt fchngQuery; /* Query for file changes on check-ins */
210
- static Stmt qbranch;
211210
int pendingEndTr = 0; /* True if a </td></tr> is needed */
212211
int vid = 0; /* Current check-out version */
213212
int dateFormat = 0; /* 0: HH:MM (default) */
214213
int bCommentGitStyle = 0; /* Only show comments through first blank line */
215214
const char *zStyle; /* Sub-name for classes for the style */
@@ -243,14 +242,10 @@
243242
zDateFmt = P("datefmt");
244243
if( zDateFmt ) dateFormat = atoi(zDateFmt);
245244
if( tmFlags & TIMELINE_GRAPH ){
246245
pGraph = graph_init();
247246
}
248
- db_static_prepare(&qbranch,
249
- "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
250
- TAG_BRANCH
251
- );
252247
if( (tmFlags & TIMELINE_CHPICK)!=0
253248
&& !db_table_exists("repository","cherrypick")
254249
){
255250
tmFlags &= ~TIMELINE_CHPICK;
256251
}
@@ -266,11 +261,11 @@
266261
const char *zType = db_column_text(pQuery, 7);
267262
const char *zUser = db_column_text(pQuery, 4);
268263
const char *zTagList = db_column_text(pQuery, 8);
269264
int tagid = db_column_int(pQuery, 9);
270265
const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
271
- const char *zBr = 0; /* Branch */
266
+ char *zBr = 0; /* Branch */
272267
int commentColumn = 3; /* Column containing comment text */
273268
int modPending; /* Pending moderation */
274269
char *zDateLink; /* URL for the link on the timestamp */
275270
int drawDetailEllipsis; /* True to show ellipsis in place of detail */
276271
int gidx = 0; /* Graph row identifier */
@@ -412,17 +407,11 @@
412407
}
413408
}
414409
if( zType[0]=='c'
415410
&& (pGraph || zBgClr==0 || (tmFlags & (TIMELINE_BRCOLOR|TIMELINE_DELTA))!=0)
416411
){
417
- db_reset(&qbranch);
418
- db_bind_int(&qbranch, ":rid", rid);
419
- if( db_step(&qbranch)==SQLITE_ROW ){
420
- zBr = db_column_text(&qbranch, 0);
421
- }else{
422
- zBr = "trunk";
423
- }
412
+ zBr = branch_of_rid(rid);
424413
if( zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0 ){
425414
if( tmFlags & (TIMELINE_DELTA|TIMELINE_NOCOLOR) ){
426415
}else if( zBr==0 || strcmp(zBr,"trunk")==0 ){
427416
zBgClr = 0;
428417
}else{
@@ -459,19 +448,19 @@
459448
db_reset(&qcherrypick);
460449
}
461450
gidx = graph_add_row(pGraph, rid, nParent, nCherrypick, aParent,
462451
zBr, zBgClr, zUuid,
463452
isLeaf ? isLeaf + 2 * has_closed_tag(rid) : 0);
464
- db_reset(&qbranch);
465453
@ <div id="m%d(gidx)" class="tl-nodemark"></div>
466454
}else if( zType[0]=='e' && pGraph && zBgClr && zBgClr[0] ){
467455
/* For technotes, make a graph node with nParent==(-1). This will
468456
** not actually draw anything on the graph, but it will set the
469457
** background color of the timeline entry */
470458
gidx = graph_add_row(pGraph, rid, -1, 0, 0, zBr, zBgClr, zUuid, 0);
471459
@ <div id="m%d(gidx)" class="tl-nodemark"></div>
472460
}
461
+ fossil_free(zBr);
473462
@</td>
474463
if( !isSelectedOrCurrent ){
475464
@ <td class="timeline%s(zStyle)Cell%s(zExtraClass)" id='mc%d(gidx)'>
476465
}else{
477466
@ <td class="timeline%s(zStyle)Cell%s(zExtraClass)">
478467
--- src/timeline.c
+++ src/timeline.c
@@ -205,11 +205,10 @@
205 char zPrevDate[20];
206 GraphContext *pGraph = 0;
207 int prevWasDivider = 0; /* True if previous output row was <hr> */
208 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
209 Stmt fchngQuery; /* Query for file changes on check-ins */
210 static Stmt qbranch;
211 int pendingEndTr = 0; /* True if a </td></tr> is needed */
212 int vid = 0; /* Current check-out version */
213 int dateFormat = 0; /* 0: HH:MM (default) */
214 int bCommentGitStyle = 0; /* Only show comments through first blank line */
215 const char *zStyle; /* Sub-name for classes for the style */
@@ -243,14 +242,10 @@
243 zDateFmt = P("datefmt");
244 if( zDateFmt ) dateFormat = atoi(zDateFmt);
245 if( tmFlags & TIMELINE_GRAPH ){
246 pGraph = graph_init();
247 }
248 db_static_prepare(&qbranch,
249 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
250 TAG_BRANCH
251 );
252 if( (tmFlags & TIMELINE_CHPICK)!=0
253 && !db_table_exists("repository","cherrypick")
254 ){
255 tmFlags &= ~TIMELINE_CHPICK;
256 }
@@ -266,11 +261,11 @@
266 const char *zType = db_column_text(pQuery, 7);
267 const char *zUser = db_column_text(pQuery, 4);
268 const char *zTagList = db_column_text(pQuery, 8);
269 int tagid = db_column_int(pQuery, 9);
270 const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
271 const char *zBr = 0; /* Branch */
272 int commentColumn = 3; /* Column containing comment text */
273 int modPending; /* Pending moderation */
274 char *zDateLink; /* URL for the link on the timestamp */
275 int drawDetailEllipsis; /* True to show ellipsis in place of detail */
276 int gidx = 0; /* Graph row identifier */
@@ -412,17 +407,11 @@
412 }
413 }
414 if( zType[0]=='c'
415 && (pGraph || zBgClr==0 || (tmFlags & (TIMELINE_BRCOLOR|TIMELINE_DELTA))!=0)
416 ){
417 db_reset(&qbranch);
418 db_bind_int(&qbranch, ":rid", rid);
419 if( db_step(&qbranch)==SQLITE_ROW ){
420 zBr = db_column_text(&qbranch, 0);
421 }else{
422 zBr = "trunk";
423 }
424 if( zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0 ){
425 if( tmFlags & (TIMELINE_DELTA|TIMELINE_NOCOLOR) ){
426 }else if( zBr==0 || strcmp(zBr,"trunk")==0 ){
427 zBgClr = 0;
428 }else{
@@ -459,19 +448,19 @@
459 db_reset(&qcherrypick);
460 }
461 gidx = graph_add_row(pGraph, rid, nParent, nCherrypick, aParent,
462 zBr, zBgClr, zUuid,
463 isLeaf ? isLeaf + 2 * has_closed_tag(rid) : 0);
464 db_reset(&qbranch);
465 @ <div id="m%d(gidx)" class="tl-nodemark"></div>
466 }else if( zType[0]=='e' && pGraph && zBgClr && zBgClr[0] ){
467 /* For technotes, make a graph node with nParent==(-1). This will
468 ** not actually draw anything on the graph, but it will set the
469 ** background color of the timeline entry */
470 gidx = graph_add_row(pGraph, rid, -1, 0, 0, zBr, zBgClr, zUuid, 0);
471 @ <div id="m%d(gidx)" class="tl-nodemark"></div>
472 }
 
473 @</td>
474 if( !isSelectedOrCurrent ){
475 @ <td class="timeline%s(zStyle)Cell%s(zExtraClass)" id='mc%d(gidx)'>
476 }else{
477 @ <td class="timeline%s(zStyle)Cell%s(zExtraClass)">
478
--- src/timeline.c
+++ src/timeline.c
@@ -205,11 +205,10 @@
205 char zPrevDate[20];
206 GraphContext *pGraph = 0;
207 int prevWasDivider = 0; /* True if previous output row was <hr> */
208 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
209 Stmt fchngQuery; /* Query for file changes on check-ins */
 
210 int pendingEndTr = 0; /* True if a </td></tr> is needed */
211 int vid = 0; /* Current check-out version */
212 int dateFormat = 0; /* 0: HH:MM (default) */
213 int bCommentGitStyle = 0; /* Only show comments through first blank line */
214 const char *zStyle; /* Sub-name for classes for the style */
@@ -243,14 +242,10 @@
242 zDateFmt = P("datefmt");
243 if( zDateFmt ) dateFormat = atoi(zDateFmt);
244 if( tmFlags & TIMELINE_GRAPH ){
245 pGraph = graph_init();
246 }
 
 
 
 
247 if( (tmFlags & TIMELINE_CHPICK)!=0
248 && !db_table_exists("repository","cherrypick")
249 ){
250 tmFlags &= ~TIMELINE_CHPICK;
251 }
@@ -266,11 +261,11 @@
261 const char *zType = db_column_text(pQuery, 7);
262 const char *zUser = db_column_text(pQuery, 4);
263 const char *zTagList = db_column_text(pQuery, 8);
264 int tagid = db_column_int(pQuery, 9);
265 const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
266 char *zBr = 0; /* Branch */
267 int commentColumn = 3; /* Column containing comment text */
268 int modPending; /* Pending moderation */
269 char *zDateLink; /* URL for the link on the timestamp */
270 int drawDetailEllipsis; /* True to show ellipsis in place of detail */
271 int gidx = 0; /* Graph row identifier */
@@ -412,17 +407,11 @@
407 }
408 }
409 if( zType[0]=='c'
410 && (pGraph || zBgClr==0 || (tmFlags & (TIMELINE_BRCOLOR|TIMELINE_DELTA))!=0)
411 ){
412 zBr = branch_of_rid(rid);
 
 
 
 
 
 
413 if( zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0 ){
414 if( tmFlags & (TIMELINE_DELTA|TIMELINE_NOCOLOR) ){
415 }else if( zBr==0 || strcmp(zBr,"trunk")==0 ){
416 zBgClr = 0;
417 }else{
@@ -459,19 +448,19 @@
448 db_reset(&qcherrypick);
449 }
450 gidx = graph_add_row(pGraph, rid, nParent, nCherrypick, aParent,
451 zBr, zBgClr, zUuid,
452 isLeaf ? isLeaf + 2 * has_closed_tag(rid) : 0);
 
453 @ <div id="m%d(gidx)" class="tl-nodemark"></div>
454 }else if( zType[0]=='e' && pGraph && zBgClr && zBgClr[0] ){
455 /* For technotes, make a graph node with nParent==(-1). This will
456 ** not actually draw anything on the graph, but it will set the
457 ** background color of the timeline entry */
458 gidx = graph_add_row(pGraph, rid, -1, 0, 0, zBr, zBgClr, zUuid, 0);
459 @ <div id="m%d(gidx)" class="tl-nodemark"></div>
460 }
461 fossil_free(zBr);
462 @</td>
463 if( !isSelectedOrCurrent ){
464 @ <td class="timeline%s(zStyle)Cell%s(zExtraClass)" id='mc%d(gidx)'>
465 }else{
466 @ <td class="timeline%s(zStyle)Cell%s(zExtraClass)">
467

Keyboard Shortcuts

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