Fossil SCM

Remove the "fossil forks" command. Replace it with "fossil leaves --multiple".

drh 2015-04-26 19:43 trunk
Commit 7bef5bf1c3d43d404a0bdfaf3c398d6354c9803e
1 file changed +58 -28
+58 -28
--- src/descendants.c
+++ src/descendants.c
@@ -340,25 +340,25 @@
340340
db_finalize(&q);
341341
}
342342
343343
/*
344344
** COMMAND: leaves*
345
-** COMMAND: forks*
345
+**
346
+** Usage: %fossil leaves ?OPTIONS?
346347
**
347
-** Usage: %fossil leaves|forks ?OPTIONS?
348
-**
349
-** Find leaves/forks of all branches. By default show only open leaves.
348
+** Find leaves of all branches. By default show only open leaves.
350349
** The -a|--all flag causes all leaves (closed and open) to be shown.
351350
** The -c|--closed flag shows only closed leaves.
352351
**
353352
** The --recompute flag causes the content of the "leaf" table in the
354353
** repository database to be recomputed.
355354
**
356355
** Options:
357356
** -a|--all show ALL leaves
358
-** -c|--closed show only closed leaves
359357
** --bybranch order output by branch name
358
+** -c|--closed show only closed leaves
359
+** -m|--multiple show only cases with multiple leaves on a single branch
360360
** --recompute recompute the "leaf" table in the repository DB
361361
** -W|--width <num> Width of lines (default is to auto-detect). Must be
362362
** >39 or 0 (= no limit, resulting in a single line per
363363
** entry).
364364
**
@@ -369,16 +369,17 @@
369369
Blob sql;
370370
int showAll = find_option("all", "a", 0)!=0;
371371
int showClosed = find_option("closed", "c", 0)!=0;
372372
int recomputeFlag = find_option("recompute",0,0)!=0;
373373
int byBranch = find_option("bybranch",0,0)!=0;
374
- int showForks = g.argv[1][0]=='f';
374
+ int multipleFlag = find_option("multiple","m",0)!=0;
375375
const char *zWidth = find_option("width","W",1);
376376
char *zLastBr = 0;
377377
int n, width;
378378
char zLineNo[10];
379379
380
+ if( multipleFlag ) byBranch = 1;
380381
if( zWidth ){
381382
width = atoi(zWidth);
382383
if( (width!=0) && (width<=39) ){
383384
fossil_fatal("-W|--width value must be >39 or 0");
384385
}
@@ -391,14 +392,45 @@
391392
verify_all_options();
392393
393394
if( recomputeFlag ) leaf_rebuild();
394395
blob_zero(&sql);
395396
blob_append(&sql, timeline_query_for_tty(), -1);
396
- blob_append_sql(&sql, " AND blob.rid IN leaf");
397
+ if( !multipleFlag ){
398
+ /* The usual case - show all leaves */
399
+ blob_append_sql(&sql, " AND blob.rid IN leaf");
400
+ }else{
401
+ /* Show only leaves where two are more occur in the same branch */
402
+ db_multi_exec(
403
+ "CREATE TEMP TABLE openLeaf(rid INTEGER PRIMARY KEY);"
404
+ "INSERT INTO openLeaf(rid)"
405
+ " SELECT rid FROM leaf"
406
+ " WHERE NOT EXISTS("
407
+ " SELECT 1 FROM tagxref"
408
+ " WHERE tagid=%d AND tagtype>0 AND rid=leaf.rid);",
409
+ TAG_CLOSED
410
+ );
411
+ db_multi_exec(
412
+ "CREATE TEMP TABLE ambiguousBranch(brname TEXT);"
413
+ "INSERT INTO ambiguousBranch(brname)"
414
+ " SELECT (SELECT value FROM tagxref WHERE tagid=%d AND rid=openLeaf.rid)"
415
+ " FROM openLeaf"
416
+ " GROUP BY 1 HAVING count(*)>1;",
417
+ TAG_BRANCH
418
+ );
419
+ db_multi_exec(
420
+ "CREATE TEMP TABLE ambiguousLeaf(rid INTEGER PRIMARY KEY);\n"
421
+ "INSERT INTO ambiguousLeaf(rid)\n"
422
+ " SELECT rid FROM openLeaf\n"
423
+ " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=openLeaf.rid)"
424
+ " IN (SELECT brname FROM ambiguousBranch);",
425
+ TAG_BRANCH
426
+ );
427
+ blob_append_sql(&sql, " AND blob.rid IN ambiguousLeaf");
428
+ }
397429
if( showClosed ){
398430
blob_append_sql(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
399
- }else if( !showAll || showForks ){
431
+ }else if( !showAll ){
400432
blob_append_sql(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
401433
}
402434
if( byBranch ){
403435
db_prepare(&q, "%s ORDER BY nullif(branch,'trunk') COLLATE nocase,"
404436
" event.mtime DESC",
@@ -407,30 +439,28 @@
407439
db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_sql_text(&sql));
408440
}
409441
blob_reset(&sql);
410442
n = 0;
411443
while( db_step(&q)==SQLITE_ROW ){
412
- if( !showForks ||
413
- fossil_find_nearest_fork(db_column_int(&q, 0), db_open_local(0)) ){
414
- const char *zId = db_column_text(&q, 1);
415
- const char *zDate = db_column_text(&q, 2);
416
- const char *zCom = db_column_text(&q, 3);
417
- const char *zBr = db_column_text(&q, 7);
418
- char *z;
419
-
420
- if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
421
- fossil_print("*** %s ***\n", zBr);
422
- fossil_free(zLastBr);
423
- zLastBr = fossil_strdup(zBr);
424
- }
425
- n++;
426
- sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
427
- fossil_print("%6s ", zLineNo);
428
- z = mprintf("%s [%S] %s", zDate, zId, zCom);
429
- comment_print(z, zCom, 7, width, g.comFmtFlags);
430
- fossil_free(z);
431
- }
444
+ const char *zId = db_column_text(&q, 1);
445
+ const char *zDate = db_column_text(&q, 2);
446
+ const char *zCom = db_column_text(&q, 3);
447
+ const char *zBr = db_column_text(&q, 7);
448
+ char *z;
449
+
450
+ if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
451
+ fossil_print("*** %s ***\n", zBr);
452
+ fossil_free(zLastBr);
453
+ zLastBr = fossil_strdup(zBr);
454
+ if( multipleFlag ) n = 0;
455
+ }
456
+ n++;
457
+ sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
458
+ fossil_print("%6s ", zLineNo);
459
+ z = mprintf("%s [%S] %s", zDate, zId, zCom);
460
+ comment_print(z, zCom, 7, width, g.comFmtFlags);
461
+ fossil_free(z);
432462
}
433463
fossil_free(zLastBr);
434464
db_finalize(&q);
435465
}
436466
437467
--- src/descendants.c
+++ src/descendants.c
@@ -340,25 +340,25 @@
340 db_finalize(&q);
341 }
342
343 /*
344 ** COMMAND: leaves*
345 ** COMMAND: forks*
 
346 **
347 ** Usage: %fossil leaves|forks ?OPTIONS?
348 **
349 ** Find leaves/forks of all branches. By default show only open leaves.
350 ** The -a|--all flag causes all leaves (closed and open) to be shown.
351 ** The -c|--closed flag shows only closed leaves.
352 **
353 ** The --recompute flag causes the content of the "leaf" table in the
354 ** repository database to be recomputed.
355 **
356 ** Options:
357 ** -a|--all show ALL leaves
358 ** -c|--closed show only closed leaves
359 ** --bybranch order output by branch name
 
 
360 ** --recompute recompute the "leaf" table in the repository DB
361 ** -W|--width <num> Width of lines (default is to auto-detect). Must be
362 ** >39 or 0 (= no limit, resulting in a single line per
363 ** entry).
364 **
@@ -369,16 +369,17 @@
369 Blob sql;
370 int showAll = find_option("all", "a", 0)!=0;
371 int showClosed = find_option("closed", "c", 0)!=0;
372 int recomputeFlag = find_option("recompute",0,0)!=0;
373 int byBranch = find_option("bybranch",0,0)!=0;
374 int showForks = g.argv[1][0]=='f';
375 const char *zWidth = find_option("width","W",1);
376 char *zLastBr = 0;
377 int n, width;
378 char zLineNo[10];
379
 
380 if( zWidth ){
381 width = atoi(zWidth);
382 if( (width!=0) && (width<=39) ){
383 fossil_fatal("-W|--width value must be >39 or 0");
384 }
@@ -391,14 +392,45 @@
391 verify_all_options();
392
393 if( recomputeFlag ) leaf_rebuild();
394 blob_zero(&sql);
395 blob_append(&sql, timeline_query_for_tty(), -1);
396 blob_append_sql(&sql, " AND blob.rid IN leaf");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397 if( showClosed ){
398 blob_append_sql(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
399 }else if( !showAll || showForks ){
400 blob_append_sql(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
401 }
402 if( byBranch ){
403 db_prepare(&q, "%s ORDER BY nullif(branch,'trunk') COLLATE nocase,"
404 " event.mtime DESC",
@@ -407,30 +439,28 @@
407 db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_sql_text(&sql));
408 }
409 blob_reset(&sql);
410 n = 0;
411 while( db_step(&q)==SQLITE_ROW ){
412 if( !showForks ||
413 fossil_find_nearest_fork(db_column_int(&q, 0), db_open_local(0)) ){
414 const char *zId = db_column_text(&q, 1);
415 const char *zDate = db_column_text(&q, 2);
416 const char *zCom = db_column_text(&q, 3);
417 const char *zBr = db_column_text(&q, 7);
418 char *z;
419
420 if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
421 fossil_print("*** %s ***\n", zBr);
422 fossil_free(zLastBr);
423 zLastBr = fossil_strdup(zBr);
424 }
425 n++;
426 sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
427 fossil_print("%6s ", zLineNo);
428 z = mprintf("%s [%S] %s", zDate, zId, zCom);
429 comment_print(z, zCom, 7, width, g.comFmtFlags);
430 fossil_free(z);
431 }
432 }
433 fossil_free(zLastBr);
434 db_finalize(&q);
435 }
436
437
--- src/descendants.c
+++ src/descendants.c
@@ -340,25 +340,25 @@
340 db_finalize(&q);
341 }
342
343 /*
344 ** COMMAND: leaves*
345 **
346 ** Usage: %fossil leaves ?OPTIONS?
347 **
348 ** Find leaves of all branches. By default show only open leaves.
 
 
349 ** The -a|--all flag causes all leaves (closed and open) to be shown.
350 ** The -c|--closed flag shows only closed leaves.
351 **
352 ** The --recompute flag causes the content of the "leaf" table in the
353 ** repository database to be recomputed.
354 **
355 ** Options:
356 ** -a|--all show ALL leaves
 
357 ** --bybranch order output by branch name
358 ** -c|--closed show only closed leaves
359 ** -m|--multiple show only cases with multiple leaves on a single branch
360 ** --recompute recompute the "leaf" table in the repository DB
361 ** -W|--width <num> Width of lines (default is to auto-detect). Must be
362 ** >39 or 0 (= no limit, resulting in a single line per
363 ** entry).
364 **
@@ -369,16 +369,17 @@
369 Blob sql;
370 int showAll = find_option("all", "a", 0)!=0;
371 int showClosed = find_option("closed", "c", 0)!=0;
372 int recomputeFlag = find_option("recompute",0,0)!=0;
373 int byBranch = find_option("bybranch",0,0)!=0;
374 int multipleFlag = find_option("multiple","m",0)!=0;
375 const char *zWidth = find_option("width","W",1);
376 char *zLastBr = 0;
377 int n, width;
378 char zLineNo[10];
379
380 if( multipleFlag ) byBranch = 1;
381 if( zWidth ){
382 width = atoi(zWidth);
383 if( (width!=0) && (width<=39) ){
384 fossil_fatal("-W|--width value must be >39 or 0");
385 }
@@ -391,14 +392,45 @@
392 verify_all_options();
393
394 if( recomputeFlag ) leaf_rebuild();
395 blob_zero(&sql);
396 blob_append(&sql, timeline_query_for_tty(), -1);
397 if( !multipleFlag ){
398 /* The usual case - show all leaves */
399 blob_append_sql(&sql, " AND blob.rid IN leaf");
400 }else{
401 /* Show only leaves where two are more occur in the same branch */
402 db_multi_exec(
403 "CREATE TEMP TABLE openLeaf(rid INTEGER PRIMARY KEY);"
404 "INSERT INTO openLeaf(rid)"
405 " SELECT rid FROM leaf"
406 " WHERE NOT EXISTS("
407 " SELECT 1 FROM tagxref"
408 " WHERE tagid=%d AND tagtype>0 AND rid=leaf.rid);",
409 TAG_CLOSED
410 );
411 db_multi_exec(
412 "CREATE TEMP TABLE ambiguousBranch(brname TEXT);"
413 "INSERT INTO ambiguousBranch(brname)"
414 " SELECT (SELECT value FROM tagxref WHERE tagid=%d AND rid=openLeaf.rid)"
415 " FROM openLeaf"
416 " GROUP BY 1 HAVING count(*)>1;",
417 TAG_BRANCH
418 );
419 db_multi_exec(
420 "CREATE TEMP TABLE ambiguousLeaf(rid INTEGER PRIMARY KEY);\n"
421 "INSERT INTO ambiguousLeaf(rid)\n"
422 " SELECT rid FROM openLeaf\n"
423 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=openLeaf.rid)"
424 " IN (SELECT brname FROM ambiguousBranch);",
425 TAG_BRANCH
426 );
427 blob_append_sql(&sql, " AND blob.rid IN ambiguousLeaf");
428 }
429 if( showClosed ){
430 blob_append_sql(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
431 }else if( !showAll ){
432 blob_append_sql(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
433 }
434 if( byBranch ){
435 db_prepare(&q, "%s ORDER BY nullif(branch,'trunk') COLLATE nocase,"
436 " event.mtime DESC",
@@ -407,30 +439,28 @@
439 db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_sql_text(&sql));
440 }
441 blob_reset(&sql);
442 n = 0;
443 while( db_step(&q)==SQLITE_ROW ){
444 const char *zId = db_column_text(&q, 1);
445 const char *zDate = db_column_text(&q, 2);
446 const char *zCom = db_column_text(&q, 3);
447 const char *zBr = db_column_text(&q, 7);
448 char *z;
449
450 if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
451 fossil_print("*** %s ***\n", zBr);
452 fossil_free(zLastBr);
453 zLastBr = fossil_strdup(zBr);
454 if( multipleFlag ) n = 0;
455 }
456 n++;
457 sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
458 fossil_print("%6s ", zLineNo);
459 z = mprintf("%s [%S] %s", zDate, zId, zCom);
460 comment_print(z, zCom, 7, width, g.comFmtFlags);
461 fossil_free(z);
 
 
462 }
463 fossil_free(zLastBr);
464 db_finalize(&q);
465 }
466
467

Keyboard Shortcuts

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