Fossil SCM

Proposed fix for ticket: test-move-repository requires access to original repository

jan.nijtmans 2013-03-04 10:25 UTC trunk
Commit 1b61defd58092e375cc3fd4857138bf874906adc
+14 -16
--- src/db.c
+++ src/db.c
@@ -935,11 +935,11 @@
935935
**
936936
** This routine always opens the user database regardless of whether or
937937
** not the repository database is found. If the _FOSSIL_ or .fos file
938938
** is found, it is attached to the open database connection too.
939939
*/
940
-int db_open_local(void){
940
+int db_open_local(const char *zDbName){
941941
int i, n;
942942
char zPwd[2000];
943943
static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
944944
945945
if( g.localOpen) return 1;
@@ -958,11 +958,11 @@
958958
zPwd[n] = 0;
959959
}
960960
g.zLocalRoot = mprintf("%s/", zPwd);
961961
g.localOpen = 1;
962962
db_open_config(0);
963
- db_open_repository(0);
963
+ db_open_repository(zDbName);
964964
return 1;
965965
}
966966
}
967967
n--;
968968
while( n>0 && zPwd[n]!='/' ){ n--; }
@@ -1051,11 +1051,11 @@
10511051
const char *zRep = find_option("repository", "R", 1);
10521052
if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
10531053
zRep = g.argv[nArgUsed];
10541054
}
10551055
if( zRep==0 ){
1056
- if( db_open_local()==0 ){
1056
+ if( db_open_local(0)==0 ){
10571057
goto rep_not_found;
10581058
}
10591059
zRep = db_repository_filename();
10601060
if( zRep==0 ){
10611061
goto rep_not_found;
@@ -1137,18 +1137,18 @@
11371137
Blob repo;
11381138
char *zRepo;
11391139
if( g.argc!=3 ){
11401140
usage("PATHNAME");
11411141
}
1142
- if( db_open_local()==0 ){
1143
- fossil_fatal("not in a local checkout");
1144
- return;
1145
- }
11461142
file_canonical_name(g.argv[2], &repo, 0);
11471143
zRepo = blob_str(&repo);
11481144
if( file_access(zRepo, 0) ){
11491145
fossil_fatal("no such file: %s", zRepo);
1146
+ }
1147
+ if( db_open_local(zRepo)==0 ){
1148
+ fossil_fatal("not in a local checkout");
1149
+ return;
11501150
}
11511151
db_open_or_attach(zRepo, "test_repo", 0);
11521152
db_lset("repository", blob_str(&repo));
11531153
db_close(1);
11541154
}
@@ -1156,11 +1156,11 @@
11561156
11571157
/*
11581158
** Open the local database. If unable, exit with an error.
11591159
*/
11601160
void db_must_be_within_tree(void){
1161
- if( db_open_local()==0 ){
1161
+ if( db_open_local(0)==0 ){
11621162
fossil_fatal("current directory is not within an open checkout");
11631163
}
11641164
db_open_repository(0);
11651165
db_verify_schema();
11661166
}
@@ -1971,11 +1971,10 @@
19711971
** --nested Allow opening a repository inside an opened checkout
19721972
**
19731973
** See also: close
19741974
*/
19751975
void cmd_open(void){
1976
- Blob path;
19771976
int vid;
19781977
int keepFlag;
19791978
int allowNested;
19801979
static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 };
19811980
@@ -1983,15 +1982,14 @@
19831982
keepFlag = find_option("keep",0,0)!=0;
19841983
allowNested = find_option("nested",0,0)!=0;
19851984
if( g.argc!=3 && g.argc!=4 ){
19861985
usage("REPOSITORY-FILENAME ?VERSION?");
19871986
}
1988
- if( !allowNested && db_open_local() ){
1987
+ if( !allowNested && db_open_local(0) ){
19891988
fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
19901989
}
1991
- file_canonical_name(g.argv[2], &path, 0);
1992
- db_open_repository(blob_str(&path));
1990
+ db_open_repository(g.argv[2]);
19931991
#if defined(_WIN32) || defined(__CYGWIN__)
19941992
# define LOCALDB_NAME "./_FOSSIL_"
19951993
#else
19961994
# define LOCALDB_NAME "./.fslckout"
19971995
#endif
@@ -1999,13 +1997,13 @@
19991997
#ifdef FOSSIL_LOCAL_WAL
20001998
"COMMIT; PRAGMA journal_mode=WAL; BEGIN;",
20011999
#endif
20022000
(char*)0);
20032001
db_delete_on_failure(LOCALDB_NAME);
2004
- db_open_local();
2002
+ db_open_local(0);
20052003
db_lset("repository", g.argv[2]);
2006
- db_record_repository_filename(blob_str(&path));
2004
+ db_record_repository_filename(g.argv[2]);
20072005
vid = db_int(0, "SELECT pid FROM plink y"
20082006
" WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)");
20092007
if( vid==0 ){
20102008
db_lset_int("checkout", 1);
20112009
}else{
@@ -2349,11 +2347,11 @@
23492347
}
23502348
if( unsetFlag && g.argc!=3 ){
23512349
usage("PROPERTY ?-global?");
23522350
}
23532351
if( g.argc==2 ){
2354
- int openLocal = db_open_local();
2352
+ int openLocal = db_open_local(0);
23552353
for(i=0; ctrlSettings[i].name; i++){
23562354
print_setting(&ctrlSettings[i], openLocal);
23572355
}
23582356
}else if( g.argc==3 || g.argc==4 ){
23592357
const char *zName = g.argv[2];
@@ -2373,11 +2371,11 @@
23732371
db_unset(ctrlSettings[i].name, globalFlag);
23742372
}else if( g.argc==4 ){
23752373
db_set(ctrlSettings[i].name, g.argv[3], globalFlag);
23762374
}else{
23772375
isManifest = 0;
2378
- print_setting(&ctrlSettings[i], db_open_local());
2376
+ print_setting(&ctrlSettings[i], db_open_local(0));
23792377
}
23802378
if( isManifest && g.localOpen ){
23812379
manifest_to_disk(db_lget_int("checkout", 0));
23822380
}
23832381
}else{
23842382
--- src/db.c
+++ src/db.c
@@ -935,11 +935,11 @@
935 **
936 ** This routine always opens the user database regardless of whether or
937 ** not the repository database is found. If the _FOSSIL_ or .fos file
938 ** is found, it is attached to the open database connection too.
939 */
940 int db_open_local(void){
941 int i, n;
942 char zPwd[2000];
943 static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
944
945 if( g.localOpen) return 1;
@@ -958,11 +958,11 @@
958 zPwd[n] = 0;
959 }
960 g.zLocalRoot = mprintf("%s/", zPwd);
961 g.localOpen = 1;
962 db_open_config(0);
963 db_open_repository(0);
964 return 1;
965 }
966 }
967 n--;
968 while( n>0 && zPwd[n]!='/' ){ n--; }
@@ -1051,11 +1051,11 @@
1051 const char *zRep = find_option("repository", "R", 1);
1052 if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
1053 zRep = g.argv[nArgUsed];
1054 }
1055 if( zRep==0 ){
1056 if( db_open_local()==0 ){
1057 goto rep_not_found;
1058 }
1059 zRep = db_repository_filename();
1060 if( zRep==0 ){
1061 goto rep_not_found;
@@ -1137,18 +1137,18 @@
1137 Blob repo;
1138 char *zRepo;
1139 if( g.argc!=3 ){
1140 usage("PATHNAME");
1141 }
1142 if( db_open_local()==0 ){
1143 fossil_fatal("not in a local checkout");
1144 return;
1145 }
1146 file_canonical_name(g.argv[2], &repo, 0);
1147 zRepo = blob_str(&repo);
1148 if( file_access(zRepo, 0) ){
1149 fossil_fatal("no such file: %s", zRepo);
 
 
 
 
1150 }
1151 db_open_or_attach(zRepo, "test_repo", 0);
1152 db_lset("repository", blob_str(&repo));
1153 db_close(1);
1154 }
@@ -1156,11 +1156,11 @@
1156
1157 /*
1158 ** Open the local database. If unable, exit with an error.
1159 */
1160 void db_must_be_within_tree(void){
1161 if( db_open_local()==0 ){
1162 fossil_fatal("current directory is not within an open checkout");
1163 }
1164 db_open_repository(0);
1165 db_verify_schema();
1166 }
@@ -1971,11 +1971,10 @@
1971 ** --nested Allow opening a repository inside an opened checkout
1972 **
1973 ** See also: close
1974 */
1975 void cmd_open(void){
1976 Blob path;
1977 int vid;
1978 int keepFlag;
1979 int allowNested;
1980 static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 };
1981
@@ -1983,15 +1982,14 @@
1983 keepFlag = find_option("keep",0,0)!=0;
1984 allowNested = find_option("nested",0,0)!=0;
1985 if( g.argc!=3 && g.argc!=4 ){
1986 usage("REPOSITORY-FILENAME ?VERSION?");
1987 }
1988 if( !allowNested && db_open_local() ){
1989 fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
1990 }
1991 file_canonical_name(g.argv[2], &path, 0);
1992 db_open_repository(blob_str(&path));
1993 #if defined(_WIN32) || defined(__CYGWIN__)
1994 # define LOCALDB_NAME "./_FOSSIL_"
1995 #else
1996 # define LOCALDB_NAME "./.fslckout"
1997 #endif
@@ -1999,13 +1997,13 @@
1999 #ifdef FOSSIL_LOCAL_WAL
2000 "COMMIT; PRAGMA journal_mode=WAL; BEGIN;",
2001 #endif
2002 (char*)0);
2003 db_delete_on_failure(LOCALDB_NAME);
2004 db_open_local();
2005 db_lset("repository", g.argv[2]);
2006 db_record_repository_filename(blob_str(&path));
2007 vid = db_int(0, "SELECT pid FROM plink y"
2008 " WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)");
2009 if( vid==0 ){
2010 db_lset_int("checkout", 1);
2011 }else{
@@ -2349,11 +2347,11 @@
2349 }
2350 if( unsetFlag && g.argc!=3 ){
2351 usage("PROPERTY ?-global?");
2352 }
2353 if( g.argc==2 ){
2354 int openLocal = db_open_local();
2355 for(i=0; ctrlSettings[i].name; i++){
2356 print_setting(&ctrlSettings[i], openLocal);
2357 }
2358 }else if( g.argc==3 || g.argc==4 ){
2359 const char *zName = g.argv[2];
@@ -2373,11 +2371,11 @@
2373 db_unset(ctrlSettings[i].name, globalFlag);
2374 }else if( g.argc==4 ){
2375 db_set(ctrlSettings[i].name, g.argv[3], globalFlag);
2376 }else{
2377 isManifest = 0;
2378 print_setting(&ctrlSettings[i], db_open_local());
2379 }
2380 if( isManifest && g.localOpen ){
2381 manifest_to_disk(db_lget_int("checkout", 0));
2382 }
2383 }else{
2384
--- src/db.c
+++ src/db.c
@@ -935,11 +935,11 @@
935 **
936 ** This routine always opens the user database regardless of whether or
937 ** not the repository database is found. If the _FOSSIL_ or .fos file
938 ** is found, it is attached to the open database connection too.
939 */
940 int db_open_local(const char *zDbName){
941 int i, n;
942 char zPwd[2000];
943 static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
944
945 if( g.localOpen) return 1;
@@ -958,11 +958,11 @@
958 zPwd[n] = 0;
959 }
960 g.zLocalRoot = mprintf("%s/", zPwd);
961 g.localOpen = 1;
962 db_open_config(0);
963 db_open_repository(zDbName);
964 return 1;
965 }
966 }
967 n--;
968 while( n>0 && zPwd[n]!='/' ){ n--; }
@@ -1051,11 +1051,11 @@
1051 const char *zRep = find_option("repository", "R", 1);
1052 if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
1053 zRep = g.argv[nArgUsed];
1054 }
1055 if( zRep==0 ){
1056 if( db_open_local(0)==0 ){
1057 goto rep_not_found;
1058 }
1059 zRep = db_repository_filename();
1060 if( zRep==0 ){
1061 goto rep_not_found;
@@ -1137,18 +1137,18 @@
1137 Blob repo;
1138 char *zRepo;
1139 if( g.argc!=3 ){
1140 usage("PATHNAME");
1141 }
 
 
 
 
1142 file_canonical_name(g.argv[2], &repo, 0);
1143 zRepo = blob_str(&repo);
1144 if( file_access(zRepo, 0) ){
1145 fossil_fatal("no such file: %s", zRepo);
1146 }
1147 if( db_open_local(zRepo)==0 ){
1148 fossil_fatal("not in a local checkout");
1149 return;
1150 }
1151 db_open_or_attach(zRepo, "test_repo", 0);
1152 db_lset("repository", blob_str(&repo));
1153 db_close(1);
1154 }
@@ -1156,11 +1156,11 @@
1156
1157 /*
1158 ** Open the local database. If unable, exit with an error.
1159 */
1160 void db_must_be_within_tree(void){
1161 if( db_open_local(0)==0 ){
1162 fossil_fatal("current directory is not within an open checkout");
1163 }
1164 db_open_repository(0);
1165 db_verify_schema();
1166 }
@@ -1971,11 +1971,10 @@
1971 ** --nested Allow opening a repository inside an opened checkout
1972 **
1973 ** See also: close
1974 */
1975 void cmd_open(void){
 
1976 int vid;
1977 int keepFlag;
1978 int allowNested;
1979 static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 };
1980
@@ -1983,15 +1982,14 @@
1982 keepFlag = find_option("keep",0,0)!=0;
1983 allowNested = find_option("nested",0,0)!=0;
1984 if( g.argc!=3 && g.argc!=4 ){
1985 usage("REPOSITORY-FILENAME ?VERSION?");
1986 }
1987 if( !allowNested && db_open_local(0) ){
1988 fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
1989 }
1990 db_open_repository(g.argv[2]);
 
1991 #if defined(_WIN32) || defined(__CYGWIN__)
1992 # define LOCALDB_NAME "./_FOSSIL_"
1993 #else
1994 # define LOCALDB_NAME "./.fslckout"
1995 #endif
@@ -1999,13 +1997,13 @@
1997 #ifdef FOSSIL_LOCAL_WAL
1998 "COMMIT; PRAGMA journal_mode=WAL; BEGIN;",
1999 #endif
2000 (char*)0);
2001 db_delete_on_failure(LOCALDB_NAME);
2002 db_open_local(0);
2003 db_lset("repository", g.argv[2]);
2004 db_record_repository_filename(g.argv[2]);
2005 vid = db_int(0, "SELECT pid FROM plink y"
2006 " WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)");
2007 if( vid==0 ){
2008 db_lset_int("checkout", 1);
2009 }else{
@@ -2349,11 +2347,11 @@
2347 }
2348 if( unsetFlag && g.argc!=3 ){
2349 usage("PROPERTY ?-global?");
2350 }
2351 if( g.argc==2 ){
2352 int openLocal = db_open_local(0);
2353 for(i=0; ctrlSettings[i].name; i++){
2354 print_setting(&ctrlSettings[i], openLocal);
2355 }
2356 }else if( g.argc==3 || g.argc==4 ){
2357 const char *zName = g.argv[2];
@@ -2373,11 +2371,11 @@
2371 db_unset(ctrlSettings[i].name, globalFlag);
2372 }else if( g.argc==4 ){
2373 db_set(ctrlSettings[i].name, g.argv[3], globalFlag);
2374 }else{
2375 isManifest = 0;
2376 print_setting(&ctrlSettings[i], db_open_local(0));
2377 }
2378 if( isManifest && g.localOpen ){
2379 manifest_to_disk(db_lget_int("checkout", 0));
2380 }
2381 }else{
2382
+1 -1
--- src/doc.c
+++ src/doc.c
@@ -395,11 +395,11 @@
395395
}
396396
}else{
397397
goto doc_not_found;
398398
}
399399
}
400
- if( fossil_strcmp(zBaseline,"ckout")==0 && db_open_local()==0 ){
400
+ if( fossil_strcmp(zBaseline,"ckout")==0 && db_open_local(0)==0 ){
401401
sqlite3_snprintf(sizeof(zBaseline), zBaseline, "tip");
402402
}
403403
if( fossil_strcmp(zBaseline,"ckout")==0 ){
404404
/* Read from the local checkout */
405405
char *zFullpath;
406406
--- src/doc.c
+++ src/doc.c
@@ -395,11 +395,11 @@
395 }
396 }else{
397 goto doc_not_found;
398 }
399 }
400 if( fossil_strcmp(zBaseline,"ckout")==0 && db_open_local()==0 ){
401 sqlite3_snprintf(sizeof(zBaseline), zBaseline, "tip");
402 }
403 if( fossil_strcmp(zBaseline,"ckout")==0 ){
404 /* Read from the local checkout */
405 char *zFullpath;
406
--- src/doc.c
+++ src/doc.c
@@ -395,11 +395,11 @@
395 }
396 }else{
397 goto doc_not_found;
398 }
399 }
400 if( fossil_strcmp(zBaseline,"ckout")==0 && db_open_local(0)==0 ){
401 sqlite3_snprintf(sizeof(zBaseline), zBaseline, "tip");
402 }
403 if( fossil_strcmp(zBaseline,"ckout")==0 ){
404 /* Read from the local checkout */
405 char *zFullpath;
406
--- src/json_status.c
+++ src/json_status.c
@@ -47,11 +47,11 @@
4747
cson_object * tmpO;
4848
char * zTmp;
4949
i64 iMtime;
5050
cson_array * aFiles;
5151
52
- if(!db_open_local()){
52
+ if(!db_open_local(0)){
5353
json_set_err(FSL_JSON_E_DB_NEEDS_CHECKOUT, NULL);
5454
return NULL;
5555
}
5656
oPay = cson_new_object();
5757
cson_object_set(oPay, "repository",
5858
--- src/json_status.c
+++ src/json_status.c
@@ -47,11 +47,11 @@
47 cson_object * tmpO;
48 char * zTmp;
49 i64 iMtime;
50 cson_array * aFiles;
51
52 if(!db_open_local()){
53 json_set_err(FSL_JSON_E_DB_NEEDS_CHECKOUT, NULL);
54 return NULL;
55 }
56 oPay = cson_new_object();
57 cson_object_set(oPay, "repository",
58
--- src/json_status.c
+++ src/json_status.c
@@ -47,11 +47,11 @@
47 cson_object * tmpO;
48 char * zTmp;
49 i64 iMtime;
50 cson_array * aFiles;
51
52 if(!db_open_local(0)){
53 json_set_err(FSL_JSON_E_DB_NEEDS_CHECKOUT, NULL);
54 return NULL;
55 }
56 oPay = cson_new_object();
57 cson_object_set(oPay, "repository",
58
+1 -1
--- src/setup.c
+++ src/setup.c
@@ -1175,11 +1175,11 @@
11751175
if( !g.perm.Setup ){
11761176
login_needed();
11771177
}
11781178
11791179
style_header("Settings");
1180
- db_open_local();
1180
+ db_open_local(0);
11811181
db_begin_transaction();
11821182
@ <p>This page provides a simple interface to the "fossil setting" command.
11831183
@ See the "fossil help setting" output below for further information on
11841184
@ the meaning of each setting.</p><hr />
11851185
@ <form action="%s(g.zTop)/setup_settings" method="post"><div>
11861186
--- src/setup.c
+++ src/setup.c
@@ -1175,11 +1175,11 @@
1175 if( !g.perm.Setup ){
1176 login_needed();
1177 }
1178
1179 style_header("Settings");
1180 db_open_local();
1181 db_begin_transaction();
1182 @ <p>This page provides a simple interface to the "fossil setting" command.
1183 @ See the "fossil help setting" output below for further information on
1184 @ the meaning of each setting.</p><hr />
1185 @ <form action="%s(g.zTop)/setup_settings" method="post"><div>
1186
--- src/setup.c
+++ src/setup.c
@@ -1175,11 +1175,11 @@
1175 if( !g.perm.Setup ){
1176 login_needed();
1177 }
1178
1179 style_header("Settings");
1180 db_open_local(0);
1181 db_begin_transaction();
1182 @ <p>This page provides a simple interface to the "fossil setting" command.
1183 @ See the "fossil help setting" output below for further information on
1184 @ the meaning of each setting.</p><hr />
1185 @ <form action="%s(g.zTop)/setup_settings" method="post"><div>
1186

Keyboard Shortcuts

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