Fossil SCM

Add submenu elements to the web-based "annotate" display to turn features on and off. Make the default depth of an annotation 20.

drh 2013-05-09 15:30 trunk
Commit f4bcdb62fb7fcb6661fe08791f81f05c3fd286a8
1 file changed +50 -5
+50 -5
--- src/diff.c
+++ src/diff.c
@@ -2397,46 +2397,91 @@
23972397
**
23982398
** Query parameters:
23992399
**
24002400
** checkin=ID The manifest ID at which to start the annotation
24012401
** filename=FILENAME The filename.
2402
+** filevers Show file versions rather than check-in versions
2403
+** log Show a log of versions analyzed
2404
+** ln Show line numbers on the output
2405
+** limit=N Limit the search depth to N ancestors
24022406
*/
24032407
void annotation_page(void){
24042408
int mid;
24052409
int fnid;
24062410
int i;
2407
- int iLimit;
2408
- int annFlags = ANN_FILE_ANCEST;
2411
+ int iLimit; /* Depth limit */
2412
+ int annFlags = ANN_FILE_ANCEST;
24092413
int showLn = 0; /* True if line numbers should be shown */
2414
+ int showLog = 0; /* True to display the log */
24102415
char zLn[10]; /* Line number buffer */
24112416
char zFormat[10]; /* Format string for line numbers */
24122417
Annotator ann;
2418
+ HQuery url;
24132419
24142420
showLn = P("ln")!=0;
2421
+ showLog = P("log")!=0;
24152422
login_check_credentials();
24162423
if( !g.perm.Read ){ login_needed(); return; }
24172424
mid = name_to_typed_rid(PD("checkin","0"),"ci");
24182425
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", P("filename"));
24192426
if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
2420
- iLimit = atoi(PD("limit","-1"));
2427
+ iLimit = atoi(PD("limit","20"));
2428
+ if( P("filevers") ) annFlags |= ANN_FILE_VERS;
24212429
if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
24222430
fossil_redirect_home();
24232431
}
24242432
compute_direct_ancestors(mid, 10000000);
24252433
style_header("File Annotation");
2426
- if( P("filevers") ) annFlags |= ANN_FILE_VERS;
2434
+ url_initialize(&url, "annotate");
2435
+ url_add_parameter(&url, "checkin", P("checkin"));
2436
+ url_add_parameter(&url, "filename", P("filename"));
2437
+ if( iLimit!=20 ){
2438
+ url_add_parameter(&url, "limit", sqlite3_mprintf("%d", iLimit));
2439
+ }
2440
+ if( showLog ) url_add_parameter(&url, "log", "1");
2441
+ if( showLn ) url_add_parameter(&url, "ln", "1");
2442
+ if( showLog ){
2443
+ style_submenu_element("Hide Log", "Hide Log",
2444
+ url_render(&url, "log", 0, 0, 0));
2445
+ }else{
2446
+ style_submenu_element("Show Log", "Show Log",
2447
+ url_render(&url, "log", "1", 0, 0));
2448
+ }
2449
+ if( showLn ){
2450
+ style_submenu_element("Hide Line Numbers", "Hide Line Numbers",
2451
+ url_render(&url, "log", 0, 0, 0));
2452
+ }else{
2453
+ style_submenu_element("Show Line Numbers", "Show Line Numbers",
2454
+ url_render(&url, "ln", "1", 0, 0));
2455
+ }
2456
+ if( iLimit>0 ){
2457
+ char *z1, *z2;
2458
+ style_submenu_element("All Ancestors", "All Ancestors",
2459
+ url_render(&url, "limit", "-1", 0, 0));
2460
+ z1 = sqlite3_mprintf("%d Ancestors", iLimit+20);
2461
+ z2 = sqlite3_mprintf("%d", iLimit+20);
2462
+ style_submenu_element(z1, z1, url_render(&url, "limit", z2, 0, 0));
2463
+ }
2464
+ if( iLimit!=20 ){
2465
+ style_submenu_element("20 Ancestors", "20 Ancestors",
2466
+ url_render(&url, "limit", "20", 0, 0));
2467
+ }
24272468
annotate_file(&ann, fnid, mid, g.perm.Hyperlink, iLimit, annFlags);
2428
- if( P("log") ){
2469
+ if( showLog ){
24292470
int i;
24302471
@ <h2>Versions analyzed:</h2>
24312472
@ <ol>
24322473
for(i=0; i<ann.nVers; i++){
24332474
@ <li><tt>%s(ann.azVers[i])</tt></li>
24342475
}
24352476
@ </ol>
24362477
@ <hr>
2478
+ }
2479
+ if( iLimit<0 ){
24372480
@ <h2>Annotation:</h2>
2481
+ }else{
2482
+ @ <h2>Annotation of %d(iLimit) most recent ancestors:</h2>
24382483
}
24392484
if( showLn ){
24402485
sqlite3_snprintf(sizeof(zLn), zLn, "%d", ann.nOrig+1);
24412486
sqlite3_snprintf(sizeof(zFormat), zFormat, "%%%dd:", strlen(zLn));
24422487
}else{
24432488
--- src/diff.c
+++ src/diff.c
@@ -2397,46 +2397,91 @@
2397 **
2398 ** Query parameters:
2399 **
2400 ** checkin=ID The manifest ID at which to start the annotation
2401 ** filename=FILENAME The filename.
 
 
 
 
2402 */
2403 void annotation_page(void){
2404 int mid;
2405 int fnid;
2406 int i;
2407 int iLimit;
2408 int annFlags = ANN_FILE_ANCEST;
2409 int showLn = 0; /* True if line numbers should be shown */
 
2410 char zLn[10]; /* Line number buffer */
2411 char zFormat[10]; /* Format string for line numbers */
2412 Annotator ann;
 
2413
2414 showLn = P("ln")!=0;
 
2415 login_check_credentials();
2416 if( !g.perm.Read ){ login_needed(); return; }
2417 mid = name_to_typed_rid(PD("checkin","0"),"ci");
2418 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", P("filename"));
2419 if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
2420 iLimit = atoi(PD("limit","-1"));
 
2421 if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
2422 fossil_redirect_home();
2423 }
2424 compute_direct_ancestors(mid, 10000000);
2425 style_header("File Annotation");
2426 if( P("filevers") ) annFlags |= ANN_FILE_VERS;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2427 annotate_file(&ann, fnid, mid, g.perm.Hyperlink, iLimit, annFlags);
2428 if( P("log") ){
2429 int i;
2430 @ <h2>Versions analyzed:</h2>
2431 @ <ol>
2432 for(i=0; i<ann.nVers; i++){
2433 @ <li><tt>%s(ann.azVers[i])</tt></li>
2434 }
2435 @ </ol>
2436 @ <hr>
 
 
2437 @ <h2>Annotation:</h2>
 
 
2438 }
2439 if( showLn ){
2440 sqlite3_snprintf(sizeof(zLn), zLn, "%d", ann.nOrig+1);
2441 sqlite3_snprintf(sizeof(zFormat), zFormat, "%%%dd:", strlen(zLn));
2442 }else{
2443
--- src/diff.c
+++ src/diff.c
@@ -2397,46 +2397,91 @@
2397 **
2398 ** Query parameters:
2399 **
2400 ** checkin=ID The manifest ID at which to start the annotation
2401 ** filename=FILENAME The filename.
2402 ** filevers Show file versions rather than check-in versions
2403 ** log Show a log of versions analyzed
2404 ** ln Show line numbers on the output
2405 ** limit=N Limit the search depth to N ancestors
2406 */
2407 void annotation_page(void){
2408 int mid;
2409 int fnid;
2410 int i;
2411 int iLimit; /* Depth limit */
2412 int annFlags = ANN_FILE_ANCEST;
2413 int showLn = 0; /* True if line numbers should be shown */
2414 int showLog = 0; /* True to display the log */
2415 char zLn[10]; /* Line number buffer */
2416 char zFormat[10]; /* Format string for line numbers */
2417 Annotator ann;
2418 HQuery url;
2419
2420 showLn = P("ln")!=0;
2421 showLog = P("log")!=0;
2422 login_check_credentials();
2423 if( !g.perm.Read ){ login_needed(); return; }
2424 mid = name_to_typed_rid(PD("checkin","0"),"ci");
2425 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", P("filename"));
2426 if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
2427 iLimit = atoi(PD("limit","20"));
2428 if( P("filevers") ) annFlags |= ANN_FILE_VERS;
2429 if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
2430 fossil_redirect_home();
2431 }
2432 compute_direct_ancestors(mid, 10000000);
2433 style_header("File Annotation");
2434 url_initialize(&url, "annotate");
2435 url_add_parameter(&url, "checkin", P("checkin"));
2436 url_add_parameter(&url, "filename", P("filename"));
2437 if( iLimit!=20 ){
2438 url_add_parameter(&url, "limit", sqlite3_mprintf("%d", iLimit));
2439 }
2440 if( showLog ) url_add_parameter(&url, "log", "1");
2441 if( showLn ) url_add_parameter(&url, "ln", "1");
2442 if( showLog ){
2443 style_submenu_element("Hide Log", "Hide Log",
2444 url_render(&url, "log", 0, 0, 0));
2445 }else{
2446 style_submenu_element("Show Log", "Show Log",
2447 url_render(&url, "log", "1", 0, 0));
2448 }
2449 if( showLn ){
2450 style_submenu_element("Hide Line Numbers", "Hide Line Numbers",
2451 url_render(&url, "log", 0, 0, 0));
2452 }else{
2453 style_submenu_element("Show Line Numbers", "Show Line Numbers",
2454 url_render(&url, "ln", "1", 0, 0));
2455 }
2456 if( iLimit>0 ){
2457 char *z1, *z2;
2458 style_submenu_element("All Ancestors", "All Ancestors",
2459 url_render(&url, "limit", "-1", 0, 0));
2460 z1 = sqlite3_mprintf("%d Ancestors", iLimit+20);
2461 z2 = sqlite3_mprintf("%d", iLimit+20);
2462 style_submenu_element(z1, z1, url_render(&url, "limit", z2, 0, 0));
2463 }
2464 if( iLimit!=20 ){
2465 style_submenu_element("20 Ancestors", "20 Ancestors",
2466 url_render(&url, "limit", "20", 0, 0));
2467 }
2468 annotate_file(&ann, fnid, mid, g.perm.Hyperlink, iLimit, annFlags);
2469 if( showLog ){
2470 int i;
2471 @ <h2>Versions analyzed:</h2>
2472 @ <ol>
2473 for(i=0; i<ann.nVers; i++){
2474 @ <li><tt>%s(ann.azVers[i])</tt></li>
2475 }
2476 @ </ol>
2477 @ <hr>
2478 }
2479 if( iLimit<0 ){
2480 @ <h2>Annotation:</h2>
2481 }else{
2482 @ <h2>Annotation of %d(iLimit) most recent ancestors:</h2>
2483 }
2484 if( showLn ){
2485 sqlite3_snprintf(sizeof(zLn), zLn, "%d", ann.nOrig+1);
2486 sqlite3_snprintf(sizeof(zFormat), zFormat, "%%%dd:", strlen(zLn));
2487 }else{
2488

Keyboard Shortcuts

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