Fossil SCM

Corrections to the new TH1 'checkout' command and tests.

mistachkin 2014-06-14 22:16 trunk
Commit 589b902edb5565fab257da1ec3d28e6bcfc75317
2 files changed +6 -4 +3 -3
+6 -4
--- src/th_main.c
+++ src/th_main.c
@@ -595,11 +595,13 @@
595595
596596
/*
597597
** TH1 command: checkout ?BOOLEAN?
598598
**
599599
** 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.
601603
*/
602604
static int checkoutCmd(
603605
Th_Interp *interp,
604606
void *p,
605607
int argc,
@@ -608,15 +610,15 @@
608610
){
609611
if( argc!=1 && argc!=2 ){
610612
return Th_WrongNumArgs(interp, "checkout ?BOOLEAN?");
611613
}
612614
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) ){
615617
return TH_ERROR;
616618
}
617
- if( openRepository ) db_find_and_open_repository(OPEN_OK_NOT_FOUND, 0);
619
+ if( openCheckout ) db_open_local(0);
618620
}
619621
Th_SetResult(interp, g.zLocalRoot, -1);
620622
return TH_OK;
621623
}
622624
623625
--- 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 @@
475475
fossil test-th-eval "expr 0+0b"
476476
test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}}
477477
478478
###############################################################################
479479
480
-fossil test-th-eval "checkout 1"
480
+fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree".
481481
test th1-checkout-1 {[string length $RESULT] > 0}
482482
483483
###############################################################################
484484
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}
487487
488488
###############################################################################
489489
490490
set savedPwd [pwd]; cd /
491491
fossil test-th-eval "checkout 1"
492492
--- 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

Keyboard Shortcuts

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