Fossil SCM

Centralize the handling of opening the configuration database and repository on behalf of TH1.

mistachkin 2014-06-11 00:51 trunk
Commit 9773eba5fe037b50e97465dd0dae834d4b796c0a
1 file changed +16 -6
+16 -6
--- src/th_main.c
+++ src/th_main.c
@@ -971,10 +971,23 @@
971971
"synchronous requests are not yet implemented", 0, 0);
972972
blob_reset(&payload);
973973
return TH_ERROR;
974974
}
975975
}
976
+
977
+/*
978
+** Attempts to open the configuration ("user") database. Optionally, also
979
+** attempts to try to find the repository and open it.
980
+*/
981
+void Th_OpenConfig(
982
+ int openRepository
983
+){
984
+ if( openRepository ){
985
+ db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
986
+ }
987
+ db_open_config(0);
988
+}
976989
977990
/*
978991
** Make sure the interpreter has been initialized. Initialize it if
979992
** it has not been already.
980993
**
@@ -1021,12 +1034,11 @@
10211034
** This function uses several settings which may be defined in the
10221035
** repository and/or the global configuration. Since the caller
10231036
** passed a non-zero value for the needConfig parameter, make sure
10241037
** the necessary database connections are open prior to continuing.
10251038
*/
1026
- db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
1027
- db_open_config(0);
1039
+ Th_OpenConfig(1);
10281040
}
10291041
if( forceReset || forceTcl || g.interp==0 ){
10301042
int created = 0;
10311043
int i;
10321044
if( g.interp==0 ){
@@ -1250,12 +1262,11 @@
12501262
*/
12511263
void test_th_render(void){
12521264
Blob in;
12531265
Th_InitTraceLog();
12541266
if( find_option("th-open-config", 0, 0)!=0 ){
1255
- db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
1256
- db_open_config(0);
1267
+ Th_OpenConfig(1);
12571268
}
12581269
if( g.argc<3 ){
12591270
usage("FILE");
12601271
}
12611272
blob_zero(&in);
@@ -1270,12 +1281,11 @@
12701281
void test_th_eval(void){
12711282
int rc;
12721283
const char *zRc;
12731284
Th_InitTraceLog();
12741285
if( find_option("th-open-config", 0, 0)!=0 ){
1275
- db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
1276
- db_open_config(0);
1286
+ Th_OpenConfig(1);
12771287
}
12781288
if( g.argc!=3 ){
12791289
usage("script");
12801290
}
12811291
Th_FossilInit(TH_INIT_DEFAULT);
12821292
--- src/th_main.c
+++ src/th_main.c
@@ -971,10 +971,23 @@
971 "synchronous requests are not yet implemented", 0, 0);
972 blob_reset(&payload);
973 return TH_ERROR;
974 }
975 }
 
 
 
 
 
 
 
 
 
 
 
 
 
976
977 /*
978 ** Make sure the interpreter has been initialized. Initialize it if
979 ** it has not been already.
980 **
@@ -1021,12 +1034,11 @@
1021 ** This function uses several settings which may be defined in the
1022 ** repository and/or the global configuration. Since the caller
1023 ** passed a non-zero value for the needConfig parameter, make sure
1024 ** the necessary database connections are open prior to continuing.
1025 */
1026 db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
1027 db_open_config(0);
1028 }
1029 if( forceReset || forceTcl || g.interp==0 ){
1030 int created = 0;
1031 int i;
1032 if( g.interp==0 ){
@@ -1250,12 +1262,11 @@
1250 */
1251 void test_th_render(void){
1252 Blob in;
1253 Th_InitTraceLog();
1254 if( find_option("th-open-config", 0, 0)!=0 ){
1255 db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
1256 db_open_config(0);
1257 }
1258 if( g.argc<3 ){
1259 usage("FILE");
1260 }
1261 blob_zero(&in);
@@ -1270,12 +1281,11 @@
1270 void test_th_eval(void){
1271 int rc;
1272 const char *zRc;
1273 Th_InitTraceLog();
1274 if( find_option("th-open-config", 0, 0)!=0 ){
1275 db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
1276 db_open_config(0);
1277 }
1278 if( g.argc!=3 ){
1279 usage("script");
1280 }
1281 Th_FossilInit(TH_INIT_DEFAULT);
1282
--- src/th_main.c
+++ src/th_main.c
@@ -971,10 +971,23 @@
971 "synchronous requests are not yet implemented", 0, 0);
972 blob_reset(&payload);
973 return TH_ERROR;
974 }
975 }
976
977 /*
978 ** Attempts to open the configuration ("user") database. Optionally, also
979 ** attempts to try to find the repository and open it.
980 */
981 void Th_OpenConfig(
982 int openRepository
983 ){
984 if( openRepository ){
985 db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
986 }
987 db_open_config(0);
988 }
989
990 /*
991 ** Make sure the interpreter has been initialized. Initialize it if
992 ** it has not been already.
993 **
@@ -1021,12 +1034,11 @@
1034 ** This function uses several settings which may be defined in the
1035 ** repository and/or the global configuration. Since the caller
1036 ** passed a non-zero value for the needConfig parameter, make sure
1037 ** the necessary database connections are open prior to continuing.
1038 */
1039 Th_OpenConfig(1);
 
1040 }
1041 if( forceReset || forceTcl || g.interp==0 ){
1042 int created = 0;
1043 int i;
1044 if( g.interp==0 ){
@@ -1250,12 +1262,11 @@
1262 */
1263 void test_th_render(void){
1264 Blob in;
1265 Th_InitTraceLog();
1266 if( find_option("th-open-config", 0, 0)!=0 ){
1267 Th_OpenConfig(1);
 
1268 }
1269 if( g.argc<3 ){
1270 usage("FILE");
1271 }
1272 blob_zero(&in);
@@ -1270,12 +1281,11 @@
1281 void test_th_eval(void){
1282 int rc;
1283 const char *zRc;
1284 Th_InitTraceLog();
1285 if( find_option("th-open-config", 0, 0)!=0 ){
1286 Th_OpenConfig(1);
 
1287 }
1288 if( g.argc!=3 ){
1289 usage("script");
1290 }
1291 Th_FossilInit(TH_INIT_DEFAULT);
1292

Keyboard Shortcuts

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