Fossil SCM

Add a -showfiles flag to timeline. fossil ... -showfiles will now print a list of files after the checkin comment, like the "Show Files" button in the Web GUI. The format of the printed lines is the same as update.

venkat 2011-08-19 23:27 venks-emacs
Commit b14ab41ff8514cae8a95fd9eebde2e30a209b3fb
--- src/descendants.c
+++ src/descendants.c
@@ -287,11 +287,11 @@
287287
"%s"
288288
" AND event.objid IN (SELECT rid FROM leaves)"
289289
" ORDER BY event.mtime DESC",
290290
timeline_query_for_tty()
291291
);
292
- print_timeline(&q, 20);
292
+ print_timeline(&q, 20, 0);
293293
db_finalize(&q);
294294
}
295295
296296
/*
297297
** COMMAND: leaves
@@ -322,11 +322,11 @@
322322
}else if( !showAll ){
323323
blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
324324
}
325325
db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
326326
blob_reset(&sql);
327
- print_timeline(&q, 2000);
327
+ print_timeline(&q, 2000, 0);
328328
db_finalize(&q);
329329
}
330330
331331
/*
332332
** WEBPAGE: leaves
333333
--- src/descendants.c
+++ src/descendants.c
@@ -287,11 +287,11 @@
287 "%s"
288 " AND event.objid IN (SELECT rid FROM leaves)"
289 " ORDER BY event.mtime DESC",
290 timeline_query_for_tty()
291 );
292 print_timeline(&q, 20);
293 db_finalize(&q);
294 }
295
296 /*
297 ** COMMAND: leaves
@@ -322,11 +322,11 @@
322 }else if( !showAll ){
323 blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
324 }
325 db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
326 blob_reset(&sql);
327 print_timeline(&q, 2000);
328 db_finalize(&q);
329 }
330
331 /*
332 ** WEBPAGE: leaves
333
--- src/descendants.c
+++ src/descendants.c
@@ -287,11 +287,11 @@
287 "%s"
288 " AND event.objid IN (SELECT rid FROM leaves)"
289 " ORDER BY event.mtime DESC",
290 timeline_query_for_tty()
291 );
292 print_timeline(&q, 20, 0);
293 db_finalize(&q);
294 }
295
296 /*
297 ** COMMAND: leaves
@@ -322,11 +322,11 @@
322 }else if( !showAll ){
323 blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
324 }
325 db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
326 blob_reset(&sql);
327 print_timeline(&q, 2000, 0);
328 db_finalize(&q);
329 }
330
331 /*
332 ** WEBPAGE: leaves
333
+1 -1
--- src/search.c
+++ src/search.c
@@ -203,8 +203,8 @@
203203
db_prepare(&q,
204204
"SELECT rid, uuid, date, comment, 0, 0 FROM srch"
205205
" WHERE x>%d ORDER BY x DESC, date DESC",
206206
iBest/3
207207
);
208
- print_timeline(&q, 1000);
208
+ print_timeline(&q, 1000, 0);
209209
db_finalize(&q);
210210
}
211211
--- src/search.c
+++ src/search.c
@@ -203,8 +203,8 @@
203 db_prepare(&q,
204 "SELECT rid, uuid, date, comment, 0, 0 FROM srch"
205 " WHERE x>%d ORDER BY x DESC, date DESC",
206 iBest/3
207 );
208 print_timeline(&q, 1000);
209 db_finalize(&q);
210 }
211
--- src/search.c
+++ src/search.c
@@ -203,8 +203,8 @@
203 db_prepare(&q,
204 "SELECT rid, uuid, date, comment, 0, 0 FROM srch"
205 " WHERE x>%d ORDER BY x DESC, date DESC",
206 iBest/3
207 );
208 print_timeline(&q, 1000, 0);
209 db_finalize(&q);
210 }
211
+1 -1
--- src/tag.c
+++ src/tag.c
@@ -458,11 +458,11 @@
458458
" WHERE tagtype>0 AND tagid=%d"
459459
")"
460460
" ORDER BY event.mtime DESC",
461461
timeline_query_for_tty(), zType, tagid
462462
);
463
- print_timeline(&q, 2000);
463
+ print_timeline(&q, 2000, 0);
464464
db_finalize(&q);
465465
}
466466
}
467467
}else
468468
469469
--- src/tag.c
+++ src/tag.c
@@ -458,11 +458,11 @@
458 " WHERE tagtype>0 AND tagid=%d"
459 ")"
460 " ORDER BY event.mtime DESC",
461 timeline_query_for_tty(), zType, tagid
462 );
463 print_timeline(&q, 2000);
464 db_finalize(&q);
465 }
466 }
467 }else
468
469
--- src/tag.c
+++ src/tag.c
@@ -458,11 +458,11 @@
458 " WHERE tagtype>0 AND tagid=%d"
459 ")"
460 " ORDER BY event.mtime DESC",
461 timeline_query_for_tty(), zType, tagid
462 );
463 print_timeline(&q, 2000, 0);
464 db_finalize(&q);
465 }
466 }
467 }else
468
469
+47 -5
--- src/timeline.c
+++ src/timeline.c
@@ -1239,15 +1239,17 @@
12391239
** 2. Date/Time
12401240
** 3. Comment string and user
12411241
** 4. Number of non-merge children
12421242
** 5. Number of parents
12431243
*/
1244
-void print_timeline(Stmt *q, int mxLine){
1244
+void print_timeline(Stmt *q, int mxLine, int showfiles){
12451245
int nLine = 0;
12461246
char zPrevDate[20];
12471247
const char *zCurrentUuid=0;
12481248
zPrevDate[0] = 0;
1249
+ int fchngQueryInit = 0; /* True if fchngQuery is initialized */
1250
+ Stmt fchngQuery; /* Query for file changes on check-ins */
12491251
12501252
if( g.localOpen ){
12511253
int rid = db_lget_int("checkout", 0);
12521254
zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
12531255
}
@@ -1292,11 +1294,45 @@
12921294
n += strlen(zPrefix);
12931295
}
12941296
zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
12951297
nLine += comment_print(zFree, 9, 79);
12961298
sqlite3_free(zFree);
1299
+
1300
+ if(showfiles){
1301
+ int inUl = 0;
1302
+ if( !fchngQueryInit ){
1303
+ db_prepare(&fchngQuery,
1304
+ "SELECT (pid==0) AS isnew,"
1305
+ " (fid==0) AS isdel,"
1306
+ " (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
1307
+ " (SELECT uuid FROM blob WHERE rid=fid),"
1308
+ " (SELECT uuid FROM blob WHERE rid=pid)"
1309
+ " FROM mlink"
1310
+ " WHERE mid=:mid AND pid!=fid"
1311
+ " ORDER BY 3 /*sort*/"
1312
+ );
1313
+ fchngQueryInit = 1;
1314
+ }
1315
+ db_bind_int(&fchngQuery, ":mid", rid);
1316
+ while( db_step(&fchngQuery)==SQLITE_ROW ){
1317
+ const char *zFilename = db_column_text(&fchngQuery, 2);
1318
+ int isNew = db_column_int(&fchngQuery, 0);
1319
+ int isDel = db_column_int(&fchngQuery, 1);
1320
+ const char *zOld = db_column_text(&fchngQuery, 4);
1321
+ const char *zNew = db_column_text(&fchngQuery, 3);
1322
+ if( isNew ){
1323
+ fossil_print(" ADDED %s\n",zFilename);
1324
+ }else if( isDel ){
1325
+ fossil_print(" DELETED %s\n",zFilename);
1326
+ }else{
1327
+ fossil_print(" EDITED %s\n", zFilename);
1328
+ }
1329
+ }
1330
+ db_reset(&fchngQuery);
1331
+ }
12971332
}
1333
+ if( fchngQueryInit ) db_finalize(&fchngQuery);
12981334
}
12991335
13001336
/*
13011337
** Return a pointer to a static string that forms the basis for
13021338
** a timeline query for display on a TTY.
@@ -1337,11 +1373,11 @@
13371373
}
13381374
13391375
/*
13401376
** COMMAND: timeline
13411377
**
1342
-** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n N? ?-t TYPE?
1378
+** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n N? ?-t TYPE? ?-showfiles?
13431379
**
13441380
** Print a summary of activity going backwards in date and time
13451381
** specified or from the current date and time if no arguments
13461382
** are given. Show as many as N (default 20) check-ins. The
13471383
** WHEN argument can be any unique abbreviation of one of these
@@ -1361,10 +1397,14 @@
13611397
** page. For example:
13621398
**
13631399
** w = wiki commits only
13641400
** ci = file commits only
13651401
** t = tickets only
1402
+**
1403
+** The optional showfiles argument if specified prints the list of
1404
+** files changed in a checkin after the checkin comment
1405
+**
13661406
*/
13671407
void timeline_cmd(void){
13681408
Stmt q;
13691409
int n, k;
13701410
const char *zCount;
@@ -1373,10 +1413,12 @@
13731413
char *zDate;
13741414
Blob sql;
13751415
int objid = 0;
13761416
Blob uuid;
13771417
int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
1418
+ int showfilesFlag = 0 ;
1419
+ showfilesFlag = find_option("showfiles","f", 0)!=0;
13781420
db_find_and_open_repository(0, 0);
13791421
zCount = find_option("count","n",1);
13801422
zType = find_option("type","t",1);
13811423
if( zCount ){
13821424
n = atoi(zCount);
@@ -1399,13 +1441,13 @@
13991441
mode = 4;
14001442
}else if(!zType && !zCount){
14011443
usage("?WHEN? ?BASELINE|DATETIME? ?-n|--count N? ?-t TYPE?");
14021444
}
14031445
if( '-' != *g.argv[3] ){
1404
- zOrigin = g.argv[3];
1446
+ zOrigin = g.argv[3];
14051447
}else{
1406
- zOrigin = "now";
1448
+ zOrigin = "now";
14071449
}
14081450
}else if( g.argc==3 ){
14091451
zOrigin = g.argv[2];
14101452
}else{
14111453
zOrigin = "now";
@@ -1459,11 +1501,11 @@
14591501
}
14601502
14611503
blob_appendf(&sql, " ORDER BY event.mtime DESC");
14621504
db_prepare(&q, blob_str(&sql));
14631505
blob_reset(&sql);
1464
- print_timeline(&q, n);
1506
+ print_timeline(&q, n, showfilesFlag);
14651507
db_finalize(&q);
14661508
}
14671509
14681510
/*
14691511
** This is a version of the "localtime()" function from the standard
14701512
--- src/timeline.c
+++ src/timeline.c
@@ -1239,15 +1239,17 @@
1239 ** 2. Date/Time
1240 ** 3. Comment string and user
1241 ** 4. Number of non-merge children
1242 ** 5. Number of parents
1243 */
1244 void print_timeline(Stmt *q, int mxLine){
1245 int nLine = 0;
1246 char zPrevDate[20];
1247 const char *zCurrentUuid=0;
1248 zPrevDate[0] = 0;
 
 
1249
1250 if( g.localOpen ){
1251 int rid = db_lget_int("checkout", 0);
1252 zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1253 }
@@ -1292,11 +1294,45 @@
1292 n += strlen(zPrefix);
1293 }
1294 zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1295 nLine += comment_print(zFree, 9, 79);
1296 sqlite3_free(zFree);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1297 }
 
