Fossil SCM
If the -s option is used on the "fossil all command" and processing stops due to an error, print a clear error message so that the stop is unambiguous and does not get lost in the clutter of the "fossil all" output.
Commit
b582c87727d98003b8a38d10180bf78afb46d0cbd46f48c3878441d46039df2a
Parent
c6715ca6a0a32e2…
1 file changed
+12
-3
+12
-3
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -167,10 +167,12 @@ | ||
| 167 | 167 | void all_cmd(void){ |
| 168 | 168 | Stmt q; |
| 169 | 169 | const char *zCmd; |
| 170 | 170 | char *zSyscmd; |
| 171 | 171 | Blob extra; |
| 172 | + int bHalted = 0; | |
| 173 | + int rc = 0; | |
| 172 | 174 | int useCheckouts = 0; |
| 173 | 175 | int quiet = 0; |
| 174 | 176 | int dryRunFlag = 0; |
| 175 | 177 | int showFile = find_option("showfile",0,0)!=0; |
| 176 | 178 | int stopOnError; |
| @@ -469,11 +471,10 @@ | ||
| 469 | 471 | " ORDER BY 1" |
| 470 | 472 | ); |
| 471 | 473 | } |
| 472 | 474 | db_prepare(&q,"SELECT name, tag, inode FROM repolist ORDER BY 1"); |
| 473 | 475 | while( db_step(&q)==SQLITE_ROW ){ |
| 474 | - int rc; | |
| 475 | 476 | const char *zFilename = db_column_text(&q, 0); |
| 476 | 477 | const char *zInode = db_column_text(&q,2); |
| 477 | 478 | #if !USE_SEE |
| 478 | 479 | if( sqlite3_strglob("*.efossil", zFilename)==0 ) continue; |
| 479 | 480 | #endif |
| @@ -506,18 +507,21 @@ | ||
| 506 | 507 | if( !quiet || dryRunFlag ){ |
| 507 | 508 | fossil_print("%s\n", zSyscmd); |
| 508 | 509 | fflush(stdout); |
| 509 | 510 | } |
| 510 | 511 | rc = dryRunFlag ? 0 : fossil_system(zSyscmd); |
| 511 | - free(zSyscmd); | |
| 512 | 512 | if( rc ){ |
| 513 | - if( stopOnError ) break; | |
| 513 | + if( stopOnError ){ | |
| 514 | + bHalted = 1; | |
| 515 | + break; | |
| 516 | + } | |
| 514 | 517 | /* If there is an error, pause briefly, but do not stop. The brief |
| 515 | 518 | ** pause is so that if the prior command failed with Ctrl-C then there |
| 516 | 519 | ** will be time to stop the whole thing with a second Ctrl-C. */ |
| 517 | 520 | sqlite3_sleep(330); |
| 518 | 521 | } |
| 522 | + fossil_free(zSyscmd); | |
| 519 | 523 | } |
| 520 | 524 | db_finalize(&q); |
| 521 | 525 | |
| 522 | 526 | blob_reset(&extra); |
| 523 | 527 | |
| @@ -532,6 +536,11 @@ | ||
| 532 | 536 | db_unprotect(PROTECT_CONFIG); |
| 533 | 537 | db_multi_exec("%s", zSql /*safe-for-%s*/ ); |
| 534 | 538 | db_protect_pop(); |
| 535 | 539 | } |
| 536 | 540 | } |
| 541 | + | |
| 542 | + if( stopOnError && bHalted ){ | |
| 543 | + fossil_fatal("STOPPED: non-zero result code (%d) from\nSTOPPED: %s", | |
| 544 | + rc, zSyscmd); | |
| 545 | + } | |
| 537 | 546 | } |
| 538 | 547 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -167,10 +167,12 @@ | |
| 167 | void all_cmd(void){ |
| 168 | Stmt q; |
| 169 | const char *zCmd; |
| 170 | char *zSyscmd; |
| 171 | Blob extra; |
| 172 | int useCheckouts = 0; |
| 173 | int quiet = 0; |
| 174 | int dryRunFlag = 0; |
| 175 | int showFile = find_option("showfile",0,0)!=0; |
| 176 | int stopOnError; |
| @@ -469,11 +471,10 @@ | |
| 469 | " ORDER BY 1" |
| 470 | ); |
| 471 | } |
| 472 | db_prepare(&q,"SELECT name, tag, inode FROM repolist ORDER BY 1"); |
| 473 | while( db_step(&q)==SQLITE_ROW ){ |
| 474 | int rc; |
| 475 | const char *zFilename = db_column_text(&q, 0); |
| 476 | const char *zInode = db_column_text(&q,2); |
| 477 | #if !USE_SEE |
| 478 | if( sqlite3_strglob("*.efossil", zFilename)==0 ) continue; |
| 479 | #endif |
| @@ -506,18 +507,21 @@ | |
| 506 | if( !quiet || dryRunFlag ){ |
| 507 | fossil_print("%s\n", zSyscmd); |
| 508 | fflush(stdout); |
| 509 | } |
| 510 | rc = dryRunFlag ? 0 : fossil_system(zSyscmd); |
| 511 | free(zSyscmd); |
| 512 | if( rc ){ |
| 513 | if( stopOnError ) break; |
| 514 | /* If there is an error, pause briefly, but do not stop. The brief |
| 515 | ** pause is so that if the prior command failed with Ctrl-C then there |
| 516 | ** will be time to stop the whole thing with a second Ctrl-C. */ |
| 517 | sqlite3_sleep(330); |
| 518 | } |
| 519 | } |
| 520 | db_finalize(&q); |
| 521 | |
| 522 | blob_reset(&extra); |
| 523 | |
| @@ -532,6 +536,11 @@ | |
| 532 | db_unprotect(PROTECT_CONFIG); |
| 533 | db_multi_exec("%s", zSql /*safe-for-%s*/ ); |
| 534 | db_protect_pop(); |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -167,10 +167,12 @@ | |
| 167 | void all_cmd(void){ |
| 168 | Stmt q; |
| 169 | const char *zCmd; |
| 170 | char *zSyscmd; |
| 171 | Blob extra; |
| 172 | int bHalted = 0; |
| 173 | int rc = 0; |
| 174 | int useCheckouts = 0; |
| 175 | int quiet = 0; |
| 176 | int dryRunFlag = 0; |
| 177 | int showFile = find_option("showfile",0,0)!=0; |
| 178 | int stopOnError; |
| @@ -469,11 +471,10 @@ | |
| 471 | " ORDER BY 1" |
| 472 | ); |
| 473 | } |
| 474 | db_prepare(&q,"SELECT name, tag, inode FROM repolist ORDER BY 1"); |
| 475 | while( db_step(&q)==SQLITE_ROW ){ |
| 476 | const char *zFilename = db_column_text(&q, 0); |
| 477 | const char *zInode = db_column_text(&q,2); |
| 478 | #if !USE_SEE |
| 479 | if( sqlite3_strglob("*.efossil", zFilename)==0 ) continue; |
| 480 | #endif |
| @@ -506,18 +507,21 @@ | |
| 507 | if( !quiet || dryRunFlag ){ |
| 508 | fossil_print("%s\n", zSyscmd); |
| 509 | fflush(stdout); |
| 510 | } |
| 511 | rc = dryRunFlag ? 0 : fossil_system(zSyscmd); |
| 512 | if( rc ){ |
| 513 | if( stopOnError ){ |
| 514 | bHalted = 1; |
| 515 | break; |
| 516 | } |
| 517 | /* If there is an error, pause briefly, but do not stop. The brief |
| 518 | ** pause is so that if the prior command failed with Ctrl-C then there |
| 519 | ** will be time to stop the whole thing with a second Ctrl-C. */ |
| 520 | sqlite3_sleep(330); |
| 521 | } |
| 522 | fossil_free(zSyscmd); |
| 523 | } |
| 524 | db_finalize(&q); |
| 525 | |
| 526 | blob_reset(&extra); |
| 527 | |
| @@ -532,6 +536,11 @@ | |
| 536 | db_unprotect(PROTECT_CONFIG); |
| 537 | db_multi_exec("%s", zSql /*safe-for-%s*/ ); |
| 538 | db_protect_pop(); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | if( stopOnError && bHalted ){ |
| 543 | fossil_fatal("STOPPED: non-zero result code (%d) from\nSTOPPED: %s", |
| 544 | rc, zSyscmd); |
| 545 | } |
| 546 | } |
| 547 |