Fossil SCM
Corrections to the new TH1 'checkout' command and tests.
Commit
589b902edb5565fab257da1ec3d28e6bcfc75317
Parent
c7f5541b7d81015…
2 files changed
+6
-4
+3
-3
+6
-4
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -595,11 +595,13 @@ | ||
| 595 | 595 | |
| 596 | 596 | /* |
| 597 | 597 | ** TH1 command: checkout ?BOOLEAN? |
| 598 | 598 | ** |
| 599 | 599 | ** Return the fully qualified directory name of the current checkout or an |
| 600 | -** empty string if it is not available. | |
| 600 | +** empty string if it is not available. Optionally, it will attempt to find | |
| 601 | +** the current checkout, opening the configuration ("user") database and the | |
| 602 | +** repository as necessary, if the boolean argument is non-zero. | |
| 601 | 603 | */ |
| 602 | 604 | static int checkoutCmd( |
| 603 | 605 | Th_Interp *interp, |
| 604 | 606 | void *p, |
| 605 | 607 | int argc, |
| @@ -608,15 +610,15 @@ | ||
| 608 | 610 | ){ |
| 609 | 611 | if( argc!=1 && argc!=2 ){ |
| 610 | 612 | return Th_WrongNumArgs(interp, "checkout ?BOOLEAN?"); |
| 611 | 613 | } |
| 612 | 614 | if( argc==2 ){ |
| 613 | - int openRepository = 0; | |
| 614 | - if( Th_ToInt(interp, argv[1], argl[1], &openRepository) ){ | |
| 615 | + int openCheckout = 0; | |
| 616 | + if( Th_ToInt(interp, argv[1], argl[1], &openCheckout) ){ | |
| 615 | 617 | return TH_ERROR; |
| 616 | 618 | } |
| 617 | - if( openRepository ) db_find_and_open_repository(OPEN_OK_NOT_FOUND, 0); | |
| 619 | + if( openCheckout ) db_open_local(0); | |
| 618 | 620 | } |
| 619 | 621 | Th_SetResult(interp, g.zLocalRoot, -1); |
| 620 | 622 | return TH_OK; |
| 621 | 623 | } |
| 622 | 624 | |
| 623 | 625 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -595,11 +595,13 @@ | |
| 595 | |
| 596 | /* |
| 597 | ** TH1 command: checkout ?BOOLEAN? |
| 598 | ** |
| 599 | ** Return the fully qualified directory name of the current checkout or an |
| 600 | ** empty string if it is not available. |
| 601 | */ |
| 602 | static int checkoutCmd( |
| 603 | Th_Interp *interp, |
| 604 | void *p, |
| 605 | int argc, |
| @@ -608,15 +610,15 @@ | |
| 608 | ){ |
| 609 | if( argc!=1 && argc!=2 ){ |
| 610 | return Th_WrongNumArgs(interp, "checkout ?BOOLEAN?"); |
| 611 | } |
| 612 | if( argc==2 ){ |
| 613 | int openRepository = 0; |
| 614 | if( Th_ToInt(interp, argv[1], argl[1], &openRepository) ){ |
| 615 | return TH_ERROR; |
| 616 | } |
| 617 | if( openRepository ) db_find_and_open_repository(OPEN_OK_NOT_FOUND, 0); |
| 618 | } |
| 619 | Th_SetResult(interp, g.zLocalRoot, -1); |
| 620 | return TH_OK; |
| 621 | } |
| 622 | |
| 623 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -595,11 +595,13 @@ | |
| 595 | |
| 596 | /* |
| 597 | ** TH1 command: checkout ?BOOLEAN? |
| 598 | ** |
| 599 | ** Return the fully qualified directory name of the current checkout or an |
| 600 | ** empty string if it is not available. Optionally, it will attempt to find |
| 601 | ** the current checkout, opening the configuration ("user") database and the |
| 602 | ** repository as necessary, if the boolean argument is non-zero. |
| 603 | */ |
| 604 | static int checkoutCmd( |
| 605 | Th_Interp *interp, |
| 606 | void *p, |
| 607 | int argc, |
| @@ -608,15 +610,15 @@ | |
| 610 | ){ |
| 611 | if( argc!=1 && argc!=2 ){ |
| 612 | return Th_WrongNumArgs(interp, "checkout ?BOOLEAN?"); |
| 613 | } |
| 614 | if( argc==2 ){ |
| 615 | int openCheckout = 0; |
| 616 | if( Th_ToInt(interp, argv[1], argl[1], &openCheckout) ){ |
| 617 | return TH_ERROR; |
| 618 | } |
| 619 | if( openCheckout ) db_open_local(0); |
| 620 | } |
| 621 | Th_SetResult(interp, g.zLocalRoot, -1); |
| 622 | return TH_OK; |
| 623 | } |
| 624 | |
| 625 |
+3
-3
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -475,17 +475,17 @@ | ||
| 475 | 475 | fossil test-th-eval "expr 0+0b" |
| 476 | 476 | test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}} |
| 477 | 477 | |
| 478 | 478 | ############################################################################### |
| 479 | 479 | |
| 480 | -fossil test-th-eval "checkout 1" | |
| 480 | +fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree". | |
| 481 | 481 | test th1-checkout-1 {[string length $RESULT] > 0} |
| 482 | 482 | |
| 483 | 483 | ############################################################################### |
| 484 | 484 | |
| 485 | -fossil test-th-eval "checkout" | |
| 486 | -test th1-checkout-2 {[string length $RESULT] == 0} | |
| 485 | +fossil test-th-eval "checkout"; # NOTE: Assumes running "in tree". | |
| 486 | +test th1-checkout-2 {[string length $RESULT] > 0} | |
| 487 | 487 | |
| 488 | 488 | ############################################################################### |
| 489 | 489 | |
| 490 | 490 | set savedPwd [pwd]; cd / |
| 491 | 491 | fossil test-th-eval "checkout 1" |
| 492 | 492 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -475,17 +475,17 @@ | |
| 475 | fossil test-th-eval "expr 0+0b" |
| 476 | test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}} |
| 477 | |
| 478 | ############################################################################### |
| 479 | |
| 480 | fossil test-th-eval "checkout 1" |
| 481 | test th1-checkout-1 {[string length $RESULT] > 0} |
| 482 | |
| 483 | ############################################################################### |
| 484 | |
| 485 | fossil test-th-eval "checkout" |
| 486 | test th1-checkout-2 {[string length $RESULT] == 0} |
| 487 | |
| 488 | ############################################################################### |
| 489 | |
| 490 | set savedPwd [pwd]; cd / |
| 491 | fossil test-th-eval "checkout 1" |
| 492 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -475,17 +475,17 @@ | |
| 475 | fossil test-th-eval "expr 0+0b" |
| 476 | test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}} |
| 477 | |
| 478 | ############################################################################### |
| 479 | |
| 480 | fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree". |
| 481 | test th1-checkout-1 {[string length $RESULT] > 0} |
| 482 | |
| 483 | ############################################################################### |
| 484 | |
| 485 | fossil test-th-eval "checkout"; # NOTE: Assumes running "in tree". |
| 486 | test th1-checkout-2 {[string length $RESULT] > 0} |
| 487 | |
| 488 | ############################################################################### |
| 489 | |
| 490 | set savedPwd [pwd]; cd / |
| 491 | fossil test-th-eval "checkout 1" |
| 492 |