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.
Commit
f76d912f1d93acbf2b653704828ef7b1a0cfe652
Parent
bee86ff39af2bc7…
2 files changed
+33
-2
+11
-3
+33
-2
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -348,10 +348,11 @@ | ||
| 348 | 348 | ** repository database to be recomputed. |
| 349 | 349 | ** |
| 350 | 350 | ** Options: |
| 351 | 351 | ** --all show ALL leaves |
| 352 | 352 | ** --closed show only closed leaves |
| 353 | +** --bybranch order output by branch name | |
| 353 | 354 | ** --recompute recompute the "leaf" table in the repository DB |
| 354 | 355 | ** |
| 355 | 356 | ** See also: descendants, finfo, info, branch |
| 356 | 357 | */ |
| 357 | 358 | void leaves_cmd(void){ |
| @@ -358,10 +359,14 @@ | ||
| 358 | 359 | Stmt q; |
| 359 | 360 | Blob sql; |
| 360 | 361 | int showAll = find_option("all", 0, 0)!=0; |
| 361 | 362 | int showClosed = find_option("closed", 0, 0)!=0; |
| 362 | 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]; | |
| 363 | 368 | |
| 364 | 369 | db_find_and_open_repository(0,0); |
| 365 | 370 | if( recomputeFlag ) leaf_rebuild(); |
| 366 | 371 | blob_zero(&sql); |
| 367 | 372 | blob_append(&sql, timeline_query_for_tty(), -1); |
| @@ -369,13 +374,39 @@ | ||
| 369 | 374 | if( showClosed ){ |
| 370 | 375 | blob_appendf(&sql," AND %z", leaf_is_closed_sql("blob.rid")); |
| 371 | 376 | }else if( !showAll ){ |
| 372 | 377 | blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid")); |
| 373 | 378 | } |
| 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 | + } | |
| 375 | 386 | 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); | |
| 377 | 408 | db_finalize(&q); |
| 378 | 409 | } |
| 379 | 410 | |
| 380 | 411 | /* |
| 381 | 412 | ** WEBPAGE: leaves |
| 382 | 413 |
| --- 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 @@ | ||
| 1392 | 1392 | ** 1. uuid |
| 1393 | 1393 | ** 2. Date/Time |
| 1394 | 1394 | ** 3. Comment string and user |
| 1395 | 1395 | ** 4. Number of non-merge children |
| 1396 | 1396 | ** 5. Number of parents |
| 1397 | +** 6. mtime | |
| 1398 | +** 7. branch | |
| 1397 | 1399 | */ |
| 1398 | 1400 | void print_timeline(Stmt *q, int mxLine, int showfiles){ |
| 1399 | 1401 | int nLine = 0; |
| 1400 | 1402 | char zPrevDate[20]; |
| 1401 | 1403 | const char *zCurrentUuid=0; |
| @@ -1500,15 +1502,21 @@ | ||
| 1500 | 1502 | @ FROM (SELECT group_concat(substr(tagname,5), ', ') AS x |
| 1501 | 1503 | @ FROM tag, tagxref |
| 1502 | 1504 | @ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid |
| 1503 | 1505 | @ AND tagxref.rid=blob.rid AND tagxref.tagtype>0)) |
| 1504 | 1506 | @ || ')' 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, | |
| 1506 | 1509 | @ (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 | |
| 1509 | 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 | |
| 1510 | 1518 | ; |
| 1511 | 1519 | return zBaseSql; |
| 1512 | 1520 | } |
| 1513 | 1521 | |
| 1514 | 1522 | /* |
| 1515 | 1523 |
| --- 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 |