Fossil SCM

Change the output format for the "fossil leaves" command and add the --bybranch command-line option which is useful for looking for forks.

drh 2013-01-14 12:52 trunk
Commit f76d912f1d93acbf2b653704828ef7b1a0cfe652
2 files changed +33 -2 +11 -3
--- src/descendants.c
+++ src/descendants.c
@@ -348,10 +348,11 @@
348348
** repository database to be recomputed.
349349
**
350350
** Options:
351351
** --all show ALL leaves
352352
** --closed show only closed leaves
353
+** --bybranch order output by branch name
353354
** --recompute recompute the "leaf" table in the repository DB
354355
**
355356
** See also: descendants, finfo, info, branch
356357
*/
357358
void leaves_cmd(void){
@@ -358,10 +359,14 @@
358359
Stmt q;
359360
Blob sql;
360361
int showAll = find_option("all", 0, 0)!=0;
361362
int showClosed = find_option("closed", 0, 0)!=0;
362363
int recomputeFlag = find_option("recompute",0,0)!=0;
364
+ int byBranch = find_option("bybranch",0,0)!=0;
365
+ const char *zLastBr = 0;
366
+ int n;
367
+ char zLineNo[10];
363368
364369
db_find_and_open_repository(0,0);
365370
if( recomputeFlag ) leaf_rebuild();
366371
blob_zero(&sql);
367372
blob_append(&sql, timeline_query_for_tty(), -1);
@@ -369,13 +374,39 @@
369374
if( showClosed ){
370375
blob_appendf(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
371376
}else if( !showAll ){
372377
blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
373378
}
374
- db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
379
+ if( byBranch ){
380
+ db_prepare(&q, "%s ORDER BY nullif(branch,'trunk') COLLATE nocase,"
381
+ " event.mtime DESC",
382
+ blob_str(&sql));
383
+ }else{
384
+ db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
385
+ }
375386
blob_reset(&sql);
376
- print_timeline(&q, 2000, 0);
387
+ n = 0;
388
+ while( db_step(&q)==SQLITE_ROW ){
389
+ const char *zId = db_column_text(&q, 1);
390
+ const char *zDate = db_column_text(&q, 2);
391
+ const char *zCom = db_column_text(&q, 3);
392
+ const char *zBr = db_column_text(&q, 7);
393
+ char *z;
394
+
395
+ if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
396
+ fossil_print("*** %s ***\n", zBr);
397
+ fossil_free(zLastBr);
398
+ zLastBr = fossil_strdup(zBr);
399
+ }
400
+ n++;
401
+ sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
402
+ fossil_print("%6s ", zLineNo);
403
+ z = mprintf("%s [%.10s] %s", zDate, zId, zCom);
404
+ comment_print(z, 7, 79);
405
+ fossil_free(z);
406
+ }
407
+ fossil_free(zLastBr);
377408
db_finalize(&q);
378409
}
379410
380411
/*
381412
** WEBPAGE: leaves
382413
--- src/descendants.c
+++ src/descendants.c
@@ -348,10 +348,11 @@
348 ** repository database to be recomputed.
349 **
350 ** Options:
351 ** --all show ALL leaves
352 ** --closed show only closed leaves
 
353 ** --recompute recompute the "leaf" table in the repository DB
354 **
355 ** See also: descendants, finfo, info, branch
356 */
357 void leaves_cmd(void){
@@ -358,10 +359,14 @@
358 Stmt q;
359 Blob sql;
360 int showAll = find_option("all", 0, 0)!=0;
361 int showClosed = find_option("closed", 0, 0)!=0;
362 int recomputeFlag = find_option("recompute",0,0)!=0;
 
 
 
 
363
364 db_find_and_open_repository(0,0);
365 if( recomputeFlag ) leaf_rebuild();
366 blob_zero(&sql);
367 blob_append(&sql, timeline_query_for_tty(), -1);
@@ -369,13 +374,39 @@
369 if( showClosed ){
370 blob_appendf(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
371 }else if( !showAll ){
372 blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
373 }
374 db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
 
 
 
 
 
 
375 blob_reset(&sql);
376 print_timeline(&q, 2000, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377 db_finalize(&q);
378 }
379
380 /*
381 ** WEBPAGE: leaves
382
--- src/descendants.c
+++ src/descendants.c
@@ -348,10 +348,11 @@
348 ** repository database to be recomputed.
349 **
350 ** Options:
351 ** --all show ALL leaves
352 ** --closed show only closed leaves
353 ** --bybranch order output by branch name
354 ** --recompute recompute the "leaf" table in the repository DB
355 **
356 ** See also: descendants, finfo, info, branch
357 */
358 void leaves_cmd(void){
@@ -358,10 +359,14 @@
359 Stmt q;
360 Blob sql;
361 int showAll = find_option("all", 0, 0)!=0;
362 int showClosed = find_option("closed", 0, 0)!=0;
363 int recomputeFlag = find_option("recompute",0,0)!=0;
364 int byBranch = find_option("bybranch",0,0)!=0;
365 const char *zLastBr = 0;
366 int n;
367 char zLineNo[10];
368
369 db_find_and_open_repository(0,0);
370 if( recomputeFlag ) leaf_rebuild();
371 blob_zero(&sql);
372 blob_append(&sql, timeline_query_for_tty(), -1);
@@ -369,13 +374,39 @@
374 if( showClosed ){
375 blob_appendf(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
376 }else if( !showAll ){
377 blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
378 }
379 if( byBranch ){
380 db_prepare(&q, "%s ORDER BY nullif(branch,'trunk') COLLATE nocase,"
381 " event.mtime DESC",
382 blob_str(&sql));
383 }else{
384 db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
385 }
386 blob_reset(&sql);
387 n = 0;
388 while( db_step(&q)==SQLITE_ROW ){
389 const char *zId = db_column_text(&q, 1);
390 const char *zDate = db_column_text(&q, 2);
391 const char *zCom = db_column_text(&q, 3);
392 const char *zBr = db_column_text(&q, 7);
393 char *z;
394
395 if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
396 fossil_print("*** %s ***\n", zBr);
397 fossil_free(zLastBr);
398 zLastBr = fossil_strdup(zBr);
399 }
400 n++;
401 sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
402 fossil_print("%6s ", zLineNo);
403 z = mprintf("%s [%.10s] %s", zDate, zId, zCom);
404 comment_print(z, 7, 79);
405 fossil_free(z);
406 }
407 fossil_free(zLastBr);
408 db_finalize(&q);
409 }
410
411 /*
412 ** WEBPAGE: leaves
413
+11 -3
--- src/timeline.c
+++ src/timeline.c
@@ -1392,10 +1392,12 @@
13921392
** 1. uuid
13931393
** 2. Date/Time
13941394
** 3. Comment string and user
13951395
** 4. Number of non-merge children
13961396
** 5. Number of parents
1397
+** 6. mtime
1398
+** 7. branch
13971399
*/
13981400
void print_timeline(Stmt *q, int mxLine, int showfiles){
13991401
int nLine = 0;
14001402
char zPrevDate[20];
14011403
const char *zCurrentUuid=0;
@@ -1500,15 +1502,21 @@
15001502
@ FROM (SELECT group_concat(substr(tagname,5), ', ') AS x
15011503
@ FROM tag, tagxref
15021504
@ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid
15031505
@ AND tagxref.rid=blob.rid AND tagxref.tagtype>0))
15041506
@ || ')' as comment,
1505
- @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim) AS primPlinkCount,
1507
+ @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim)
1508
+ @ AS primPlinkCount,
15061509
@ (SELECT count(*) FROM plink WHERE cid=blob.rid) AS plinkCount,
1507
- @ event.mtime AS mtime
1508
- @ FROM event, blob
1510
+ @ event.mtime AS mtime,
1511
+ @ tagxref.value AS branch
1512
+ @ FROM tag CROSS JOIN event CROSS JOIN blob CROSS JOIN tagxref
15091513
@ WHERE blob.rid=event.objid
1514
+ @ AND tag.tagname='branch'
1515
+ @ AND tagxref.tagid=tag.tagid
1516
+ @ AND tagxref.tagtype>0
1517
+ @ AND tagxref.rid=blob.rid
15101518
;
15111519
return zBaseSql;
15121520
}
15131521
15141522
/*
15151523
--- src/timeline.c
+++ src/timeline.c
@@ -1392,10 +1392,12 @@
1392 ** 1. uuid
1393 ** 2. Date/Time
1394 ** 3. Comment string and user
1395 ** 4. Number of non-merge children
1396 ** 5. Number of parents
 
 
1397 */
1398 void print_timeline(Stmt *q, int mxLine, int showfiles){
1399 int nLine = 0;
1400 char zPrevDate[20];
1401 const char *zCurrentUuid=0;
@@ -1500,15 +1502,21 @@
1500 @ FROM (SELECT group_concat(substr(tagname,5), ', ') AS x
1501 @ FROM tag, tagxref
1502 @ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid
1503 @ AND tagxref.rid=blob.rid AND tagxref.tagtype>0))
1504 @ || ')' as comment,
1505 @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim) AS primPlinkCount,
 
