Fossil SCM

Put the divider marks around the base check-in on ancestor and descendent timelines.

drh 2009-08-29 22:54 trunk
Commit d42adc11c8473e0d00efe377a1da8e8e3ffdea76
1 file changed +38 -14
+38 -14
--- src/timeline.c
+++ src/timeline.c
@@ -334,10 +334,30 @@
334334
const char *zRemove /* Parameter to omit */
335335
){
336336
style_submenu_element(zMenuName, zMenuName, "%s",
337337
url_render(pUrl, zParam, zValue, zRemove, 0));
338338
}
339
+
340
+
341
+/*
342
+** zDate is a localtime date. Insert records into the
343
+** "timeline" table to cause <hr> to be inserted before and after
344
+** entries of that date.
345
+*/
346
+static void timeline_add_dividers(const char *zDate){
347
+ db_multi_exec(
348
+ "INSERT INTO timeline(rid,timestamp,etype)"
349
+ "VALUES(-1,datetime(%Q,'-1 second') || '.9','div')",
350
+ zDate
351
+ );
352
+ db_multi_exec(
353
+ "INSERT INTO timeline(rid,timestamp,etype)"
354
+ "VALUES(-2,datetime(%Q) || '.1','div')",
355
+ zDate
356
+ );
357
+}
358
+
339359
340360
/*
341361
** WEBPAGE: timeline
342362
**
343363
** Query parameters:
@@ -396,41 +416,54 @@
396416
if( p_rid || d_rid ){
397417
/* If p= or d= is present, ignore all other parameters other than n= */
398418
char *zUuid;
399419
int np, nd;
400420
401
- if( p_rid && d_rid && p_rid!=d_rid ) p_rid = d_rid;
421
+ if( p_rid && d_rid ){
422
+ if( p_rid!=d_rid ) p_rid = d_rid;
423
+ if( P("n")==0 ) nEntry = 10;
424
+ }
402425
db_multi_exec(
403426
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
404427
);
405428
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",
406429
p_rid ? p_rid : d_rid);
407430
blob_appendf(&sql, " AND event.objid IN ok");
408431
nd = 0;
409432
if( d_rid ){
410
- compute_descendants(d_rid, nEntry);
433
+ compute_descendants(d_rid, nEntry+1);
411434
nd = db_int(0, "SELECT count(*)-1 FROM ok");
412435
if( nd>0 ){
413436
db_multi_exec("%s", blob_str(&sql));
414437
blob_appendf(&desc, "%d descendants", nd);
415438
}
439
+ timeline_add_dividers(
440
+ db_text("1","SELECT datetime(mtime,'localtime') FROM event"
441
+ " WHERE objid=%d", d_rid)
442
+ );
416443
db_multi_exec("DELETE FROM ok");
417444
}
418445
if( p_rid ){
419
- compute_ancestors(p_rid, nEntry);
446
+ compute_ancestors(p_rid, nEntry+1);
420447
np = db_int(0, "SELECT count(*)-1 FROM ok");
421448
if( np>0 ){
422449
if( nd>0 ) blob_appendf(&desc, " and ");
423450
blob_appendf(&desc, "%d ancestors", np);
424451
db_multi_exec("%s", blob_str(&sql));
425452
}
453
+ if( d_rid==0 ){
454
+ timeline_add_dividers(
455
+ db_text("1","SELECT datetime(mtime,'localtime') FROM event"
456
+ " WHERE objid=%d", p_rid)
457
+ );
458
+ }
426459
}
427460
if( g.okHistory ){
428461
blob_appendf(&desc, " of <a href='%s/info/%s'>[%.10s]</a>",
429462
g.zBaseURL, zUuid, zUuid);
430463
}else{
431
- blob_appendf(&desc, " of [%.10s]", zUuid);
464
+ blob_appendf(&desc, " of check-in [%.10s]", zUuid);
432465
}
433466
}else{
434467
int n;
435468
const char *zEType = "event";
436469
char *zDate;
@@ -495,20 +528,11 @@
495528
blob_appendf(&sql,
496529
" AND event.mtime>=%f ORDER BY event.mtime ASC",
497530
rCirca
498531
);
499532
nEntry -= (nEntry+1)/2;
500
- db_multi_exec(
501
- "INSERT INTO timeline(rid,timestamp,etype)"
502
- "VALUES(-1,datetime(%Q,'-1 second') || '.9','div')",
503
- zCirca
504
- );
505
- db_multi_exec(
506
- "INSERT INTO timeline(rid,timestamp,etype)"
507
- "VALUES(-2,datetime(%Q) || '.1','div')",
508
- zCirca
509
- );
533
+ timeline_add_dividers(zCirca);
510534
url_add_parameter(&url, "c", zCirca);
511535
}else{
512536
zCirca = 0;
513537
}
514538
}else{
515539
--- src/timeline.c
+++ src/timeline.c
@@ -334,10 +334,30 @@
334 const char *zRemove /* Parameter to omit */
335 ){
336 style_submenu_element(zMenuName, zMenuName, "%s",
337 url_render(pUrl, zParam, zValue, zRemove, 0));
338 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
340 /*
341 ** WEBPAGE: timeline
342 **
343 ** Query parameters:
@@ -396,41 +416,54 @@
396 if( p_rid || d_rid ){
397 /* If p= or d= is present, ignore all other parameters other than n= */
398 char *zUuid;
399 int np, nd;
400
401 if( p_rid && d_rid && p_rid!=d_rid ) p_rid = d_rid;
 
 
 
402 db_multi_exec(
403 "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
404 );
405 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",
406 p_rid ? p_rid : d_rid);
407 blob_appendf(&sql, " AND event.objid IN ok");
408 nd = 0;
409 if( d_rid ){
410 compute_descendants(d_rid, nEntry);
411 nd = db_int(0, "SELECT count(*)-1 FROM ok");
412 if( nd>0 ){
413 db_multi_exec("%s", blob_str(&sql));
414 blob_appendf(&desc, "%d descendants", nd);
415 }
 
 
 
 
416 db_multi_exec("DELETE FROM ok");
417 }
418 if( p_rid ){
419 compute_ancestors(p_rid, nEntry);
420 np = db_int(0, "SELECT count(*)-1 FROM ok");
421 if( np>0 ){
422 if( nd>0 ) blob_appendf(&desc, " and ");
423 blob_appendf(&desc, "%d ancestors", np);
424 db_multi_exec("%s", blob_str(&sql));
425 }
 
 
 
 
 
 
426 }
427 if( g.okHistory ){
428 blob_appendf(&desc, " of <a href='%s/info/%s'>[%.10s]</a>",
429 g.zBaseURL, zUuid, zUuid);
430 }else{
431 blob_appendf(&desc, " of [%.10s]", zUuid);
432 }
433 }else{
434 int n;
435 const char *zEType = "event";
436 char *zDate;
@@ -495,20 +528,11 @@
495 blob_appendf(&sql,
496 " AND event.mtime>=%f ORDER BY event.mtime ASC",
497 rCirca
498 );
499 nEntry -= (nEntry+1)/2;
500 db_multi_exec(
501 "INSERT INTO timeline(rid,timestamp,etype)"
502 "VALUES(-1,datetime(%Q,'-1 second') || '.9','div')",
503 zCirca
504 );
505 db_multi_exec(
506 "INSERT INTO timeline(rid,timestamp,etype)"
507 "VALUES(-2,datetime(%Q) || '.1','div')",
508 zCirca
509 );
510 url_add_parameter(&url, "c", zCirca);
511 }else{
512 zCirca = 0;
513 }
514 }else{
515
--- src/timeline.c
+++ src/timeline.c
@@ -334,10 +334,30 @@
334 const char *zRemove /* Parameter to omit */
335 ){
336 style_submenu_element(zMenuName, zMenuName, "%s",
337 url_render(pUrl, zParam, zValue, zRemove, 0));
338 }
339
340
341 /*
342 ** zDate is a localtime date. Insert records into the
343 ** "timeline" table to cause <hr> to be inserted before and after
344 ** entries of that date.
345 */
346 static void timeline_add_dividers(const char *zDate){
347 db_multi_exec(
348 "INSERT INTO timeline(rid,timestamp,etype)"
349 "VALUES(-1,datetime(%Q,'-1 second') || '.9','div')",
350 zDate
351 );
352 db_multi_exec(
353 "INSERT INTO timeline(rid,timestamp,etype)"
354 "VALUES(-2,datetime(%Q) || '.1','div')",
355 zDate
356 );
357 }
358
359
360 /*
361 ** WEBPAGE: timeline
362 **
363 ** Query parameters:
@@ -396,41 +416,54 @@
416 if( p_rid || d_rid ){
417 /* If p= or d= is present, ignore all other parameters other than n= */
418 char *zUuid;
419 int np, nd;
420
421 if( p_rid && d_rid ){
422 if( p_rid!=d_rid ) p_rid = d_rid;
423 if( P("n")==0 ) nEntry = 10;
424 }
425 db_multi_exec(
426 "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
427 );
428 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",
429 p_rid ? p_rid : d_rid);
430 blob_appendf(&sql, " AND event.objid IN ok");
431 nd = 0;
432 if( d_rid ){
433 compute_descendants(d_rid, nEntry+1);
434 nd = db_int(0, "SELECT count(*)-1 FROM ok");
435 if( nd>0 ){
436 db_multi_exec("%s", blob_str(&sql));
437 blob_appendf(&desc, "%d descendants", nd);
438 }
439 timeline_add_dividers(
440 db_text("1","SELECT datetime(mtime,'localtime') FROM event"
441 " WHERE objid=%d", d_rid)
442 );
443 db_multi_exec("DELETE FROM ok");
444 }
445 if( p_rid ){
446 compute_ancestors(p_rid, nEntry+1);
447 np = db_int(0, "SELECT count(*)-1 FROM ok");
448 if( np>0 ){
449 if( nd>0 ) blob_appendf(&desc, " and ");
450 blob_appendf(&desc, "%d ancestors", np);
451 db_multi_exec("%s", blob_str(&sql));
452 }
453 if( d_rid==0 ){
454 timeline_add_dividers(
455 db_text("1","SELECT datetime(mtime,'localtime') FROM event"
456 " WHERE objid=%d", p_rid)
457 );
458 }
459 }
460 if( g.okHistory ){
461 blob_appendf(&desc, " of <a href='%s/info/%s'>[%.10s]</a>",
462 g.zBaseURL, zUuid, zUuid);
463 }else{
464 blob_appendf(&desc, " of check-in [%.10s]", zUuid);
465 }
466 }else{
467 int n;
468 const char *zEType = "event";
469 char *zDate;
@@ -495,20 +528,11 @@
528 blob_appendf(&sql,
529 " AND event.mtime>=%f ORDER BY event.mtime ASC",
530 rCirca
531 );
532 nEntry -= (nEntry+1)/2;
533 timeline_add_dividers(zCirca);
 
 
 
 
 
 
 
 
 
534 url_add_parameter(&url, "c", zCirca);
535 }else{
536 zCirca = 0;
537 }
538 }else{
539

Keyboard Shortcuts

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