| | @@ -929,11 +929,11 @@ |
| 929 | 929 | ** |
| 930 | 930 | ** This routine always opens the user database regardless of whether or |
| 931 | 931 | ** not the repository database is found. If the _FOSSIL_ or .fslckout file |
| 932 | 932 | ** is found, it is attached to the open database connection too. |
| 933 | 933 | */ |
| 934 | | -int db_open_local(void){ |
| 934 | +int db_open_local(const char *zDbName){ |
| 935 | 935 | int i, n; |
| 936 | 936 | char zPwd[2000]; |
| 937 | 937 | static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" }; |
| 938 | 938 | |
| 939 | 939 | if( g.localOpen) return 1; |
| | @@ -951,11 +951,11 @@ |
| 951 | 951 | zPwd[n] = 0; |
| 952 | 952 | } |
| 953 | 953 | g.zLocalRoot = mprintf("%s/", zPwd); |
| 954 | 954 | g.localOpen = 1; |
| 955 | 955 | db_open_config(0); |
| 956 | | - db_open_repository(0); |
| 956 | + db_open_repository(zDbName); |
| 957 | 957 | return 1; |
| 958 | 958 | } |
| 959 | 959 | } |
| 960 | 960 | n--; |
| 961 | 961 | while( n>0 && zPwd[n]!='/' ){ n--; } |
| | @@ -1044,11 +1044,11 @@ |
| 1044 | 1044 | const char *zRep = find_option("repository", "R", 1); |
| 1045 | 1045 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 1046 | 1046 | zRep = g.argv[nArgUsed]; |
| 1047 | 1047 | } |
| 1048 | 1048 | if( zRep==0 ){ |
| 1049 | | - if( db_open_local()==0 ){ |
| 1049 | + if( db_open_local(0)==0 ){ |
| 1050 | 1050 | goto rep_not_found; |
| 1051 | 1051 | } |
| 1052 | 1052 | zRep = db_repository_filename(); |
| 1053 | 1053 | if( zRep==0 ){ |
| 1054 | 1054 | goto rep_not_found; |
| | @@ -1130,18 +1130,18 @@ |
| 1130 | 1130 | Blob repo; |
| 1131 | 1131 | char *zRepo; |
| 1132 | 1132 | if( g.argc!=3 ){ |
| 1133 | 1133 | usage("PATHNAME"); |
| 1134 | 1134 | } |
| 1135 | | - if( db_open_local()==0 ){ |
| 1136 | | - fossil_fatal("not in a local checkout"); |
| 1137 | | - return; |
| 1138 | | - } |
| 1139 | 1135 | file_canonical_name(g.argv[2], &repo, 0); |
| 1140 | 1136 | zRepo = blob_str(&repo); |
| 1141 | 1137 | if( file_access(zRepo, 0) ){ |
| 1142 | 1138 | fossil_fatal("no such file: %s", zRepo); |
| 1139 | + } |
| 1140 | + if( db_open_local(zRepo)==0 ){ |
| 1141 | + fossil_fatal("not in a local checkout"); |
| 1142 | + return; |
| 1143 | 1143 | } |
| 1144 | 1144 | db_open_or_attach(zRepo, "test_repo", 0); |
| 1145 | 1145 | db_lset("repository", blob_str(&repo)); |
| 1146 | 1146 | db_close(1); |
| 1147 | 1147 | } |
| | @@ -1149,11 +1149,11 @@ |
| 1149 | 1149 | |
| 1150 | 1150 | /* |
| 1151 | 1151 | ** Open the local database. If unable, exit with an error. |
| 1152 | 1152 | */ |
| 1153 | 1153 | void db_must_be_within_tree(void){ |
| 1154 | | - if( db_open_local()==0 ){ |
| 1154 | + if( db_open_local(0)==0 ){ |
| 1155 | 1155 | fossil_fatal("current directory is not within an open checkout"); |
| 1156 | 1156 | } |
| 1157 | 1157 | db_open_repository(0); |
| 1158 | 1158 | db_verify_schema(); |
| 1159 | 1159 | } |
| | @@ -1964,11 +1964,10 @@ |
| 1964 | 1964 | ** --nested Allow opening a repository inside an opened checkout |
| 1965 | 1965 | ** |
| 1966 | 1966 | ** See also: close |
| 1967 | 1967 | */ |
| 1968 | 1968 | void cmd_open(void){ |
| 1969 | | - Blob path; |
| 1970 | 1969 | int vid; |
| 1971 | 1970 | int keepFlag; |
| 1972 | 1971 | int allowNested; |
| 1973 | 1972 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 }; |
| 1974 | 1973 | |
| | @@ -1976,15 +1975,14 @@ |
| 1976 | 1975 | keepFlag = find_option("keep",0,0)!=0; |
| 1977 | 1976 | allowNested = find_option("nested",0,0)!=0; |
| 1978 | 1977 | if( g.argc!=3 && g.argc!=4 ){ |
| 1979 | 1978 | usage("REPOSITORY-FILENAME ?VERSION?"); |
| 1980 | 1979 | } |
| 1981 | | - if( !allowNested && db_open_local() ){ |
| 1980 | + if( !allowNested && db_open_local(0) ){ |
| 1982 | 1981 | fossil_panic("already within an open tree rooted at %s", g.zLocalRoot); |
| 1983 | 1982 | } |
| 1984 | | - file_canonical_name(g.argv[2], &path, 0); |
| 1985 | | - db_open_repository(blob_str(&path)); |
| 1983 | + db_open_repository(g.argv[2]); |
| 1986 | 1984 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 1987 | 1985 | # define LOCALDB_NAME "./_FOSSIL_" |
| 1988 | 1986 | #else |
| 1989 | 1987 | # define LOCALDB_NAME "./.fslckout" |
| 1990 | 1988 | #endif |
| | @@ -1992,13 +1990,13 @@ |
| 1992 | 1990 | #ifdef FOSSIL_LOCAL_WAL |
| 1993 | 1991 | "COMMIT; PRAGMA journal_mode=WAL; BEGIN;", |
| 1994 | 1992 | #endif |
| 1995 | 1993 | (char*)0); |
| 1996 | 1994 | db_delete_on_failure(LOCALDB_NAME); |
| 1997 | | - db_open_local(); |
| 1995 | + db_open_local(0); |
| 1998 | 1996 | db_lset("repository", g.argv[2]); |
| 1999 | | - db_record_repository_filename(blob_str(&path)); |
| 1997 | + db_record_repository_filename(g.argv[2]); |
| 2000 | 1998 | vid = db_int(0, "SELECT pid FROM plink y" |
| 2001 | 1999 | " WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)"); |
| 2002 | 2000 | if( vid==0 ){ |
| 2003 | 2001 | db_lset_int("checkout", 1); |
| 2004 | 2002 | }else{ |
| | @@ -2342,11 +2340,11 @@ |
| 2342 | 2340 | } |
| 2343 | 2341 | if( unsetFlag && g.argc!=3 ){ |
| 2344 | 2342 | usage("PROPERTY ?-global?"); |
| 2345 | 2343 | } |
| 2346 | 2344 | if( g.argc==2 ){ |
| 2347 | | - int openLocal = db_open_local(); |
| 2345 | + int openLocal = db_open_local(0); |
| 2348 | 2346 | for(i=0; ctrlSettings[i].name; i++){ |
| 2349 | 2347 | print_setting(&ctrlSettings[i], openLocal); |
| 2350 | 2348 | } |
| 2351 | 2349 | }else if( g.argc==3 || g.argc==4 ){ |
| 2352 | 2350 | const char *zName = g.argv[2]; |
| | @@ -2366,11 +2364,11 @@ |
| 2366 | 2364 | db_unset(ctrlSettings[i].name, globalFlag); |
| 2367 | 2365 | }else if( g.argc==4 ){ |
| 2368 | 2366 | db_set(ctrlSettings[i].name, g.argv[3], globalFlag); |
| 2369 | 2367 | }else{ |
| 2370 | 2368 | isManifest = 0; |
| 2371 | | - print_setting(&ctrlSettings[i], db_open_local()); |
| 2369 | + print_setting(&ctrlSettings[i], db_open_local(0)); |
| 2372 | 2370 | } |
| 2373 | 2371 | if( isManifest && g.localOpen ){ |
| 2374 | 2372 | manifest_to_disk(db_lget_int("checkout", 0)); |
| 2375 | 2373 | } |
| 2376 | 2374 | }else{ |
| 2377 | 2375 | |