Fossil SCM

Correct operation of filevers query parameter to annotate pages

andygoth 2017-09-23 21:18 UTC andygoth-annotation-enhancements
Commit 4b721600e7b8315e18cd6762d0da7d2fee1952027829e8ad673f18f426308933
1 file changed +14 -9
+14 -9
--- src/diff.c
+++ src/diff.c
@@ -43,13 +43,10 @@
4343
#define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
4444
#define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
4545
#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
4646
#define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better, but slower side-by-side */
4747
48
-/* Annotation flags (any DIFF flag can be used as Annotation flag as well) */
49
-#define ANN_FILE_VERS (((u64)0x40)<<32) /* File vers not commit vers */
50
-
5148
/*
5249
** These error messages are shared in multiple locations. They are defined
5350
** here for consistency.
5451
*/
5552
#define DIFF_CANNOT_COMPUTE_BINARY \
@@ -2347,11 +2344,11 @@
23472344
**
23482345
** Query parameters:
23492346
**
23502347
** checkin=ID The manifest ID at which to start the annotation
23512348
** filename=FILENAME The filename.
2352
-** filevers Show file versions rather than check-in versions
2349
+** filevers=BOOLEAN Show file versions rather than check-in versions
23532350
** limit=N Limit the search depth to N ancestors
23542351
** log=BOOLEAN Show a log of versions analyzed
23552352
** w Ignore whitespace
23562353
**
23572354
*/
@@ -2358,10 +2355,11 @@
23582355
void annotation_page(void){
23592356
int i;
23602357
int iLimit; /* Depth limit */
23612358
u64 annFlags = DIFF_STRIP_EOLCR;
23622359
int showLog = 0; /* True to display the log */
2360
+ int fileVers; /* Show file version instead of check-in versions */
23632361
int ignoreWs = 0; /* Ignore whitespace */
23642362
const char *zFilename; /* Name of file to annotate */
23652363
const char *zRevision; /* Name of check-in from which to start annotation */
23662364
const char *zCI; /* The check-in containing zFilename */
23672365
Annotator ann;
@@ -2377,11 +2375,11 @@
23772375
if( exclude_spiders() ) return;
23782376
load_control();
23792377
zFilename = P("filename");
23802378
zRevision = PD("checkin",0);
23812379
iLimit = atoi(PD("limit","20"));
2382
- if( P("filevers") ) annFlags |= ANN_FILE_VERS;
2380
+ fileVers = PB("filevers");
23832381
ignoreWs = P("w")!=0;
23842382
if( ignoreWs ) annFlags |= DIFF_IGNORE_ALLWS;
23852383
23862384
/* compute the annotation */
23872385
annotate_file(&ann, zFilename, zRevision, iLimit, annFlags);
@@ -2411,10 +2409,15 @@
24112409
if( showLog ){
24122410
style_submenu_element("Hide Log", "%s", url_render(&url, "log", "0", 0, 0));
24132411
}else{
24142412
style_submenu_element("Show Log", "%s", url_render(&url, "log", "1", 0, 0));
24152413
}
2414
+ if( fileVers ){
2415
+ style_submenu_element("Link to Check-ins", "%s", url_render(&url, "filevers", "0", 0, 0));
2416
+ }else{
2417
+ style_submenu_element("Link to Files", "%s", url_render(&url, "filevers", "1", 0, 0));
2418
+ }
24162419
if( ann.bLimit ){
24172420
char *z1, *z2;
24182421
style_submenu_element("All Ancestors", "%s",
24192422
url_render(&url, "limit", "-1", 0, 0));
24202423
z1 = sqlite3_mprintf("%d Ancestors", iLimit+20);
@@ -2484,27 +2487,29 @@
24842487
if( iLimit>ann.nVers && iVers<0 ) iVers = ann.nVers-1;
24852488
24862489
if( bBlame ){
24872490
if( iVers>=0 ){
24882491
struct AnnVers *p = ann.aVers+iVers;
2489
- char *zLink = xhref("target='infowindow'", "%R/info/%!S", p->zMUuid);
2492
+ const char *zUuid = fileVers ? p->zFUuid : p->zMUuid;
2493
+ char *zLink = xhref("target='infowindow'", "%R/info/%!S", zUuid);
24902494
sqlite3_snprintf(sizeof(zPrefix), zPrefix,
24912495
"<span style='background-color:%s'>"
24922496
"%s%.10s</a> %s</span> %13.13s:",
2493
- p->zBgColor, zLink, p->zMUuid, p->zDate, p->zUser);
2497
+ p->zBgColor, zLink, zUuid, p->zDate, p->zUser);
24942498
fossil_free(zLink);
24952499
}else{
24962500
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%36s", "");
24972501
}
24982502
}else{
24992503
if( iVers>=0 ){
25002504
struct AnnVers *p = ann.aVers+iVers;
2501
- char *zLink = xhref("target='infowindow'", "%R/info/%!S", p->zMUuid);
2505
+ const char *zUuid = fileVers ? p->zFUuid : p->zMUuid;
2506
+ char *zLink = xhref("target='infowindow'", "%R/info/%!S", zUuid);
25022507
sqlite3_snprintf(sizeof(zPrefix), zPrefix,
25032508
"<span style='background-color:%s'>"
25042509
"%s%.10s</a> %s</span> %4d:",
2505
- p->zBgColor, zLink, p->zMUuid, p->zDate, i+1);
2510
+ p->zBgColor, zLink, zUuid, p->zDate, i+1);
25062511
fossil_free(zLink);
25072512
}else{
25082513
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%22s%4d:", "", i+1);
25092514
}
25102515
}
25112516
--- src/diff.c
+++ src/diff.c
@@ -43,13 +43,10 @@
43 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
44 #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
45 #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
46 #define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better, but slower side-by-side */
47
48 /* Annotation flags (any DIFF flag can be used as Annotation flag as well) */
49 #define ANN_FILE_VERS (((u64)0x40)<<32) /* File vers not commit vers */
50
51 /*
52 ** These error messages are shared in multiple locations. They are defined
53 ** here for consistency.
54 */
55 #define DIFF_CANNOT_COMPUTE_BINARY \
@@ -2347,11 +2344,11 @@
2347 **
2348 ** Query parameters:
2349 **
2350 ** checkin=ID The manifest ID at which to start the annotation
2351 ** filename=FILENAME The filename.
2352 ** filevers Show file versions rather than check-in versions
2353 ** limit=N Limit the search depth to N ancestors
2354 ** log=BOOLEAN Show a log of versions analyzed
2355 ** w Ignore whitespace
2356 **
2357 */
@@ -2358,10 +2355,11 @@
2358 void annotation_page(void){
2359 int i;
2360 int iLimit; /* Depth limit */
2361 u64 annFlags = DIFF_STRIP_EOLCR;
2362 int showLog = 0; /* True to display the log */
 
2363 int ignoreWs = 0; /* Ignore whitespace */
2364 const char *zFilename; /* Name of file to annotate */
2365 const char *zRevision; /* Name of check-in from which to start annotation */
2366 const char *zCI; /* The check-in containing zFilename */
2367 Annotator ann;
@@ -2377,11 +2375,11 @@
2377 if( exclude_spiders() ) return;
2378 load_control();
2379 zFilename = P("filename");
2380 zRevision = PD("checkin",0);
2381 iLimit = atoi(PD("limit","20"));
2382 if( P("filevers") ) annFlags |= ANN_FILE_VERS;
2383 ignoreWs = P("w")!=0;
2384 if( ignoreWs ) annFlags |= DIFF_IGNORE_ALLWS;
2385
2386 /* compute the annotation */
2387 annotate_file(&ann, zFilename, zRevision, iLimit, annFlags);
@@ -2411,10 +2409,15 @@
2411 if( showLog ){
2412 style_submenu_element("Hide Log", "%s", url_render(&url, "log", "0", 0, 0));
2413 }else{
2414 style_submenu_element("Show Log", "%s", url_render(&url, "log", "1", 0, 0));
2415 }
 
 
 
 
 
2416 if( ann.bLimit ){
2417 char *z1, *z2;
2418 style_submenu_element("All Ancestors", "%s",
2419 url_render(&url, "limit", "-1", 0, 0));
2420 z1 = sqlite3_mprintf("%d Ancestors", iLimit+20);
@@ -2484,27 +2487,29 @@
2484 if( iLimit>ann.nVers && iVers<0 ) iVers = ann.nVers-1;
2485
2486 if( bBlame ){
2487 if( iVers>=0 ){
2488 struct AnnVers *p = ann.aVers+iVers;
2489 char *zLink = xhref("target='infowindow'", "%R/info/%!S", p->zMUuid);
 
2490 sqlite3_snprintf(sizeof(zPrefix), zPrefix,
2491 "<span style='background-color:%s'>"
2492 "%s%.10s</a> %s</span> %13.13s:",
2493 p->zBgColor, zLink, p->zMUuid, p->zDate, p->zUser);
2494 fossil_free(zLink);
2495 }else{
2496 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%36s", "");
2497 }
2498 }else{
2499 if( iVers>=0 ){
2500 struct AnnVers *p = ann.aVers+iVers;
2501 char *zLink = xhref("target='infowindow'", "%R/info/%!S", p->zMUuid);
 
2502 sqlite3_snprintf(sizeof(zPrefix), zPrefix,
2503 "<span style='background-color:%s'>"
2504 "%s%.10s</a> %s</span> %4d:",
2505 p->zBgColor, zLink, p->zMUuid, p->zDate, i+1);
2506 fossil_free(zLink);
2507 }else{
2508 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%22s%4d:", "", i+1);
2509 }
2510 }
2511
--- src/diff.c
+++ src/diff.c
@@ -43,13 +43,10 @@
43 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
44 #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
45 #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
46 #define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better, but slower side-by-side */
47
 
 
 
48 /*
49 ** These error messages are shared in multiple locations. They are defined
50 ** here for consistency.
51 */
52 #define DIFF_CANNOT_COMPUTE_BINARY \
@@ -2347,11 +2344,11 @@
2344 **
2345 ** Query parameters:
2346 **
2347 ** checkin=ID The manifest ID at which to start the annotation
2348 ** filename=FILENAME The filename.
2349 ** filevers=BOOLEAN Show file versions rather than check-in versions
2350 ** limit=N Limit the search depth to N ancestors
2351 ** log=BOOLEAN Show a log of versions analyzed
2352 ** w Ignore whitespace
2353 **
2354 */
@@ -2358,10 +2355,11 @@
2355 void annotation_page(void){
2356 int i;
2357 int iLimit; /* Depth limit */
2358 u64 annFlags = DIFF_STRIP_EOLCR;
2359 int showLog = 0; /* True to display the log */
2360 int fileVers; /* Show file version instead of check-in versions */
2361 int ignoreWs = 0; /* Ignore whitespace */
2362 const char *zFilename; /* Name of file to annotate */
2363 const char *zRevision; /* Name of check-in from which to start annotation */
2364 const char *zCI; /* The check-in containing zFilename */
2365 Annotator ann;
@@ -2377,11 +2375,11 @@
2375 if( exclude_spiders() ) return;
2376 load_control();
2377 zFilename = P("filename");
2378 zRevision = PD("checkin",0);
2379 iLimit = atoi(PD("limit","20"));
2380 fileVers = PB("filevers");
2381 ignoreWs = P("w")!=0;
2382 if( ignoreWs ) annFlags |= DIFF_IGNORE_ALLWS;
2383
2384 /* compute the annotation */
2385 annotate_file(&ann, zFilename, zRevision, iLimit, annFlags);
@@ -2411,10 +2409,15 @@
2409 if( showLog ){
2410 style_submenu_element("Hide Log", "%s", url_render(&url, "log", "0", 0, 0));
2411 }else{
2412 style_submenu_element("Show Log", "%s", url_render(&url, "log", "1", 0, 0));
2413 }
2414 if( fileVers ){
2415 style_submenu_element("Link to Check-ins", "%s", url_render(&url, "filevers", "0", 0, 0));
2416 }else{
2417 style_submenu_element("Link to Files", "%s", url_render(&url, "filevers", "1", 0, 0));
2418 }
2419 if( ann.bLimit ){
2420 char *z1, *z2;
2421 style_submenu_element("All Ancestors", "%s",
2422 url_render(&url, "limit", "-1", 0, 0));
2423 z1 = sqlite3_mprintf("%d Ancestors", iLimit+20);
@@ -2484,27 +2487,29 @@
2487 if( iLimit>ann.nVers && iVers<0 ) iVers = ann.nVers-1;
2488
2489 if( bBlame ){
2490 if( iVers>=0 ){
2491 struct AnnVers *p = ann.aVers+iVers;
2492 const char *zUuid = fileVers ? p->zFUuid : p->zMUuid;
2493 char *zLink = xhref("target='infowindow'", "%R/info/%!S", zUuid);
2494 sqlite3_snprintf(sizeof(zPrefix), zPrefix,
2495 "<span style='background-color:%s'>"
2496 "%s%.10s</a> %s</span> %13.13s:",
2497 p->zBgColor, zLink, zUuid, p->zDate, p->zUser);
2498 fossil_free(zLink);
2499 }else{
2500 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%36s", "");
2501 }
2502 }else{
2503 if( iVers>=0 ){
2504 struct AnnVers *p = ann.aVers+iVers;
2505 const char *zUuid = fileVers ? p->zFUuid : p->zMUuid;
2506 char *zLink = xhref("target='infowindow'", "%R/info/%!S", zUuid);
2507 sqlite3_snprintf(sizeof(zPrefix), zPrefix,
2508 "<span style='background-color:%s'>"
2509 "%s%.10s</a> %s</span> %4d:",
2510 p->zBgColor, zLink, zUuid, p->zDate, i+1);
2511 fossil_free(zLink);
2512 }else{
2513 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%22s%4d:", "", i+1);
2514 }
2515 }
2516

Keyboard Shortcuts

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