Fossil SCM
Experimental query parameters brbg and ubg for the timeline.
Commit
b6b419c32db4ca48b040562454f328568404e49f
Parent
fca30736219e8c7…
1 file changed
+44
+44
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -107,11 +107,43 @@ | ||
| 107 | 107 | #define TIMELINE_LEAFONLY 0x0002 /* Show "Leaf", but not "Merge", "Fork" etc */ |
| 108 | 108 | #define TIMELINE_BRIEF 0x0004 /* Combine adjacent elements of same object */ |
| 109 | 109 | #define TIMELINE_GRAPH 0x0008 /* Compute a graph */ |
| 110 | 110 | #define TIMELINE_DISJOINT 0x0010 /* Elements are not contiguous */ |
| 111 | 111 | #define TIMELINE_FCHANGES 0x0020 /* Detail file changes */ |
| 112 | +#define TIMELINE_BRCOLOR 0x0040 /* Background color by branch name */ | |
| 113 | +#define TIMELINE_UCOLOR 0x0080 /* Background color by user */ | |
| 112 | 114 | #endif |
| 115 | + | |
| 116 | +/* | |
| 117 | +** Hash a string and use the hash to determine a background color. | |
| 118 | +*/ | |
| 119 | +const char *hashColor(const char *z){ | |
| 120 | + int i; /* Loop counter */ | |
| 121 | + unsigned int h = 0; /* Hash on the branch name */ | |
| 122 | + int r, g, b; /* Values for red, green, and blue */ | |
| 123 | + int mx, mn, h1, h2; /* Components of HSV */ | |
| 124 | + static char zColor[10]; /* The resulting color */ | |
| 125 | + | |
| 126 | + for(i=0; z[i]; i++ ){ | |
| 127 | + h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[0]; | |
| 128 | + z++; | |
| 129 | + } | |
| 130 | + mx = 0xd1; | |
| 131 | + mn = 0xa8; | |
| 132 | + h1 = h%6; | |
| 133 | + h2 = ((h/6)%(mx - mn)) + mn; | |
| 134 | + switch( h1 ){ | |
| 135 | + case 0: r = mx; g = h2, b = mn; break; | |
| 136 | + case 1: r = h2; g = mx, b = mn; break; | |
| 137 | + case 2: r = mn; g = mx, b = h2; break; | |
| 138 | + case 3: r = mn; g = h2, b = mx; break; | |
| 139 | + case 4: r = h2; g = mn, b = mx; break; | |
| 140 | + default: r = mx; g = mn, b = h2; break; | |
| 141 | + } | |
| 142 | + sqlite3_snprintf(8, zColor, "#%02x%02x%02x", r,g,b); | |
| 143 | + return zColor; | |
| 144 | +} | |
| 113 | 145 | |
| 114 | 146 | /* |
| 115 | 147 | ** Output a timeline in the web format given a query. The query |
| 116 | 148 | ** should return these columns: |
| 117 | 149 | ** |
| @@ -208,10 +240,11 @@ | ||
| 208 | 240 | memcpy(zTime, &zDate[11], 5); |
| 209 | 241 | zTime[5] = 0; |
| 210 | 242 | @ <tr> |
| 211 | 243 | @ <td class="timelineTime">%s(zTime)</td> |
| 212 | 244 | @ <td class="timelineGraph"> |
| 245 | + if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hashColor(zUser) : 0; | |
| 213 | 246 | if( pGraph && zType[0]=='c' ){ |
| 214 | 247 | int nParent = 0; |
| 215 | 248 | int aParent[32]; |
| 216 | 249 | const char *zBr; |
| 217 | 250 | int gidx; |
| @@ -234,10 +267,17 @@ | ||
| 234 | 267 | db_bind_int(&qbranch, ":rid", rid); |
| 235 | 268 | if( db_step(&qbranch)==SQLITE_ROW ){ |
| 236 | 269 | zBr = db_column_text(&qbranch, 0); |
| 237 | 270 | }else{ |
| 238 | 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 | + } | |
| 239 | 279 | } |
| 240 | 280 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, isLeaf); |
| 241 | 281 | db_reset(&qbranch); |
| 242 | 282 | @ <div id="m%d(gidx)"></div> |
| 243 | 283 | } |
| @@ -768,10 +808,12 @@ | ||
| 768 | 808 | ** fc Show details of files changed |
| 769 | 809 | ** f=RID Show family (immediate parents and children) of RID |
| 770 | 810 | ** from=RID Path from... |
| 771 | 811 | ** to=RID ... to this |
| 772 | 812 | ** nomerge ... avoid merge links on the path |
| 813 | +** brbg Background color from branch name | |
| 814 | +** ubg Background color from user | |
| 773 | 815 | ** |
| 774 | 816 | ** p= and d= can appear individually or together. If either p= or d= |
| 775 | 817 | ** appear, then u=, y=, a=, and b= are ignored. |
| 776 | 818 | ** |
| 777 | 819 | ** If a= and b= appear, only a= is used. If neither appear, the most |
| @@ -826,10 +868,12 @@ | ||
| 826 | 868 | tmFlags = TIMELINE_GRAPH; |
| 827 | 869 | } |
| 828 | 870 | if( P("ng")!=0 || zSearch!=0 ){ |
| 829 | 871 | tmFlags &= ~TIMELINE_GRAPH; |
| 830 | 872 | } |
| 873 | + if( P("brbg")!=0 ) tmFlags |= TIMELINE_BRCOLOR; | |
| 874 | + if( P("ubg")!=0 ) tmFlags |= TIMELINE_UCOLOR; | |
| 831 | 875 | |
| 832 | 876 | style_header("Timeline"); |
| 833 | 877 | login_anonymous_available(); |
| 834 | 878 | timeline_temp_table(); |
| 835 | 879 | blob_zero(&sql); |
| 836 | 880 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -107,11 +107,43 @@ | |
| 107 | #define TIMELINE_LEAFONLY 0x0002 /* Show "Leaf", but not "Merge", "Fork" etc */ |
| 108 | #define TIMELINE_BRIEF 0x0004 /* Combine adjacent elements of same object */ |
| 109 | #define TIMELINE_GRAPH 0x0008 /* Compute a graph */ |
| 110 | #define TIMELINE_DISJOINT 0x0010 /* Elements are not contiguous */ |
| 111 | #define TIMELINE_FCHANGES 0x0020 /* Detail file changes */ |
| 112 | #endif |
| 113 | |
| 114 | /* |
| 115 | ** Output a timeline in the web format given a query. The query |
| 116 | ** should return these columns: |
| 117 | ** |
| @@ -208,10 +240,11 @@ | |
| 208 | memcpy(zTime, &zDate[11], 5); |
| 209 | zTime[5] = 0; |
| 210 | @ <tr> |
| 211 | @ <td class="timelineTime">%s(zTime)</td> |
| 212 | @ <td class="timelineGraph"> |
| 213 | if( pGraph && zType[0]=='c' ){ |
| 214 | int nParent = 0; |
| 215 | int aParent[32]; |
| 216 | const char *zBr; |
| 217 | int gidx; |
| @@ -234,10 +267,17 @@ | |
| 234 | db_bind_int(&qbranch, ":rid", rid); |
| 235 | if( db_step(&qbranch)==SQLITE_ROW ){ |
| 236 | zBr = db_column_text(&qbranch, 0); |
| 237 | }else{ |
| 238 | zBr = "trunk"; |
| 239 | } |
| 240 | gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr, isLeaf); |
| 241 | db_reset(&qbranch); |
| 242 | @ <div id="m%d(gidx)"></div> |
| 243 | } |
| @@ -768,10 +808,12 @@ | |
| 768 | ** fc Show details of files changed |
| 769 | ** f=RID Show family (immediate parents and children) of RID |
| 770 | ** from=RID Path from... |
| 771 | ** to=RID ... to this |
| 772 | ** nomerge ... avoid merge links on the path |
| 773 | ** |
| 774 | ** p= and d= can appear individually or together. If either p= or d= |
| 775 | ** appear, then u=, y=, a=, and b= are ignored. |
| 776 | ** |
| 777 | ** If a= and b= appear, only a= is used. If neither appear, the most |
| @@ -826,10 +868,12 @@ | |
| 826 | tmFlags = TIMELINE_GRAPH; |
| 827 | } |
| 828 | if( P("ng")!=0 || zSearch!=0 ){ |
| 829 | tmFlags &= ~TIMELINE_GRAPH; |
| 830 | } |
| 831 | |
| 832 | style_header("Timeline"); |
| 833 | login_anonymous_available(); |
| 834 | timeline_temp_table(); |
| 835 | blob_zero(&sql); |
| 836 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -107,11 +107,43 @@ | |
| 107 | #define TIMELINE_LEAFONLY 0x0002 /* Show "Leaf", but not "Merge", "Fork" etc */ |
| 108 | #define TIMELINE_BRIEF 0x0004 /* Combine adjacent elements of same object */ |
| 109 | #define TIMELINE_GRAPH 0x0008 /* Compute a graph */ |
| 110 | #define TIMELINE_DISJOINT 0x0010 /* Elements are not contiguous */ |
| 111 | #define TIMELINE_FCHANGES 0x0020 /* Detail file changes */ |
| 112 | #define TIMELINE_BRCOLOR 0x0040 /* Background color by branch name */ |
| 113 | #define TIMELINE_UCOLOR 0x0080 /* Background color by user */ |
| 114 | #endif |
| 115 | |
| 116 | /* |
| 117 | ** Hash a string and use the hash to determine a background color. |
| 118 | */ |
| 119 | const char *hashColor(const char *z){ |
| 120 | int i; /* Loop counter */ |
| 121 | unsigned int h = 0; /* Hash on the branch name */ |
| 122 | int r, g, b; /* Values for red, green, and blue */ |
| 123 | int mx, mn, h1, h2; /* Components of HSV */ |
| 124 | static char zColor[10]; /* The resulting color */ |
| 125 | |
| 126 | for(i=0; z[i]; i++ ){ |
| 127 | h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[0]; |
| 128 | z++; |
| 129 | } |
| 130 | mx = 0xd1; |
| 131 | mn = 0xa8; |
| 132 | h1 = h%6; |
| 133 | h2 = ((h/6)%(mx - mn)) + mn; |
| 134 | switch( h1 ){ |
| 135 | case 0: r = mx; g = h2, b = mn; break; |
| 136 | case 1: r = h2; g = mx, b = mn; break; |
| 137 | case 2: r = mn; g = mx, b = h2; break; |
| 138 | case 3: r = mn; g = h2, b = mx; break; |
| 139 | case 4: r = h2; g = mn, b = mx; break; |
| 140 | default: r = mx; g = mn, b = h2; break; |
| 141 | } |
| 142 | sqlite3_snprintf(8, zColor, "#%02x%02x%02x", r,g,b); |
| 143 | return zColor; |
| 144 | } |
| 145 | |
| 146 | /* |
| 147 | ** Output a timeline in the web format given a query. The query |
| 148 | ** should return these columns: |
| 149 | ** |
| @@ -208,10 +240,11 @@ | |
| 240 | memcpy(zTime, &zDate[11], 5); |
| 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; |
| @@ -234,10 +267,17 @@ | |
| 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 | } |
| @@ -768,10 +808,12 @@ | |
| 808 | ** fc Show details of files changed |
| 809 | ** f=RID Show family (immediate parents and children) of RID |
| 810 | ** from=RID Path from... |
| 811 | ** to=RID ... to this |
| 812 | ** nomerge ... avoid merge links on the path |
| 813 | ** brbg Background color from branch name |
| 814 | ** ubg Background color from user |
| 815 | ** |
| 816 | ** p= and d= can appear individually or together. If either p= or d= |
| 817 | ** appear, then u=, y=, a=, and b= are ignored. |
| 818 | ** |
| 819 | ** If a= and b= appear, only a= is used. If neither appear, the most |
| @@ -826,10 +868,12 @@ | |
| 868 | tmFlags = TIMELINE_GRAPH; |
| 869 | } |
| 870 | if( P("ng")!=0 || zSearch!=0 ){ |
| 871 | tmFlags &= ~TIMELINE_GRAPH; |
| 872 | } |
| 873 | if( P("brbg")!=0 ) tmFlags |= TIMELINE_BRCOLOR; |
| 874 | if( P("ubg")!=0 ) tmFlags |= TIMELINE_UCOLOR; |
| 875 | |
| 876 | style_header("Timeline"); |
| 877 | login_anonymous_available(); |
| 878 | timeline_temp_table(); |
| 879 | blob_zero(&sql); |
| 880 |