| | @@ -935,11 +935,11 @@ |
| 935 | 935 | ** |
| 936 | 936 | ** This routine always opens the user database regardless of whether or |
| 937 | 937 | ** not the repository database is found. If the _FOSSIL_ or .fos file |
| 938 | 938 | ** is found, it is attached to the open database connection too. |
| 939 | 939 | */ |
| 940 | | -int db_open_local(void){ |
| 940 | +int db_open_local(const char *zDbName){ |
| 941 | 941 | int i, n; |
| 942 | 942 | char zPwd[2000]; |
| 943 | 943 | static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" }; |
| 944 | 944 | |
| 945 | 945 | if( g.localOpen) return 1; |
| | @@ -958,11 +958,11 @@ |
| 958 | 958 | zPwd[n] = 0; |
| 959 | 959 | } |
| 960 | 960 | g.zLocalRoot = mprintf("%s/", zPwd); |
| 961 | 961 | g.localOpen = 1; |
| 962 | 962 | db_open_config(0); |
| 963 | | - db_open_repository(0); |
| 963 | + db_open_repository(zDbName); |
| 964 | 964 | return 1; |
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | 967 | n--; |
| 968 | 968 | while( n>0 && zPwd[n]!='/' ){ n--; } |
| | @@ -1051,11 +1051,11 @@ |
| 1051 | 1051 | const char *zRep = find_option("repository", "R", 1); |
| 1052 | 1052 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 1053 | 1053 | zRep = g.argv[nArgUsed]; |
| 1054 | 1054 | } |
| 1055 | 1055 | if( zRep==0 ){ |
| 1056 | | - if( db_open_local()==0 ){ |
| 1056 | + if( db_open_local(0)==0 ){ |
| 1057 | 1057 | goto rep_not_found; |
| 1058 | 1058 | } |
| 1059 | 1059 | zRep = db_repository_filename(); |
| 1060 | 1060 | if( zRep==0 ){ |
| 1061 | 1061 | goto rep_not_found; |
| | @@ -1137,18 +1137,18 @@ |
| 1137 | 1137 | Blob repo; |
| 1138 | 1138 | char *zRepo; |
| 1139 | 1139 | if( g.argc!=3 ){ |
| 1140 | 1140 | usage("PATHNAME"); |
| 1141 | 1141 | } |
| 1142 | | - if( db_open_local()==0 ){ |
| 1143 | | - fossil_fatal("not in a local checkout"); |
| 1144 | | - return; |
| 1145 | | - } |
| 1146 | 1142 | file_canonical_name(g.argv[2], &repo, 0); |
| 1147 | 1143 | zRepo = blob_str(&repo); |
| 1148 | 1144 | if( file_access(zRepo, 0) ){ |
| 1149 | 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 | 1150 | } |
| 1151 | 1151 | db_open_or_attach(zRepo, "test_repo", 0); |
| 1152 | 1152 | db_lset("repository", blob_str(&repo)); |
| 1153 | 1153 | db_close(1); |
| 1154 | 1154 | } |
| | @@ -1156,11 +1156,11 @@ |
| 1156 | 1156 | |
| 1157 | 1157 | /* |
| 1158 | 1158 | ** Open the local database. If unable, exit with an error. |
| 1159 | 1159 | */ |
| 1160 | 1160 | void db_must_be_within_tree(void){ |
| 1161 | | - if( db_open_local()==0 ){ |
| 1161 | + if( db_open_local(0)==0 ){ |
| 1162 | 1162 | fossil_fatal("current directory is not within an open checkout"); |
| 1163 | 1163 | } |
| 1164 | 1164 | db_open_repository(0); |
| 1165 | 1165 | db_verify_schema(); |
| 1166 | 1166 | } |
| | @@ -1971,11 +1971,10 @@ |
| 1971 | 1971 | ** --nested Allow opening a repository inside an opened checkout |
| 1972 | 1972 | ** |
| 1973 | 1973 | ** See also: close |
| 1974 | 1974 | */ |
| 1975 | 1975 | void cmd_open(void){ |
| 1976 | | - Blob path; |
| 1977 | 1976 | int vid; |
| 1978 | 1977 | int keepFlag; |
| 1979 | 1978 | int allowNested; |
| 1980 | 1979 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 }; |
| 1981 | 1980 | |
| | @@ -1983,15 +1982,14 @@ |
| 1983 | 1982 | keepFlag = find_option("keep",0,0)!=0; |
| 1984 | 1983 | allowNested = find_option("nested",0,0)!=0; |
| 1985 | 1984 | if( g.argc!=3 && g.argc!=4 ){ |
| 1986 | 1985 | usage("REPOSITORY-FILENAME ?VERSION?"); |
| 1987 | 1986 | } |
| 1988 | | - if( !allowNested && db_open_local() ){ |
| 1987 | + if( !allowNested && db_open_local(0) ){ |
| 1989 | 1988 | fossil_panic("already within an open tree rooted at %s", g.zLocalRoot); |
| 1990 | 1989 | } |
| 1991 | | - file_canonical_name(g.argv[2], &path, 0); |
| 1992 | | - db_open_repository(blob_str(&path)); |
| 1990 | + db_open_repository(g.argv[2]); |
| 1993 | 1991 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 1994 | 1992 | # define LOCALDB_NAME "./_FOSSIL_" |
| 1995 | 1993 | #else |
| 1996 | 1994 | # define LOCALDB_NAME "./.fslckout" |
| 1997 | 1995 | #endif |
| | @@ -1999,13 +1997,13 @@ |
| 1999 | 1997 | #ifdef FOSSIL_LOCAL_WAL |
| 2000 | 1998 | "COMMIT; PRAGMA journal_mode=WAL; BEGIN;", |
| 2001 | 1999 | #endif |
| 2002 | 2000 | (char*)0); |
| 2003 | 2001 | db_delete_on_failure(LOCALDB_NAME); |
| 2004 | | - db_open_local(); |
| 2002 | + db_open_local(0); |
| 2005 | 2003 | db_lset("repository", g.argv[2]); |
| 2006 | | - db_record_repository_filename(blob_str(&path)); |
| 2004 | + db_record_repository_filename(g.argv[2]); |
| 2007 | 2005 | vid = db_int(0, "SELECT pid FROM plink y" |
| 2008 | 2006 | " WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)"); |
| 2009 | 2007 | if( vid==0 ){ |
| 2010 | 2008 | db_lset_int("checkout", 1); |
| 2011 | 2009 | }else{ |
| | @@ -2349,11 +2347,11 @@ |
| 2349 | 2347 | } |
| 2350 | 2348 | if( unsetFlag && g.argc!=3 ){ |
| 2351 | 2349 | usage("PROPERTY ?-global?"); |
| 2352 | 2350 | } |
| 2353 | 2351 | if( g.argc==2 ){ |
| 2354 | | - int openLocal = db_open_local(); |
| 2352 | + int openLocal = db_open_local(0); |
| 2355 | 2353 | for(i=0; ctrlSettings[i].name; i++){ |
| 2356 | 2354 | print_setting(&ctrlSettings[i], openLocal); |
| 2357 | 2355 | } |
| 2358 | 2356 | }else if( g.argc==3 || g.argc==4 ){ |
| 2359 | 2357 | const char *zName = g.argv[2]; |
| | @@ -2373,11 +2371,11 @@ |
| 2373 | 2371 | db_unset(ctrlSettings[i].name, globalFlag); |
| 2374 | 2372 | }else if( g.argc==4 ){ |
| 2375 | 2373 | db_set(ctrlSettings[i].name, g.argv[3], globalFlag); |
| 2376 | 2374 | }else{ |
| 2377 | 2375 | isManifest = 0; |
| 2378 | | - print_setting(&ctrlSettings[i], db_open_local()); |
| 2376 | + print_setting(&ctrlSettings[i], db_open_local(0)); |
| 2379 | 2377 | } |
| 2380 | 2378 | if( isManifest && g.localOpen ){ |
| 2381 | 2379 | manifest_to_disk(db_lget_int("checkout", 0)); |
| 2382 | 2380 | } |
| 2383 | 2381 | }else{ |
| 2384 | 2382 | |