| ︙ | | |
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
|
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
|
-
+
-
+
|
}
if( zHome==0 ){
if( isOptional ) return 0;
fossil_fatal("cannot locate home directory - please set the "
"FOSSIL_HOME or HOME environment variables");
}
#endif
if( file_isdir(zHome)!=1 ){
if( file_isdir(zHome, ExtFILE)!=1 ){
if( isOptional ) return 0;
fossil_fatal("invalid home directory: %s", zHome);
}
#if defined(_WIN32) || defined(__CYGWIN__)
/* . filenames give some window systems problems and many apps problems */
zDbName = mprintf("%//_fossil", zHome);
#else
zDbName = mprintf("%s/.fossil", zHome);
#endif
if( file_size(zDbName)<1024*3 ){
if( file_size(zDbName, ExtFILE)<1024*3 ){
if( file_access(zHome, W_OK) ){
if( isOptional ) return 0;
fossil_fatal("home directory %s must be writeable", zHome);
}
db_init_database(zDbName, zConfigSchema, (char*)0);
}
if( file_access(zDbName, W_OK) ){
|
| ︙ | | |
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
|
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
|
-
+
|
** true. If it is not a valid local database file, return 0.
*/
static int isValidLocalDb(const char *zDbName){
i64 lsize;
char *zVFileDef;
if( file_access(zDbName, F_OK) ) return 0;
lsize = file_size(zDbName);
lsize = file_size(zDbName, ExtFILE);
if( lsize%1024!=0 || lsize<4096 ) return 0;
db_open_or_attach(zDbName, "localdb");
zVFileDef = db_text(0, "SELECT sql FROM localdb.sqlite_master"
" WHERE name=='vfile'");
if( zVFileDef==0 ) return 0;
/* If the "isexe" column is missing from the vfile table, then
|
| ︙ | | |
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
|
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
|
-
+
|
if( g.localOpen ){
zDbName = db_repository_filename();
}
if( zDbName==0 ){
db_err("unable to find the name of a repository database");
}
}
if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
if( file_access(zDbName, R_OK) || file_size(zDbName, ExtFILE)<1024 ){
if( file_access(zDbName, F_OK) ){
#ifdef FOSSIL_ENABLE_JSON
g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
#endif
fossil_panic("repository does not exist or"
" is in an unreadable directory: %s", zDbName);
}else if( file_access(zDbName, R_OK) ){
|
| ︙ | | |
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
|
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
|
-
+
|
** option to locate the repository. If no such option is available, then
** use the repository of the open checkout if there is one.
**
** Error out if the repository cannot be opened.
*/
void db_find_and_open_repository(int bFlags, int nArgUsed){
const char *zRep = find_repository_option();
if( zRep && file_isdir(zRep)==1 ){
if( zRep && file_isdir(zRep, ExtFILE)==1 ){
goto rep_not_found;
}
if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
zRep = g.argv[nArgUsed];
}
if( zRep==0 ){
if( db_open_local(0)==0 ){
|
| ︙ | | |
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
|
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
|
-
+
|
/* We should be done with options.. */
verify_all_options();
if( g.argc!=3 ){
usage("REPOSITORY-NAME");
}
if( -1 != file_size(g.argv[2]) ){
if( -1 != file_size(g.argv[2], ExtFILE) ){
fossil_fatal("file already exists: %s", g.argv[2]);
}
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
db_open_config(0, 0);
if( zTemplate ) db_attach(zTemplate, "settingSrc");
|
| ︙ | | |
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
|
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
|
-
+
+
-
+
-
+
|
blob_append(&versionedPathname, ".no-warn", -1);
blob_zero(&noWarnFile);
if( historical_blob(g.zOpenRevision, blob_str(&versionedPathname),
&noWarnFile, 0) ){
noWarn = 1;
}
blob_reset(&noWarnFile);
}else if( file_size(blob_str(&versionedPathname))>=0 ){
}else if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
/* File exists, and contains the value for this setting. Load from
** the file. */
const char *zFile = blob_str(&versionedPathname);
if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){
if( blob_read_from_file(&setting, zFile, ExtFILE)>=0 ){
found = 1;
}
/* See if there's a no-warn flag */
blob_append(&versionedPathname, ".no-warn", -1);
if( file_size(blob_str(&versionedPathname))>=0 ){
if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
noWarn = 1;
}
}
blob_reset(&versionedPathname);
if( found ){
blob_trim(&setting); /* Avoid non-obvious problems with line endings
** on boolean properties */
|
| ︙ | | |
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
|
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
|
-
+
|
}
if( pSetting->versionable && g.localOpen ){
/* Check to see if this is overridden by a versionable settings file */
Blob versionedPathname;
blob_zero(&versionedPathname);
blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
g.zLocalRoot, pSetting->name);
if( file_size(blob_str(&versionedPathname))>=0 ){
if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
pSetting->name);
}
}
db_finalize(&q);
}
|
| ︙ | | |