Fossil SCM

Improvements to the web display of file annotations.

drh 2013-05-27 01:56 trunk
Commit 59d70140f69e98041a8a59871f46ea3483732d7a
1 file changed +21 -29
+21 -29
--- src/diff.c
+++ src/diff.c
@@ -2195,10 +2195,11 @@
21952195
short int n; /* Number of bytes (omitting trailing space and \n) */
21962196
short int iVers; /* Level at which tag was set */
21972197
} *aOrig;
21982198
int nOrig; /* Number of elements in aOrig[] */
21992199
int nVers; /* Number of versions analyzed */
2200
+ int bLimit; /* True if the iLimit was reached */
22002201
struct AnnVers {
22012202
const char *zFUuid; /* File being analyzed */
22022203
const char *zMUuid; /* Check-in containing the file */
22032204
const char *zDate; /* Date of the check-in */
22042205
const char *zBgColor; /* Suggested background color */
@@ -2354,10 +2355,11 @@
23542355
db_reset(&q);
23552356
rid = prevId;
23562357
db_bind_int(&q, ":rid", prevId);
23572358
cnt++;
23582359
}
2360
+ p->bLimit = iLimit==cnt;
23592361
db_finalize(&q);
23602362
db_finalize(&ins);
23612363
db_end_transaction(0);
23622364
}
23632365
@@ -2385,78 +2387,73 @@
23852387
** Query parameters:
23862388
**
23872389
** checkin=ID The manifest ID at which to start the annotation
23882390
** filename=FILENAME The filename.
23892391
** filevers Show file versions rather than check-in versions
2390
-** log Show a log of versions analyzed
2391
-** ln Show line numbers on the output
2392
+** log=BOOLEAN Show a log of versions analyzed
23922393
** limit=N Limit the search depth to N ancestors
23932394
*/
23942395
void annotation_page(void){
23952396
int mid;
23962397
int fnid;
23972398
int i;
23982399
int iLimit; /* Depth limit */
23992400
int annFlags = ANN_FILE_ANCEST;
2400
- int showLn = 0; /* True if line numbers should be shown */
24012401
int showLog = 0; /* True to display the log */
2402
- char zLn[10]; /* Line number buffer */
2402
+ const char *zFilename; /* Name of file to annotate */
24032403
char zFormat[10]; /* Format string for line numbers */
24042404
Annotator ann;
24052405
HQuery url;
24062406
struct AnnVers *p;
24072407
unsigned clr1, clr2, clr;
24082408
2409
- showLn = atoi(PD("ln","1"));
2409
+ /* Gather query parameters */
24102410
showLog = atoi(PD("log","1"));
24112411
login_check_credentials();
24122412
if( !g.perm.Read ){ login_needed(); return; }
24132413
mid = name_to_typed_rid(PD("checkin","0"),"ci");
2414
- fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", P("filename"));
2414
+ zFilename = P("filename");
2415
+ fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
24152416
if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
24162417
iLimit = atoi(PD("limit","20"));
24172418
if( P("filevers") ) annFlags |= ANN_FILE_VERS;
24182419
if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
24192420
fossil_redirect_home();
24202421
}
2422
+
2423
+ /* compute the annotation */
24212424
compute_direct_ancestors(mid, 10000000);
2422
- style_header("File Annotation");
2425
+ annotate_file(&ann, fnid, mid, iLimit, annFlags);
2426
+
2427
+ /* generate the web page */
2428
+ style_header("Annotation For %h", zFilename);
24232429
url_initialize(&url, "annotate");
24242430
url_add_parameter(&url, "checkin", P("checkin"));
2425
- url_add_parameter(&url, "filename", P("filename"));
2431
+ url_add_parameter(&url, "filename", zFilename);
24262432
if( iLimit!=20 ){
24272433
url_add_parameter(&url, "limit", sqlite3_mprintf("%d", iLimit));
24282434
}
24292435
url_add_parameter(&url, "log", showLog ? "1" : "0");
2430
- url_add_parameter(&url, "ln", showLn ? "1" : "0");
24312436
if( showLog ){
24322437
style_submenu_element("Hide Log", "Hide Log",
24332438
url_render(&url, "log", "0", 0, 0));
24342439
}else{
24352440
style_submenu_element("Show Log", "Show Log",
24362441
url_render(&url, "log", "1", 0, 0));
24372442
}
2438
- if( showLn ){
2439
- style_submenu_element("Hide Line Numbers", "Hide Line Numbers",
2440
- url_render(&url, "ln", "0", 0, 0));
2441
- }else{
2442
- style_submenu_element("Show Line Numbers", "Show Line Numbers",
2443
- url_render(&url, "ln", "1", 0, 0));
2444
- }
2445
- if( iLimit>0 ){
2443
+ if( ann.bLimit ){
24462444
char *z1, *z2;
24472445
style_submenu_element("All Ancestors", "All Ancestors",
24482446
url_render(&url, "limit", "-1", 0, 0));
24492447
z1 = sqlite3_mprintf("%d Ancestors", iLimit+20);
24502448
z2 = sqlite3_mprintf("%d", iLimit+20);
24512449
style_submenu_element(z1, z1, url_render(&url, "limit", z2, 0, 0));
24522450
}
2453
- if( iLimit!=20 ){
2451
+ if( iLimit>20 ){
24542452
style_submenu_element("20 Ancestors", "20 Ancestors",
24552453
url_render(&url, "limit", "20", 0, 0));
24562454
}
2457
- annotate_file(&ann, fnid, mid, iLimit, annFlags);
24582455
if( db_get_boolean("white-foreground", 0) ){
24592456
clr1 = 0xa04040;
24602457
clr2 = 0x4059a0;
24612458
}else{
24622459
clr1 = 0xffb5b5; /* Recent changes: red (hot) */
@@ -2466,11 +2463,11 @@
24662463
clr = gradient_color(clr1, clr2, ann.nVers-1, i);
24672464
ann.aVers[i].zBgColor = mprintf("#%06x", clr);
24682465
}
24692466
24702467
if( showLog ){
2471
- @ <h2>Versions analyzed:</h2>
2468
+ @ <h2>Ancestors of %h(zFilename) analyzed:</h2>
24722469
@ <ol>
24732470
for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){
24742471
@ <li><span style='background-color:%s(p->zBgColor);'>%s(p->zDate)
24752472
@ check-in %z(href("%R/info/%S",p->zMUuid))%.10s(p->zMUuid)</a>
24762473
@ artifact %z(href("%R/artifact/%S",p->zFUuid))%.10s(p->zFUuid)</a>
@@ -2491,21 +2488,16 @@
24912488
#endif
24922489
}
24932490
@ </ol>
24942491
@ <hr>
24952492
}
2496
- if( iLimit<0 ){
2497
- @ <h2>Annotation:</h2>
2493
+ if( !ann.bLimit ){
2494
+ @ <h2>Origin for each line in %h(zFilename):</h2>
24982495
iLimit = ann.nVers+10;
24992496
}else{
2500
- @ <h2>Annotation of %d(iLimit) most recent ancestors:</h2>
2501
- }
2502
- if( showLn ){
2503
- sqlite3_snprintf(sizeof(zLn), zLn, "%d", ann.nOrig+1);
2504
- sqlite3_snprintf(sizeof(zFormat), zFormat, "%%%dd:", strlen(zLn));
2505
- }else{
2506
- zLn[0] = 0;
2497
+ @ <h2>Lines added by the %d(iLimit) most recent
2498
+ @ ancestors of %h(zFilename):</h2>
25072499
}
25082500
@ <pre>
25092501
for(i=0; i<ann.nOrig; i++){
25102502
int iVers = ann.aOrig[i].iVers;
25112503
char *z = (char*)ann.aOrig[i].z;
25122504
--- src/diff.c
+++ src/diff.c
@@ -2195,10 +2195,11 @@
2195 short int n; /* Number of bytes (omitting trailing space and \n) */
2196 short int iVers; /* Level at which tag was set */
2197 } *aOrig;
2198 int nOrig; /* Number of elements in aOrig[] */
2199 int nVers; /* Number of versions analyzed */
 
2200 struct AnnVers {
2201 const char *zFUuid; /* File being analyzed */
2202 const char *zMUuid; /* Check-in containing the file */
2203 const char *zDate; /* Date of the check-in */
2204 const char *zBgColor; /* Suggested background color */
@@ -2354,10 +2355,11 @@
2354 db_reset(&q);
2355 rid = prevId;
2356 db_bind_int(&q, ":rid", prevId);
2357 cnt++;
2358 }
 
2359 db_finalize(&q);
2360 db_finalize(&ins);
2361 db_end_transaction(0);
2362 }
2363
@@ -2385,78 +2387,73 @@
2385 ** Query parameters:
2386 **
2387 ** checkin=ID The manifest ID at which to start the annotation
2388 ** filename=FILENAME The filename.
2389 ** filevers Show file versions rather than check-in versions
2390 ** log Show a log of versions analyzed
2391 ** ln Show line numbers on the output
2392 ** limit=N Limit the search depth to N ancestors
2393 */
2394 void annotation_page(void){
2395 int mid;
2396 int fnid;
2397 int i;
2398 int iLimit; /* Depth limit */
2399 int annFlags = ANN_FILE_ANCEST;
2400 int showLn = 0; /* True if line numbers should be shown */
2401 int showLog = 0; /* True to display the log */
2402 char zLn[10]; /* Line number buffer */
2403 char zFormat[10]; /* Format string for line numbers */
2404 Annotator ann;
2405 HQuery url;
2406 struct AnnVers *p;
2407 unsigned clr1, clr2, clr;
2408
2409 showLn = atoi(PD("ln","1"));
2410 showLog = atoi(PD("log","1"));
2411 login_check_credentials();
2412 if( !g.perm.Read ){ login_needed(); return; }
2413 mid = name_to_typed_rid(PD("checkin","0"),"ci");
2414 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", P("filename"));
 
2415 if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
2416 iLimit = atoi(PD("limit","20"));
2417 if( P("filevers") ) annFlags |= ANN_FILE_VERS;
2418 if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
2419 fossil_redirect_home();
2420 }
 
 
2421 compute_direct_ancestors(mid, 10000000);
2422 style_header("File Annotation");
 
 
 
2423 url_initialize(&url, "annotate");
2424 url_add_parameter(&url, "checkin", P("checkin"));
2425 url_add_parameter(&url, "filename", P("filename"));
2426 if( iLimit!=20 ){
2427 url_add_parameter(&url, "limit", sqlite3_mprintf("%d", iLimit));
2428 }
2429 url_add_parameter(&url, "log", showLog ? "1" : "0");
2430 url_add_parameter(&url, "ln", showLn ? "1" : "0");
2431 if( showLog ){
2432 style_submenu_element("Hide Log", "Hide Log",
2433 url_render(&url, "log", "0", 0, 0));
2434 }else{
2435 style_submenu_element("Show Log", "Show Log",
2436 url_render(&url, "log", "1", 0, 0));
2437 }
2438 if( showLn ){
2439 style_submenu_element("Hide Line Numbers", "Hide Line Numbers",
2440 url_render(&url, "ln", "0", 0, 0));
2441 }else{
2442 style_submenu_element("Show Line Numbers", "Show Line Numbers",
2443 url_render(&url, "ln", "1", 0, 0));
2444 }
2445 if( iLimit>0 ){
2446 char *z1, *z2;
2447 style_submenu_element("All Ancestors", "All Ancestors",
2448 url_render(&url, "limit", "-1", 0, 0));
2449 z1 = sqlite3_mprintf("%d Ancestors", iLimit+20);
2450 z2 = sqlite3_mprintf("%d", iLimit+20);
2451 style_submenu_element(z1, z1, url_render(&url, "limit", z2, 0, 0));
2452 }
2453 if( iLimit!=20 ){
2454 style_submenu_element("20 Ancestors", "20 Ancestors",
2455 url_render(&url, "limit", "20", 0, 0));
2456 }
2457 annotate_file(&ann, fnid, mid, iLimit, annFlags);
2458 if( db_get_boolean("white-foreground", 0) ){
2459 clr1 = 0xa04040;
2460 clr2 = 0x4059a0;
2461 }else{
2462 clr1 = 0xffb5b5; /* Recent changes: red (hot) */
@@ -2466,11 +2463,11 @@
2466 clr = gradient_color(clr1, clr2, ann.nVers-1, i);
2467 ann.aVers[i].zBgColor = mprintf("#%06x", clr);
2468 }
2469
2470 if( showLog ){
2471 @ <h2>Versions analyzed:</h2>
2472 @ <ol>
2473 for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){
2474 @ <li><span style='background-color:%s(p->zBgColor);'>%s(p->zDate)
2475 @ check-in %z(href("%R/info/%S",p->zMUuid))%.10s(p->zMUuid)</a>
2476 @ artifact %z(href("%R/artifact/%S",p->zFUuid))%.10s(p->zFUuid)</a>
@@ -2491,21 +2488,16 @@
2491 #endif
2492 }
2493 @ </ol>
2494 @ <hr>
2495 }
2496 if( iLimit<0 ){
2497 @ <h2>Annotation:</h2>
2498 iLimit = ann.nVers+10;
2499 }else{
2500 @ <h2>Annotation of %d(iLimit) most recent ancestors:</h2>
2501 }
2502 if( showLn ){
2503 sqlite3_snprintf(sizeof(zLn), zLn, "%d", ann.nOrig+1);
2504 sqlite3_snprintf(sizeof(zFormat), zFormat, "%%%dd:", strlen(zLn));
2505 }else{
2506 zLn[0] = 0;
2507 }
2508 @ <pre>
2509 for(i=0; i<ann.nOrig; i++){
2510 int iVers = ann.aOrig[i].iVers;
2511 char *z = (char*)ann.aOrig[i].z;
2512
--- src/diff.c
+++ src/diff.c
@@ -2195,10 +2195,11 @@
2195 short int n; /* Number of bytes (omitting trailing space and \n) */
2196 short int iVers; /* Level at which tag was set */
2197 } *aOrig;
2198 int nOrig; /* Number of elements in aOrig[] */
2199 int nVers; /* Number of versions analyzed */
2200 int bLimit; /* True if the iLimit was reached */
2201 struct AnnVers {
2202 const char *zFUuid; /* File being analyzed */
2203 const char *zMUuid; /* Check-in containing the file */
2204 const char *zDate; /* Date of the check-in */
2205 const char *zBgColor; /* Suggested background color */
@@ -2354,10 +2355,11 @@
2355 db_reset(&q);
2356 rid = prevId;
2357 db_bind_int(&q, ":rid", prevId);
2358 cnt++;
2359 }
2360 p->bLimit = iLimit==cnt;
2361 db_finalize(&q);
2362 db_finalize(&ins);
2363 db_end_transaction(0);
2364 }
2365
@@ -2385,78 +2387,73 @@
2387 ** Query parameters:
2388 **
2389 ** checkin=ID The manifest ID at which to start the annotation
2390 ** filename=FILENAME The filename.
2391 ** filevers Show file versions rather than check-in versions
2392 ** log=BOOLEAN Show a log of versions analyzed
 
