Fossil SCM

Add the bid= query parameter to the /timeline page.

drh 2019-01-17 00:20 trunk
Commit 8cb1b231dc1cfe6c5ecb914fa1338331c8dad09bee47733171039ce547eef770
2 files changed +56 -4 +18 -8
+56 -4
--- src/bisect.c
+++ src/bisect.c
@@ -172,16 +172,40 @@
172172
173173
/*
174174
** Create a TEMP table named "bilog" that contains the complete history
175175
** of the current bisect.
176176
*/
177
-void bisect_create_bilog_table(int iCurrent){
178
- char *zLog = db_lget("bisect-log","");
177
+int bisect_create_bilog_table(int iCurrent, const char *zDesc){
178
+ char *zLog;
179179
Blob log, id;
180180
Stmt q;
181181
int cnt = 0;
182
- blob_init(&log, zLog, -1);
182
+
183
+ if( zDesc!=0 ){
184
+ blob_init(&log, 0, 0);
185
+ while( zDesc[0]=='y' || zDesc[0]=='n' ){
186
+ int i;
187
+ char c;
188
+ int rid;
189
+ if( blob_size(&log) ) blob_append(&log, " ", 1);
190
+ if( zDesc[0]=='n' ) blob_append(&log, "-", 1);
191
+ for(i=1; ((c = zDesc[i])>='0' && c<='9') || (c>='a' && c<='f'); i++){}
192
+ if( i==1 ) break;
193
+ rid = db_int(0,
194
+ "SELECT rid FROM blob"
195
+ " WHERE uuid LIKE '%.*q%%'"
196
+ " AND EXISTS(SELECT 1 FROM plink WHERE cid=rid)",
197
+ i-1, zDesc+1
198
+ );
199
+ if( rid==0 ) break;
200
+ blob_appendf(&log, "%d", rid);
201
+ zDesc += i;
202
+ }
203
+ }else{
204
+ zLog = db_lget("bisect-log","");
205
+ blob_init(&log, zLog, -1);
206
+ }
183207
db_multi_exec(
184208
"CREATE TEMP TABLE bilog("
185209
" seq INTEGER PRIMARY KEY," /* Sequence of events */
186210
" stat TEXT," /* Type of occurrence */
187211
" rid INTEGER UNIQUE" /* Check-in number */
@@ -202,20 +226,48 @@
202226
db_bind_text(&q, ":stat", "CURRENT");
203227
db_bind_int(&q, ":rid", iCurrent);
204228
db_step(&q);
205229
}
206230
db_finalize(&q);
231
+ return 1;
232
+}
233
+
234
+/* Return a permalink description of a bisect. Space is obtained from
235
+** fossil_malloc() and should be freed by the caller.
236
+**
237
+** A bisect description consists of characters 'y' and 'n' and lowercase
238
+** hex digits. Each term begins with 'y' or 'n' (success or failure) and
239
+** is followed by a hash prefix in lowercase hex.
240
+*/
241
+char *bisect_permalink(void){
242
+ char *zLog = db_lget("bisect-log","");
243
+ char *zResult;
244
+ Blob log;
245
+ Blob link = BLOB_INITIALIZER;
246
+ Blob id;
247
+ blob_init(&log, zLog, -1);
248
+ while( blob_token(&log, &id) ){
249
+ int rid = atoi(blob_str(&id));
250
+ char *zUuid = db_text(0,"SELECT lower(uuid) FROM blob WHERE rid=%d",
251
+ rid<0 ? -rid : rid);
252
+ blob_appendf(&link, "%c%.10s", rid<0 ? 'n' : 'y', zUuid);
253
+ }
254
+ zResult = mprintf("%s", blob_str(&link));
255
+ blob_reset(&link);
256
+ blob_reset(&log);
257
+ blob_reset(&id);
258
+ return zResult;
207259
}
208260
209261
/*
210262
** Show a chart of bisect "good" and "bad" versions. The chart can be
211263
** sorted either chronologically by bisect time, or by check-in time.
212264
*/
213265
static void bisect_chart(int sortByCkinTime){
214266
Stmt q;
215267
int iCurrent = db_lget_int("checkout",0);
216
- bisect_create_bilog_table(iCurrent);
268
+ bisect_create_bilog_table(iCurrent, 0);
217269
db_prepare(&q,
218270
"SELECT bilog.seq, bilog.stat,"
219271
" substr(blob.uuid,1,16), datetime(event.mtime),"
220272
" blob.rid==%d"
221273
" FROM bilog, blob, event"
222274
--- src/bisect.c
+++ src/bisect.c
@@ -172,16 +172,40 @@
172
173 /*
174 ** Create a TEMP table named "bilog" that contains the complete history
175 ** of the current bisect.
176 */
177 void bisect_create_bilog_table(int iCurrent){
178 char *zLog = db_lget("bisect-log","");
179 Blob log, id;
180 Stmt q;
181 int cnt = 0;
182 blob_init(&log, zLog, -1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183 db_multi_exec(
184 "CREATE TEMP TABLE bilog("
185 " seq INTEGER PRIMARY KEY," /* Sequence of events */
186 " stat TEXT," /* Type of occurrence */
187 " rid INTEGER UNIQUE" /* Check-in number */
@@ -202,20 +226,48 @@
202 db_bind_text(&q, ":stat", "CURRENT");
203 db_bind_int(&q, ":rid", iCurrent);
204 db_step(&q);
205 }
206 db_finalize(&q);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207 }
208
209 /*
210 ** Show a chart of bisect "good" and "bad" versions. The chart can be
211 ** sorted either chronologically by bisect time, or by check-in time.
212 */
213 static void bisect_chart(int sortByCkinTime){
214 Stmt q;
215 int iCurrent = db_lget_int("checkout",0);
216 bisect_create_bilog_table(iCurrent);
217 db_prepare(&q,
218 "SELECT bilog.seq, bilog.stat,"
219 " substr(blob.uuid,1,16), datetime(event.mtime),"
220 " blob.rid==%d"
221 " FROM bilog, blob, event"
222
--- src/bisect.c
+++ src/bisect.c
@@ -172,16 +172,40 @@
172
173 /*
174 ** Create a TEMP table named "bilog" that contains the complete history
175 ** of the current bisect.
176 */
177 int bisect_create_bilog_table(int iCurrent, const char *zDesc){
178 char *zLog;
179 Blob log, id;
180 Stmt q;
181 int cnt = 0;
182
183 if( zDesc!=0 ){
184 blob_init(&log, 0, 0);
185 while( zDesc[0]=='y' || zDesc[0]=='n' ){
186 int i;
187 char c;
188 int rid;
189 if( blob_size(&log) ) blob_append(&log, " ", 1);
190 if( zDesc[0]=='n' ) blob_append(&log, "-", 1);
191 for(i=1; ((c = zDesc[i])>='0' && c<='9') || (c>='a' && c<='f'); i++){}
192 if( i==1 ) break;
193 rid = db_int(0,
194 "SELECT rid FROM blob"
195 " WHERE uuid LIKE '%.*q%%'"
196 " AND EXISTS(SELECT 1 FROM plink WHERE cid=rid)",
197 i-1, zDesc+1
198 );
199 if( rid==0 ) break;
200 blob_appendf(&log, "%d", rid);
201 zDesc += i;
202 }
203 }else{
204 zLog = db_lget("bisect-log","");
205 blob_init(&log, zLog, -1);
206 }
207 db_multi_exec(
208 "CREATE TEMP TABLE bilog("
209 " seq INTEGER PRIMARY KEY," /* Sequence of events */
210 " stat TEXT," /* Type of occurrence */
211 " rid INTEGER UNIQUE" /* Check-in number */
@@ -202,20 +226,48 @@
226 db_bind_text(&q, ":stat", "CURRENT");
227 db_bind_int(&q, ":rid", iCurrent);
228 db_step(&q);
229 }
230 db_finalize(&q);
231 return 1;
232 }
233
234 /* Return a permalink description of a bisect. Space is obtained from
235 ** fossil_malloc() and should be freed by the caller.
236 **
237 ** A bisect description consists of characters 'y' and 'n' and lowercase
238 ** hex digits. Each term begins with 'y' or 'n' (success or failure) and
239 ** is followed by a hash prefix in lowercase hex.
240 */
241 char *bisect_permalink(void){
242 char *zLog = db_lget("bisect-log","");
243 char *zResult;
244 Blob log;
245 Blob link = BLOB_INITIALIZER;
246 Blob id;
247 blob_init(&log, zLog, -1);
248 while( blob_token(&log, &id) ){
249 int rid = atoi(blob_str(&id));
250 char *zUuid = db_text(0,"SELECT lower(uuid) FROM blob WHERE rid=%d",
251 rid<0 ? -rid : rid);
252 blob_appendf(&link, "%c%.10s", rid<0 ? 'n' : 'y', zUuid);
253 }
254 zResult = mprintf("%s", blob_str(&link));
255 blob_reset(&link);
256 blob_reset(&log);
257 blob_reset(&id);
258 return zResult;
259 }
260
261 /*
262 ** Show a chart of bisect "good" and "bad" versions. The chart can be
263 ** sorted either chronologically by bisect time, or by check-in time.
264 */
265 static void bisect_chart(int sortByCkinTime){
266 Stmt q;
267 int iCurrent = db_lget_int("checkout",0);
268 bisect_create_bilog_table(iCurrent, 0);
269 db_prepare(&q,
270 "SELECT bilog.seq, bilog.stat,"
271 " substr(blob.uuid,1,16), datetime(event.mtime),"
272 " blob.rid==%d"
273 " FROM bilog, blob, event"
274
+18 -8
--- src/timeline.c
+++ src/timeline.c
@@ -1498,11 +1498,12 @@
14981498
int nDays = 0; /* Numeric value for zNDays */
14991499
const char *zChng = P("chng"); /* List of GLOBs for files that changed */
15001500
int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
15011501
int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */
15021502
int forkOnly = PB("forks"); /* Show only forks and their children */
1503
- int bisectOnly = PB("bisect"); /* Show the check-ins of the bisect */
1503
+ int bisectLocal = PB("bisect"); /* Show the check-ins of the bisect */
1504
+ const char *zBisect = P("bid"); /* Bisect description */
15041505
int cpOnly = PB("cherrypicks"); /* Show all cherrypick checkins */
15051506
int tmFlags = 0; /* Timeline flags */
15061507
const char *zThisTag = 0; /* Suppress links to this tag */
15071508
const char *zThisUser = 0; /* Suppress links to this user */
15081509
HQuery url; /* URL for various branch links */
@@ -1558,11 +1559,11 @@
15581559
if( pd_rid ){
15591560
p_rid = d_rid = pd_rid;
15601561
}
15611562
login_check_credentials();
15621563
if( (!g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki && !g.perm.RdForum)
1563
- || (bisectOnly && !g.perm.Setup)
1564
+ || (bisectLocal && !g.perm.Setup)
15641565
){
15651566
login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
15661567
return;
15671568
}
15681569
cookie_read_parameter("y","y");
@@ -1686,21 +1687,30 @@
16861687
);
16871688
tmFlags |= TIMELINE_UNHIDE;
16881689
zType = "ci";
16891690
disableY = 1;
16901691
}
1691
- if( bisectOnly
1692
+ if( bisectLocal
16921693
&& fossil_strcmp(g.zIpAddr,"127.0.0.1")==0
16931694
&& db_open_local(0)
16941695
){
16951696
int iCurrent = db_lget_int("checkout",0);
1696
- bisect_create_bilog_table(iCurrent);
1697
+ char *zPerm = bisect_permalink();
1698
+ bisect_create_bilog_table(iCurrent, 0);
1699
+ tmFlags |= TIMELINE_UNHIDE | TIMELINE_BISECT;
1700
+ zType = "ci";
1701
+ disableY = 1;
1702
+ style_submenu_element("Permalink", "%R/timeline?bid=%z", zPerm);
1703
+ }else{
1704
+ bisectLocal = 0;
1705
+ }
1706
+ if( zBisect!=0 && bisect_create_bilog_table(0, zBisect) ){
16971707
tmFlags |= TIMELINE_UNHIDE | TIMELINE_BISECT;
16981708
zType = "ci";
16991709
disableY = 1;
17001710
}else{
1701
- bisectOnly = 0;
1711
+ zBisect = 0;
17021712
}
17031713
17041714
style_header("Timeline");
17051715
if( advancedMenu ){
17061716
style_submenu_element("Help", "%R/help?cmd=/timeline");
@@ -1908,11 +1918,11 @@
19081918
"INSERT OR IGNORE INTO cpnodes SELECT childid FROM cherrypick;"
19091919
"INSERT OR IGNORE INTO cpnodes SELECT parentid FROM cherrypick;"
19101920
);
19111921
blob_append_sql(&cond, " AND event.objid IN cpnodes ");
19121922
}
1913
- if( bisectOnly ){
1923
+ if( bisectLocal || zBisect!=0 ){
19141924
blob_append_sql(&cond, " AND event.objid IN (SELECT rid FROM bilog) ");
19151925
}
19161926
if( zYearMonth ){
19171927
blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
19181928
zYearMonth);
@@ -2155,12 +2165,12 @@
21552165
}
21562166
if( forkOnly ){
21572167
blob_appendf(&desc, " associated with forks");
21582168
tmFlags |= TIMELINE_DISJOINT;
21592169
}
2160
- if( bisectOnly ){
2161
- blob_appendf(&desc, " in the most recent bisect");
2170
+ if( bisectLocal || zBisect!=0 ){
2171
+ blob_appendf(&desc, " in a bisect");
21622172
tmFlags |= TIMELINE_DISJOINT;
21632173
}
21642174
if( cpOnly && showCherrypicks ){
21652175
blob_appendf(&desc, " that participate in a cherrypick merge");
21662176
tmFlags |= TIMELINE_CHPICK|TIMELINE_DISJOINT;
21672177
--- src/timeline.c
+++ src/timeline.c
@@ -1498,11 +1498,12 @@
1498 int nDays = 0; /* Numeric value for zNDays */
1499 const char *zChng = P("chng"); /* List of GLOBs for files that changed */
1500 int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
1501 int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */
1502 int forkOnly = PB("forks"); /* Show only forks and their children */
1503 int bisectOnly = PB("bisect"); /* Show the check-ins of the bisect */
 
1504 int cpOnly = PB("cherrypicks"); /* Show all cherrypick checkins */
1505 int tmFlags = 0; /* Timeline flags */
1506 const char *zThisTag = 0; /* Suppress links to this tag */
1507 const char *zThisUser = 0; /* Suppress links to this user */
1508 HQuery url; /* URL for various branch links */
@@ -1558,11 +1559,11 @@
1558 if( pd_rid ){
1559 p_rid = d_rid = pd_rid;
1560 }
1561 login_check_credentials();
1562 if( (!g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki && !g.perm.RdForum)
1563 || (bisectOnly && !g.perm.Setup)
1564 ){
1565 login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
1566 return;
1567 }
1568 cookie_read_parameter("y","y");
@@ -1686,21 +1687,30 @@
1686 );
1687 tmFlags |= TIMELINE_UNHIDE;
1688 zType = "ci";
1689 disableY = 1;
1690 }
1691 if( bisectOnly
1692 && fossil_strcmp(g.zIpAddr,"127.0.0.1")==0
1693 && db_open_local(0)
1694 ){
1695 int iCurrent = db_lget_int("checkout",0);
1696 bisect_create_bilog_table(iCurrent);
 
 
 
 
 
 
 
 
 
1697 tmFlags |= TIMELINE_UNHIDE | TIMELINE_BISECT;
1698 zType = "ci";
1699 disableY = 1;
1700 }else{
1701 bisectOnly = 0;
1702 }
1703
1704 style_header("Timeline");
1705 if( advancedMenu ){
1706 style_submenu_element("Help", "%R/help?cmd=/timeline");
@@ -1908,11 +1918,11 @@
1908 "INSERT OR IGNORE INTO cpnodes SELECT childid FROM cherrypick;"
1909 "INSERT OR IGNORE INTO cpnodes SELECT parentid FROM cherrypick;"
1910 );
1911 blob_append_sql(&cond, " AND event.objid IN cpnodes ");
1912 }
1913 if( bisectOnly ){
1914 blob_append_sql(&cond, " AND event.objid IN (SELECT rid FROM bilog) ");
1915 }
1916 if( zYearMonth ){
1917 blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
1918 zYearMonth);
@@ -2155,12 +2165,12 @@
2155 }
2156 if( forkOnly ){
2157 blob_appendf(&desc, " associated with forks");
2158 tmFlags |= TIMELINE_DISJOINT;
2159 }
2160 if( bisectOnly ){
2161 blob_appendf(&desc, " in the most recent bisect");
2162 tmFlags |= TIMELINE_DISJOINT;
2163 }
2164 if( cpOnly && showCherrypicks ){
2165 blob_appendf(&desc, " that participate in a cherrypick merge");
2166 tmFlags |= TIMELINE_CHPICK|TIMELINE_DISJOINT;
2167
--- src/timeline.c
+++ src/timeline.c
@@ -1498,11 +1498,12 @@
1498 int nDays = 0; /* Numeric value for zNDays */
1499 const char *zChng = P("chng"); /* List of GLOBs for files that changed */
1500 int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
1501 int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */
1502 int forkOnly = PB("forks"); /* Show only forks and their children */
1503 int bisectLocal = PB("bisect"); /* Show the check-ins of the bisect */
1504 const char *zBisect = P("bid"); /* Bisect description */
1505 int cpOnly = PB("cherrypicks"); /* Show all cherrypick checkins */
1506 int tmFlags = 0; /* Timeline flags */
1507 const char *zThisTag = 0; /* Suppress links to this tag */
1508 const char *zThisUser = 0; /* Suppress links to this user */
1509 HQuery url; /* URL for various branch links */
@@ -1558,11 +1559,11 @@
1559 if( pd_rid ){
1560 p_rid = d_rid = pd_rid;
1561 }
1562 login_check_credentials();
1563 if( (!g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki && !g.perm.RdForum)
1564 || (bisectLocal && !g.perm.Setup)
1565 ){
1566 login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
1567 return;
1568 }
1569 cookie_read_parameter("y","y");
@@ -1686,21 +1687,30 @@
1687 );
1688 tmFlags |= TIMELINE_UNHIDE;
1689 zType = "ci";
1690 disableY = 1;
1691 }
1692 if( bisectLocal
1693 && fossil_strcmp(g.zIpAddr,"127.0.0.1")==0
1694 && db_open_local(0)
1695 ){
1696 int iCurrent = db_lget_int("checkout",0);
1697 char *zPerm = bisect_permalink();
1698 bisect_create_bilog_table(iCurrent, 0);
1699 tmFlags |= TIMELINE_UNHIDE | TIMELINE_BISECT;
1700 zType = "ci";
1701 disableY = 1;
1702 style_submenu_element("Permalink", "%R/timeline?bid=%z", zPerm);
1703 }else{
1704 bisectLocal = 0;
1705 }
1706 if( zBisect!=0 && bisect_create_bilog_table(0, zBisect) ){
1707 tmFlags |= TIMELINE_UNHIDE | TIMELINE_BISECT;
1708 zType = "ci";
1709 disableY = 1;
1710 }else{
1711 zBisect = 0;
1712 }
1713
1714 style_header("Timeline");
1715 if( advancedMenu ){
1716 style_submenu_element("Help", "%R/help?cmd=/timeline");
@@ -1908,11 +1918,11 @@
1918 "INSERT OR IGNORE INTO cpnodes SELECT childid FROM cherrypick;"
1919 "INSERT OR IGNORE INTO cpnodes SELECT parentid FROM cherrypick;"
1920 );
1921 blob_append_sql(&cond, " AND event.objid IN cpnodes ");
1922 }
1923 if( bisectLocal || zBisect!=0 ){
1924 blob_append_sql(&cond, " AND event.objid IN (SELECT rid FROM bilog) ");
1925 }
1926 if( zYearMonth ){
1927 blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
1928 zYearMonth);
@@ -2155,12 +2165,12 @@
2165 }
2166 if( forkOnly ){
2167 blob_appendf(&desc, " associated with forks");
2168 tmFlags |= TIMELINE_DISJOINT;
2169 }
2170 if( bisectLocal || zBisect!=0 ){
2171 blob_appendf(&desc, " in a bisect");
2172 tmFlags |= TIMELINE_DISJOINT;
2173 }
2174 if( cpOnly && showCherrypicks ){
2175 blob_appendf(&desc, " that participate in a cherrypick merge");
2176 tmFlags |= TIMELINE_CHPICK|TIMELINE_DISJOINT;
2177

Keyboard Shortcuts

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