1506 @ (SELECT count(*) FROM plink WHERE cid=blob.rid) AS plinkCount,
1507 @ event.mtime AS mtime
1508 @ FROM event, blob
 
1509 @ WHERE blob.rid=event.objid
 
 
 
 
1510 ;
1511 return zBaseSql;
1512 }
1513
1514 /*
1515
--- src/timeline.c
+++ src/timeline.c
@@ -1392,10 +1392,12 @@
1392 ** 1. uuid
1393 ** 2. Date/Time
1394 ** 3. Comment string and user
1395 ** 4. Number of non-merge children
1396 ** 5. Number of parents
1397 ** 6. mtime
1398 ** 7. branch
1399 */
1400 void print_timeline(Stmt *q, int mxLine, int showfiles){
1401 int nLine = 0;
1402 char zPrevDate[20];
1403 const char *zCurrentUuid=0;
@@ -1500,15 +1502,21 @@
1502 @ FROM (SELECT group_concat(substr(tagname,5), ', ') AS x
1503 @ FROM tag, tagxref
1504 @ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid
1505 @ AND tagxref.rid=blob.rid AND tagxref.tagtype>0))
1506 @ || ')' as comment,
1507 @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim)
1508 @ AS primPlinkCount,
1509 @ (SELECT count(*) FROM plink WHERE cid=blob.rid) AS plinkCount,
1510 @ event.mtime AS mtime,
1511 @ tagxref.value AS branch
1512 @ FROM tag CROSS JOIN event CROSS JOIN blob CROSS JOIN tagxref
1513 @ WHERE blob.rid=event.objid
1514 @ AND tag.tagname='branch'
1515 @ AND tagxref.tagid=tag.tagid
1516 @ AND tagxref.tagtype>0
1517 @ AND tagxref.rid=blob.rid
1518 ;
1519 return zBaseSql;
1520 }
1521
1522 /*
1523

Keyboard Shortcuts

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