Fossil SCM

If a branch does not have a color set for it, choose a background color for the timeline background based on a hash of the branch name.

drh 2011-07-22 23:46 trunk
Commit c946b573c7d03af9fcbf14cb72cb6b84267e1503
1 file changed +25 -20
+25 -20
--- src/timeline.c
+++ src/timeline.c
@@ -174,10 +174,11 @@
174174
char zPrevDate[20];
175175
GraphContext *pGraph = 0;
176176
int prevWasDivider = 0; /* True if previous output row was <hr> */
177177
int fchngQueryInit = 0; /* True if fchngQuery is initialized */
178178
Stmt fchngQuery; /* Query for file changes on check-ins */
179
+ static Stmt qbranch;
179180
180181
zPrevDate[0] = 0;
181182
mxWikiLen = db_get_int("timeline-max-comment", 0);
182183
if( db_get_boolean("timeline-block-markup", 0) ){
183184
wikiFlags = WIKI_INLINE;
@@ -189,10 +190,14 @@
189190
/* style is not moved to css, because this is
190191
** a technical div for the timeline graph
191192
*/
192193
@ <div id="canvas" style="position:relative;width:1px;height:1px;"></div>
193194
}
195
+ db_static_prepare(&qbranch,
196
+ "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
197
+ TAG_BRANCH
198
+ );
194199
195200
@ <table id="timelineTable" class="timelineTable">
196201
blob_zero(&comment);
197202
while( db_step(pQuery)==SQLITE_ROW ){
198203
int rid = db_column_int(pQuery, 0);
@@ -202,10 +207,11 @@
202207
const char *zDate = db_column_text(pQuery, 2);
203208
const char *zType = db_column_text(pQuery, 7);
204209
const char *zUser = db_column_text(pQuery, 4);
205210
const char *zTagList = db_column_text(pQuery, 8);
206211
int tagid = db_column_int(pQuery, 9);
212
+ const char *zBr; /* Branch */
207213
int commentColumn = 3; /* Column containing comment text */
208214
char zTime[8];
209215
if( tagid ){
210216
if( tagid==prevTagid ){
211217
if( tmFlags & TIMELINE_BRIEF ){
@@ -241,44 +247,43 @@
241247
zTime[5] = 0;
242248
@ <tr>
243249
@ <td class="timelineTime">%s(zTime)</td>
244250
@ <td class="timelineGraph">
245251
if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hashColor(zUser) : 0;
246
- if( pGraph && zType[0]=='c' ){
252
+ if( zType[0]=='c'
253
+ && (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
254
+ ){
255
+ db_reset(&qbranch);
256
+ db_bind_int(&qbranch, ":rid", rid);
257
+ if( db_step(&qbranch)==SQLITE_ROW ){
258
+ zBr = db_column_text(&qbranch, 0);
259
+ }else{
260
+ zBr = "trunk";
261
+ }
262
+ if( zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0 ){
263
+ if( zBr==0 || strcmp(zBr,"trunk")==0 ){
264
+ zBgClr = 0;
265
+ }else{
266
+ zBgClr = hashColor(zBr);
267
+ }
268
+ }
269
+ }
270
+ if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){
247271
int nParent = 0;
248272
int aParent[32];
249
- const char *zBr;
250273
int gidx;
251274
static Stmt qparent;
252
- static Stmt qbranch;
253275
db_static_prepare(&qparent,
254276
"SELECT pid FROM plink"
255277
" WHERE cid=:rid AND pid NOT IN phantom"
256278
" ORDER BY isprim DESC /*sort*/"
257279
);
258
- db_static_prepare(&qbranch,
259
- "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
260
- TAG_BRANCH
261
- );
262280
db_bind_int(&qparent, ":rid", rid);
263281
while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){
264282
aParent[nParent++] = db_column_int(&qparent, 0);
265283
}
266284
db_reset(&qparent);
267
- db_bind_int(&qbranch, ":rid", rid);
268
- if( db_step(&qbranch)==SQLITE_ROW ){
269
- zBr = db_column_text(&qbranch, 0);
270
- }else{
271
- zBr = "trunk";
272
- }
273
- if( tmFlags & TIMELINE_BRCOLOR ){
274
- if( zBr==0 || strcmp(zBr,"trunk")==0 ){
275
- zBgClr = 0;
276
- }else{
277
- zBgClr = hashColor(zBr);
278
- }
279
- }
280285
gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, isLeaf);
281286
db_reset(&qbranch);
282287
@ <div id="m%d(gidx)"></div>
283288
}
284289
@</td>
285290
--- src/timeline.c
+++ src/timeline.c
@@ -174,10 +174,11 @@
174 char zPrevDate[20];
175 GraphContext *pGraph = 0;
176 int prevWasDivider = 0; /* True if previous output row was <hr> */
177 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
178 Stmt fchngQuery; /* Query for file changes on check-ins */
 
179
180 zPrevDate[0] = 0;
181 mxWikiLen = db_get_int("timeline-max-comment", 0);
182 if( db_get_boolean("timeline-block-markup", 0) ){
183 wikiFlags = WIKI_INLINE;
@@ -189,10 +190,14 @@
189 /* style is not moved to css, because this is
190 ** a technical div for the timeline graph
191 */
192 @ <div id="canvas" style="position:relative;width:1px;height:1px;"></div>
193 }
 
 
 
 
194
195 @ <table id="timelineTable" class="timelineTable">
196 blob_zero(&comment);
197 while( db_step(pQuery)==SQLITE_ROW ){
198 int rid = db_column_int(pQuery, 0);
@@ -202,10 +207,11 @@
202 const char *zDate = db_column_text(pQuery, 2);
203 const char *zType = db_column_text(pQuery, 7);
204 const char *zUser = db_column_text(pQuery, 4);
205 const char *zTagList = db_column_text(pQuery, 8);
206 int tagid = db_column_int(pQuery, 9);
 
207 int commentColumn = 3; /* Column containing comment text */
208 char zTime[8];
209 if( tagid ){
210 if( tagid==prevTagid ){
211 if( tmFlags & TIMELINE_BRIEF ){
@@ -241,44 +247,43 @@
241 zTime[5] = 0;
242 @ <tr>
243 @ <td class="timelineTime">%s(zTime)</td>
244 @ <td class="timelineGraph">
245 if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hashColor(zUser) : 0;
246 if( pGraph && zType[0]=='c' ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247 int nParent = 0;
248 int aParent[32];
249 const char *zBr;
250 int gidx;
251 static Stmt qparent;
252 static Stmt qbranch;
253 db_static_prepare(&qparent,
254 "SELECT pid FROM plink"
255 " WHERE cid=:rid AND pid NOT IN phantom"
256 " ORDER BY isprim DESC /*sort*/"
257 );
258 db_static_prepare(&qbranch,
259 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
260 TAG_BRANCH
261 );
262 db_bind_int(&qparent, ":rid", rid);
263 while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){
264 aParent[nParent++] = db_column_int(&qparent, 0);
265 }
266 db_reset(&qparent);
267 db_bind_int(&qbranch, ":rid", rid);
268 if( db_step(&qbranch)==SQLITE_ROW ){
269 zBr = db_column_text(&qbranch, 0);
270 }else{
271 zBr = "trunk";
272 }
273 if( tmFlags & TIMELINE_BRCOLOR ){
274 if( zBr==0 || strcmp(zBr,"trunk")==0 ){
275 zBgClr = 0;
276 }else{
277 zBgClr = hashColor(zBr);
278 }
279 }
280 gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, isLeaf);
281 db_reset(&qbranch);
282 @ <div id="m%d(gidx)"></div>
283 }
284 @</td>
285
--- src/timeline.c
+++ src/timeline.c
@@ -174,10 +174,11 @@
174 char zPrevDate[20];
175 GraphContext *pGraph = 0;
176 int prevWasDivider = 0; /* True if previous output row was <hr> */
177 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
178 Stmt fchngQuery; /* Query for file changes on check-ins */
179 static Stmt qbranch;
180
181 zPrevDate[0] = 0;
182 mxWikiLen = db_get_int("timeline-max-comment", 0);
183 if( db_get_boolean("timeline-block-markup", 0) ){
184 wikiFlags = WIKI_INLINE;
@@ -189,10 +190,14 @@
190 /* style is not moved to css, because this is
191 ** a technical div for the timeline graph
192 */
193 @ <div id="canvas" style="position:relative;width:1px;height:1px;"></div>
194 }
195 db_static_prepare(&qbranch,
196 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
197 TAG_BRANCH
198 );
199
200 @ <table id="timelineTable" class="timelineTable">
201 blob_zero(&comment);
202 while( db_step(pQuery)==SQLITE_ROW ){
203 int rid = db_column_int(pQuery, 0);
@@ -202,10 +207,11 @@
207 const char *zDate = db_column_text(pQuery, 2);
208 const char *zType = db_column_text(pQuery, 7);
209 const char *zUser = db_column_text(pQuery, 4);
210 const char *zTagList = db_column_text(pQuery, 8);
211 int tagid = db_column_int(pQuery, 9);
212 const char *zBr; /* Branch */
213 int commentColumn = 3; /* Column containing comment text */
214 char zTime[8];
215 if( tagid ){
216 if( tagid==prevTagid ){
217 if( tmFlags & TIMELINE_BRIEF ){
@@ -241,44 +247,43 @@
247 zTime[5] = 0;
248 @ <tr>
249 @ <td class="timelineTime">%s(zTime)</td>
250 @ <td class="timelineGraph">
251 if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hashColor(zUser) : 0;
252 if( zType[0]=='c'
253 && (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
254 ){
255 db_reset(&qbranch);
256 db_bind_int(&qbranch, ":rid", rid);
257 if( db_step(&qbranch)==SQLITE_ROW ){
258 zBr = db_column_text(&qbranch, 0);
259 }else{
260 zBr = "trunk";
261 }
262 if( zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0 ){
263 if( zBr==0 || strcmp(zBr,"trunk")==0 ){
264 zBgClr = 0;
265 }else{
266 zBgClr = hashColor(zBr);
267 }
268 }
269 }
270 if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){
271 int nParent = 0;
272 int aParent[32];
 
273 int gidx;
274 static Stmt qparent;
 
275 db_static_prepare(&qparent,
276 "SELECT pid FROM plink"
277 " WHERE cid=:rid AND pid NOT IN phantom"
278 " ORDER BY isprim DESC /*sort*/"
279 );
 
 
 
 
280 db_bind_int(&qparent, ":rid", rid);
281 while( db_step(&qparent)==SQLITE_ROW && nParent<32 ){
282 aParent[nParent++] = db_column_int(&qparent, 0);
283 }
284 db_reset(&qparent);
 
 
 
 
 
 
 
 
 
 
 
 
 
285 gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, isLeaf);
286 db_reset(&qbranch);
287 @ <div id="m%d(gidx)"></div>
288 }
289 @</td>
290

Keyboard Shortcuts

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