Fossil SCM

Implement "fossil undo -n|--dry-run" as replacement for the --explain flag which does the same.

jan.nijtmans 2013-05-03 11:50 trunk
Commit 57cfcc262168497f6fe3eb604042e82d1cfb4f68
1 file changed +9 -5
+9 -5
--- src/undo.c
+++ src/undo.c
@@ -367,32 +367,36 @@
367367
**
368368
** If FILENAME is specified then restore the content of the named
369369
** file(s) but otherwise leave the update or merge or revert in effect.
370370
** The redo command undoes the effect of the most recent undo.
371371
**
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
373373
** 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.
375375
**
376376
** A single level of undo/redo is supported. The undo/redo stack
377377
** is cleared by the commit and checkout commands.
378378
**
379379
** 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
381381
**
382382
** See also: commit, status
383383
*/
384384
void undo_cmd(void){
385385
int isRedo = g.argv[1][0]=='r';
386386
int undo_available;
387
- int explainFlag = find_option("explain", 0, 0)!=0;
387
+ int dryRunFlag = find_option("dry-run", "n", 0)!=0;
388388
const char *zCmd = isRedo ? "redo" : "undo";
389
+
390
+ if( !dryRunFlag ){
391
+ dryRunFlag = find_option("explain", 0, 0)!=0;
392
+ }
389393
db_must_be_within_tree();
390394
verify_all_options();
391395
db_begin_transaction();
392396
undo_available = db_lget_int("undo_available", 0);
393
- if( explainFlag ){
397
+ if( dryRunFlag ){
394398
if( undo_available==0 ){
395399
fossil_print("No undo or redo is available\n");
396400
}else{
397401
Stmt q;
398402
int nChng = 0;
399403
--- 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

Keyboard Shortcuts

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