2393 ** limit=N Limit the search depth to N ancestors
2394 */
2395 void annotation_page(void){
2396 int mid;
2397 int fnid;
2398 int i;
2399 int iLimit; /* Depth limit */
2400 int annFlags = ANN_FILE_ANCEST;
 
2401 int showLog = 0; /* True to display the log */
2402 const char *zFilename; /* Name of file to annotate */
2403 char zFormat[10]; /* Format string for line numbers */
2404 Annotator ann;
2405 HQuery url;
2406 struct AnnVers *p;
2407 unsigned clr1, clr2, clr;
2408
2409 /* Gather query parameters */
2410 showLog = atoi(PD("log","1"));
2411 login_check_credentials();
2412 if( !g.perm.Read ){ login_needed(); return; }
2413 mid = name_to_typed_rid(PD("checkin","0"),"ci");
2414 zFilename = P("filename");
2415 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
2416 if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
2417 iLimit = atoi(PD("limit","20"));
2418 if( P("filevers") ) annFlags |= ANN_FILE_VERS;
2419 if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
2420 fossil_redirect_home();
2421 }
2422
2423 /* compute the annotation */
2424 compute_direct_ancestors(mid, 10000000);
2425 annotate_file(&ann, fnid, mid, iLimit, annFlags);
2426
2427 /* generate the web page */
2428 style_header("Annotation For %h", zFilename);
2429 url_initialize(&url, "annotate");
2430 url_add_parameter(&url, "checkin", P("checkin"));
2431 url_add_parameter(&url, "filename", zFilename);
2432 if( iLimit!=20 ){
2433 url_add_parameter(&url, "limit", sqlite3_mprintf("%d", iLimit));
2434 }
2435 url_add_parameter(&url, "log", showLog ? "1" : "0");
 