1298 }
1299
1300 /*
1301 ** Return a pointer to a static string that forms the basis for
1302 ** a timeline query for display on a TTY.
@@ -1337,11 +1373,11 @@
1337 }
1338
1339 /*
1340 ** COMMAND: timeline
1341 **
1342 ** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n N? ?-t TYPE?
1343 **
1344 ** Print a summary of activity going backwards in date and time
1345 ** specified or from the current date and time if no arguments
1346 ** are given. Show as many as N (default 20) check-ins. The
1347 ** WHEN argument can be any unique abbreviation of one of these
@@ -1361,10 +1397,14 @@
1361 ** page. For example:
1362 **
1363 ** w = wiki commits only
1364 ** ci = file commits only
1365 ** t = tickets only
 
 
 
 
1366 */
1367 void timeline_cmd(void){
1368 Stmt q;
1369 int n, k;
1370 const char *zCount;
@@ -1373,10 +1413,12 @@
1373 char *zDate;
1374 Blob sql;
1375 int objid = 0;
1376 Blob uuid;
1377 int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
 
 
1378 db_find_and_open_repository(0, 0);
1379 zCount = find_option("count","n",1);
1380 zType = find_option("type","t",1);
1381 if( zCount ){
1382 n = atoi(zCount);
@@ -1399,13 +1441,13 @@
1399 mode = 4;
1400 }else if(!zType && !zCount){
1401 usage("?WHEN? ?BASELINE|DATETIME? ?-n|--count N? ?-t TYPE?");
1402 }
1403 if( '-' != *g.argv[3] ){
1404 zOrigin = g.argv[3];
1405 }else{
1406 zOrigin = "now";
1407 }
1408 }else if( g.argc==3 ){
1409 zOrigin = g.argv[2];
1410 }else{
1411 zOrigin = "now";
@@ -1459,11 +1501,11 @@
1459 }
1460
1461 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1462 db_prepare(&q, blob_str(&sql));
1463 blob_reset(&sql);
1464 print_timeline(&q, n);
1465 db_finalize(&q);
1466 }
1467
1468 /*
1469 ** This is a version of the "localtime()" function from the standard
1470
--- src/timeline.c
+++ src/timeline.c
@@ -1239,15 +1239,17 @@
1239 ** 2. Date/Time
1240 ** 3. Comment string and user
1241 ** 4. Number of non-merge children
1242 ** 5. Number of parents
1243 */
1244 void print_timeline(Stmt *q, int mxLine, int showfiles){
1245 int nLine = 0;
1246 char zPrevDate[20];
1247 const char *zCurrentUuid=0;
1248 zPrevDate[0] = 0;
1249 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
1250 Stmt fchngQuery; /* Query for file changes on check-ins */
1251
1252 if( g.localOpen ){
1253 int rid = db_lget_int("checkout", 0);
1254 zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1255 }
@@ -1292,11 +1294,45 @@
1294 n += strlen(zPrefix);
1295 }
1296 zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1297 nLine += comment_print(zFree, 9, 79);
1298 sqlite3_free(zFree);
1299
1300 if(showfiles){
1301 int inUl = 0;
1302 if( !fchngQueryInit ){
1303 db_prepare(&fchngQuery,
1304 "SELECT (pid==0) AS isnew,"
1305 " (fid==0) AS isdel,"
1306 " (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
1307 " (SELECT uuid FROM blob WHERE rid=fid),"
1308 " (SELECT uuid FROM blob WHERE rid=pid)"
1309 " FROM mlink"
1310 " WHERE mid=:mid AND pid!=fid"
1311 " ORDER BY 3 /*sort*/"
1312 );
1313 fchngQueryInit = 1;
1314 }
1315 db_bind_int(&fchngQuery, ":mid", rid);
1316 while( db_step(&fchngQuery)==SQLITE_ROW ){
1317 const char *zFilename = db_column_text(&fchngQuery, 2);
1318 int isNew = db_column_int(&fchngQuery, 0);
1319 int isDel = db_column_int(&fchngQuery, 1);
1320 const char *zOld = db_column_text(&fchngQuery, 4);
1321 const char *zNew = db_column_text(&fchngQuery, 3);
1322 if( isNew ){
1323 fossil_print(" ADDED %s\n",zFilename);
1324 }else if( isDel ){
1325 fossil_print(" DELETED %s\n",zFilename);
1326 }else{
1327 fossil_print(" EDITED %s\n", zFilename);
1328 }
1329 }
1330 db_reset(&fchngQuery);
1331 }
1332 }
1333 if( fchngQueryInit ) db_finalize(&fchngQuery);
1334 }
1335
1336 /*
1337 ** Return a pointer to a static string that forms the basis for
1338 ** a timeline query for display on a TTY.
@@ -1337,11 +1373,11 @@
1373 }
1374
1375 /*
1376 ** COMMAND: timeline
1377 **
1378 ** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n N? ?-t TYPE? ?-showfiles?
1379 **
1380 ** Print a summary of activity going backwards in date and time
1381 ** specified or from the current date and time if no arguments
1382 ** are given. Show as many as N (default 20) check-ins. The
1383 ** WHEN argument can be any unique abbreviation of one of these
@@ -1361,10 +1397,14 @@
1397 ** page. For example:
1398 **
1399 ** w = wiki commits only
1400 ** ci = file commits only
1401 ** t = tickets only
1402 **
1403 ** The optional showfiles argument if specified prints the list of
1404 ** files changed in a checkin after the checkin comment
1405 **
1406 */
1407 void timeline_cmd(void){
1408 Stmt q;
1409 int n, k;
1410 const char *zCount;
@@ -1373,10 +1413,12 @@
1413 char *zDate;
1414 Blob sql;
1415 int objid = 0;
1416 Blob uuid;
1417 int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
1418 int showfilesFlag = 0 ;
1419 showfilesFlag = find_option("showfiles","f", 0)!=0;
1420 db_find_and_open_repository(0, 0);
1421 zCount = find_option("count","n",1);
1422 zType = find_option("type","t",1);
1423 if( zCount ){
1424 n = atoi(zCount);
@@ -1399,13 +1441,13 @@
1441 mode = 4;
1442 }else if(!zType && !zCount){
1443 usage("?WHEN? ?BASELINE|DATETIME? ?-n|--count N? ?-t TYPE?");
1444 }
1445 if( '-' != *g.argv[3] ){
1446 zOrigin = g.argv[3];
1447 }else{
1448 zOrigin = "now";
1449 }
1450 }else if( g.argc==3 ){
1451 zOrigin = g.argv[2];
1452 }else{
1453 zOrigin = "now";
@@ -1459,11 +1501,11 @@
1501 }
1502
1503 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1504 db_prepare(&q, blob_str(&sql));
1505 blob_reset(&sql);
1506 print_timeline(&q, n, showfilesFlag);
1507 db_finalize(&q);
1508 }
1509
1510 /*
1511 ** This is a version of the "localtime()" function from the standard
1512
+1 -1
--- src/update.c
+++ src/update.c
@@ -170,11 +170,11 @@
170170
"%s "
171171
" AND event.objid IN leaves"
172172
" ORDER BY event.mtime DESC",
173173
timeline_query_for_tty()
174174
);
175
- print_timeline(&q, 100);
175
+ print_timeline(&q, 100, 0);
176176
db_finalize(&q);
177177
fossil_fatal("Multiple descendants");
178178
}
179179
}
180180
tid = db_int(0, "SELECT rid FROM leaves, event"
181181
--- src/update.c
+++ src/update.c
@@ -170,11 +170,11 @@
170 "%s "
171 " AND event.objid IN leaves"
172 " ORDER BY event.mtime DESC",
173 timeline_query_for_tty()
174 );
175 print_timeline(&q, 100);
176 db_finalize(&q);
177 fossil_fatal("Multiple descendants");
178 }
179 }
180 tid = db_int(0, "SELECT rid FROM leaves, event"
181
--- src/update.c
+++ src/update.c
@@ -170,11 +170,11 @@
170 "%s "
171 " AND event.objid IN leaves"
172 " ORDER BY event.mtime DESC",
173 timeline_query_for_tty()
174 );
175 print_timeline(&q, 100, 0);
176 db_finalize(&q);
177 fossil_fatal("Multiple descendants");
178 }
179 }
180 tid = db_int(0, "SELECT rid FROM leaves, event"
181

Keyboard Shortcuts

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