Fossil SCM
Implement "fossil undo -n|--dry-run" as replacement for the --explain flag which does the same.
Commit
57cfcc262168497f6fe3eb604042e82d1cfb4f68
Parent
12bc63aae53e482…
1 file changed
+9
-5
+9
-5
| --- src/undo.c | ||
| +++ src/undo.c | ||
| @@ -367,32 +367,36 @@ | ||
| 367 | 367 | ** |
| 368 | 368 | ** If FILENAME is specified then restore the content of the named |
| 369 | 369 | ** file(s) but otherwise leave the update or merge or revert in effect. |
| 370 | 370 | ** The redo command undoes the effect of the most recent undo. |
| 371 | 371 | ** |
| 372 | -** If the --explain option is present, no changes are made and instead | |
| 372 | +** If the -n|--dry-run option is present, no changes are made and instead | |
| 373 | 373 | ** the undo or redo command explains what actions the undo or redo would |
| 374 | -** have done had the --explain been omitted. | |
| 374 | +** have done had the -n|--dry-run been omitted. | |
| 375 | 375 | ** |
| 376 | 376 | ** A single level of undo/redo is supported. The undo/redo stack |
| 377 | 377 | ** is cleared by the commit and checkout commands. |
| 378 | 378 | ** |
| 379 | 379 | ** Options: |
| 380 | -** --explain do not make changes but show what would be done | |
| 380 | +** -n|--dry-run do not make changes but show what would be done | |
| 381 | 381 | ** |
| 382 | 382 | ** See also: commit, status |
| 383 | 383 | */ |
| 384 | 384 | void undo_cmd(void){ |
| 385 | 385 | int isRedo = g.argv[1][0]=='r'; |
| 386 | 386 | int undo_available; |
| 387 | - int explainFlag = find_option("explain", 0, 0)!=0; | |
| 387 | + int dryRunFlag = find_option("dry-run", "n", 0)!=0; | |
| 388 | 388 | const char *zCmd = isRedo ? "redo" : "undo"; |
| 389 | + | |
| 390 | + if( !dryRunFlag ){ | |
| 391 | + dryRunFlag = find_option("explain", 0, 0)!=0; | |
| 392 | + } | |
| 389 | 393 | db_must_be_within_tree(); |
| 390 | 394 | verify_all_options(); |
| 391 | 395 | db_begin_transaction(); |
| 392 | 396 | undo_available = db_lget_int("undo_available", 0); |
| 393 | - if( explainFlag ){ | |
| 397 | + if( dryRunFlag ){ | |
| 394 | 398 | if( undo_available==0 ){ |
| 395 | 399 | fossil_print("No undo or redo is available\n"); |
| 396 | 400 | }else{ |
| 397 | 401 | Stmt q; |
| 398 | 402 | int nChng = 0; |
| 399 | 403 |
| --- src/undo.c | |
| +++ src/undo.c | |
| @@ -367,32 +367,36 @@ | |
| 367 | ** |
| 368 | ** If FILENAME is specified then restore the content of the named |
| 369 | ** file(s) but otherwise leave the update or merge or revert in effect. |
| 370 | ** The redo command undoes the effect of the most recent undo. |
| 371 | ** |
| 372 | ** If the --explain option is present, no changes are made and instead |
| 373 | ** the undo or redo command explains what actions the undo or redo would |
| 374 | ** have done had the --explain been omitted. |
| 375 | ** |
| 376 | ** A single level of undo/redo is supported. The undo/redo stack |
| 377 | ** is cleared by the commit and checkout commands. |
| 378 | ** |
| 379 | ** Options: |
| 380 | ** --explain do not make changes but show what would be done |
| 381 | ** |
| 382 | ** See also: commit, status |
| 383 | */ |
| 384 | void undo_cmd(void){ |
| 385 | int isRedo = g.argv[1][0]=='r'; |
| 386 | int undo_available; |
| 387 | int explainFlag = find_option("explain", 0, 0)!=0; |
| 388 | const char *zCmd = isRedo ? "redo" : "undo"; |
| 389 | db_must_be_within_tree(); |
| 390 | verify_all_options(); |
| 391 | db_begin_transaction(); |
| 392 | undo_available = db_lget_int("undo_available", 0); |
| 393 | if( explainFlag ){ |
| 394 | if( undo_available==0 ){ |
| 395 | fossil_print("No undo or redo is available\n"); |
| 396 | }else{ |
| 397 | Stmt q; |
| 398 | int nChng = 0; |
| 399 |
| --- src/undo.c | |
| +++ src/undo.c | |
| @@ -367,32 +367,36 @@ | |
| 367 | ** |
| 368 | ** If FILENAME is specified then restore the content of the named |
| 369 | ** file(s) but otherwise leave the update or merge or revert in effect. |
| 370 | ** The redo command undoes the effect of the most recent undo. |
| 371 | ** |
| 372 | ** If the -n|--dry-run option is present, no changes are made and instead |
| 373 | ** the undo or redo command explains what actions the undo or redo would |
| 374 | ** have done had the -n|--dry-run been omitted. |
| 375 | ** |
| 376 | ** A single level of undo/redo is supported. The undo/redo stack |
| 377 | ** is cleared by the commit and checkout commands. |
| 378 | ** |
| 379 | ** Options: |
| 380 | ** -n|--dry-run do not make changes but show what would be done |
| 381 | ** |
| 382 | ** See also: commit, status |
| 383 | */ |
| 384 | void undo_cmd(void){ |
| 385 | int isRedo = g.argv[1][0]=='r'; |
| 386 | int undo_available; |
| 387 | int dryRunFlag = find_option("dry-run", "n", 0)!=0; |
| 388 | const char *zCmd = isRedo ? "redo" : "undo"; |
| 389 | |
| 390 | if( !dryRunFlag ){ |
| 391 | dryRunFlag = find_option("explain", 0, 0)!=0; |
| 392 | } |
| 393 | db_must_be_within_tree(); |
| 394 | verify_all_options(); |
| 395 | db_begin_transaction(); |
| 396 | undo_available = db_lget_int("undo_available", 0); |
| 397 | if( dryRunFlag ){ |
| 398 | if( undo_available==0 ){ |
| 399 | fossil_print("No undo or redo is available\n"); |
| 400 | }else{ |
| 401 | Stmt q; |
| 402 | int nChng = 0; |
| 403 |