2436 if( showLog ){
2437 style_submenu_element("Hide Log", "Hide Log",
2438 url_render(&url, "log", "0", 0, 0));
2439 }else{
2440 style_submenu_element("Show Log", "Show Log",
2441 url_render(&url, "log", "1", 0, 0));
2442 }
2443 if( ann.bLimit ){
 
 
 
 
 
 
 
2444 char *z1, *z2;
2445 style_submenu_element("All Ancestors", "All Ancestors",
2446 url_render(&url, "limit", "-1", 0, 0));
2447 z1 = sqlite3_mprintf("%d Ancestors", iLimit+20);
2448 z2 = sqlite3_mprintf("%d", iLimit+20);
2449 style_submenu_element(z1, z1, url_render(&url, "limit", z2, 0, 0));
2450 }
2451 if( iLimit>20 ){
2452 style_submenu_element("20 Ancestors", "20 Ancestors",
2453 url_render(&url, "limit", "20", 0, 0));
2454 }
 
2455 if( db_get_boolean("white-foreground", 0) ){
2456 clr1 = 0xa04040;
2457 clr2 = 0x4059a0;
2458 }else{
2459 clr1 = 0xffb5b5; /* Recent changes: red (hot) */
@@ -2466,11 +2463,11 @@
2463 clr = gradient_color(clr1, clr2, ann.nVers-1, i);
2464 ann.aVers[i].zBgColor = mprintf("#%06x", clr);
2465 }
2466
2467 if( showLog ){
2468 @ <h2>Ancestors of %h(zFilename) analyzed:</h2>
2469 @ <ol>
2470 for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){
2471 @ <li><span style='background-color:%s(p->zBgColor);'>%s(p->zDate)
2472 @ check-in %z(href("%R/info/%S",p->zMUuid))%.10s(p->zMUuid)</a>
2473 @ artifact %z(href("%R/artifact/%S",p->zFUuid))%.10s(p->zFUuid)</a>
@@ -2491,21 +2488,16 @@
2488 #endif
2489 }
2490 @ </ol>
2491 @ <hr>
2492 }
2493 if( !ann.bLimit ){
2494 @ <h2>Origin for each line in %h(zFilename):</h2>
2495 iLimit = ann.nVers+10;
2496 }else{
2497 @ <h2>Lines added by the %d(iLimit) most recent
2498 @ ancestors of %h(zFilename):</h2>
 
 
 
 
 
2499 }
2500 @ <pre>
2501 for(i=0; i<ann.nOrig; i++){
2502 int iVers = ann.aOrig[i].iVers;
2503 char *z = (char*)ann.aOrig[i].z;
2504

Keyboard Shortcuts

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