Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Revise the algorithm for finding the configuration database on unix. The algorithm is now approximately this: (1) Use the ~/.fossil name if such a file exists. (2) Use ~/.config/fossil.db if the ~/.config directory exists (3) Otherwise use ~/.fossil See [/doc/4645e9bb1a/www/tech_overview.wiki#configloc|www/tech_overview.wiki] for details. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
4645e9bb1aaaf0cc66e4aaa77ad63efa |
| User & Date: | drh 2020-04-19 14:06:29.147 |
| Original Comment: | Revise the algorithm for finding the configuration database on unix. The algorithm is now approximately this: (1) Use the ~/.fossil name if such a file exists. (2) Use ~/.config/fossil.db if the ~/.config directory exists (3) Otherwise use ~/.fossil See [/doc/$CURRENT/www/tech_overview.wiki#configloc|www/tech_overview.wiki] for details. |
Context
|
2020-04-19
| ||
| 14:18 | Enhance the "fossil info" command so that if it is run with no arguments and not in an option check-out, it shows global information about the fossil setup (currently limited to the location of the configuration database). check-in: 6e71a28847 user: drh tags: trunk | |
| 14:06 | Revise the algorithm for finding the configuration database on unix. The algorithm is now approximately this: (1) Use the ~/.fossil name if such a file exists. (2) Use ~/.config/fossil.db if the ~/.config directory exists (3) Otherwise use ~/.fossil See [/doc/4645e9bb1a/www/tech_overview.wiki#configloc|www/tech_overview.wiki] for details. check-in: 4645e9bb1a user: drh tags: trunk | |
|
2020-04-18
| ||
| 21:05 | Add the ability to display the history of edits to a single timeline post. Improvements to the CSS for timeline display in the default skin. check-in: 34d8d7e714 user: drh tags: trunk | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 | ******************************************************************************* ** ** Code for interfacing to the various databases. ** ** There are three separate database files that fossil interacts ** with: ** | | > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ******************************************************************************* ** ** Code for interfacing to the various databases. ** ** There are three separate database files that fossil interacts ** with: ** ** (1) The "configdb" database in ~/.fossil or ~/.config/fossil.db ** or in %LOCALAPPDATA%/_fossil ** ** (2) The "repository" database ** ** (3) A local checkout database named "_FOSSIL_" or ".fslckout" ** and located at the root of the local copy of the source tree. ** */ |
| ︙ | ︙ | |||
1367 1368 1369 1370 1371 1372 1373 |
db_set_main_schemaname(g.db, zLabel);
}else{
db_attach(zDbName, zLabel);
}
}
/*
| | | 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 |
db_set_main_schemaname(g.db, zLabel);
}else{
db_attach(zDbName, zLabel);
}
}
/*
** Close the per-user configuration database file
*/
void db_close_config(){
int iSlot = db_database_slot("configdb");
if( iSlot>0 ){
db_detach("configdb");
}else if( g.dbConfig ){
sqlite3_wal_checkpoint(g.dbConfig, 0);
|
| ︙ | ︙ | |||
1391 1392 1393 1394 1395 1396 1397 |
return;
}
fossil_free(g.zConfigDbName);
g.zConfigDbName = 0;
}
/*
| | | | < < < < < < | < | | | < < < | > > | > > > > > | > | | < < < | | > | > > > > > > | > > > | | > > > > | > | > > | > > > > > > | | | | | | | > > > > | | > > > > > > > > > > > > > > | > | < > < < | < | < > > > > > | > > | | 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 |
return;
}
fossil_free(g.zConfigDbName);
g.zConfigDbName = 0;
}
/*
** Compute the name of the configuration database. If unable to find the
** database, return 0 if isOptional is true, or panic if isOptional is false.
**
** Space to hold the result comes from fossil_malloc().
*/
static char *db_configdb_name(int isOptional){
char *zHome; /* Home directory */
char *zDbName; /* Name of the database file */
/* On Windows, look for these directories, in order:
**
** FOSSIL_HOME
** LOCALAPPDATA
** APPDATA
** USERPROFILE
** HOMEDRIVE HOMEPATH
*/
#if defined(_WIN32) || defined(__CYGWIN__)
zHome = fossil_getenv("FOSSIL_HOME");
if( zHome==0 ){
zHome = fossil_getenv("LOCALAPPDATA");
if( zHome==0 ){
zHome = fossil_getenv("APPDATA");
if( zHome==0 ){
zHome = fossil_getenv("USERPROFILE");
if( zHome==0 ){
char *zDrive = fossil_getenv("HOMEDRIVE");
char *zPath = fossil_getenv("HOMEPATH");
if( zDrive && zPath ) zHome = mprintf("%s%s", zDrive, zPath);
}
}
}
}
zDbName = mprintf("%//_fossil", zHome);
fossil_free(zHome);
return zDbName;
#else /* if unix */
char *zXdgHome;
/* For unix. a 5-step algorithm is used.
** See ../www/tech_overview.wiki for discussion.
**
** Step 1: If FOSSIL_HOME exists -> $FOSSIL_HOME/.fossil
*/
zHome = fossil_getenv("FOSSIL_HOME");
if( zHome!=0 ) return mprintf("%s/.fossil", zHome);
/* Step 2: If HOME exists and file $HOME/.fossil exists -> $HOME/.fossil
*/
zHome = fossil_getenv("HOME");
if( zHome ){
zDbName = mprintf("%s/.fossil", zHome);
if( file_size(zDbName, ExtFILE)>1024*3 ){
return zDbName;
}
fossil_free(zDbName);
}
/* Step 3: if XDG_CONFIG_HOME exists -> $XDG_CONFIG_HOME/fossil.db
*/
zXdgHome = fossil_getenv("XDG_CONFIG_HOME");
if( zXdgHome!=0 ){
return mprintf("%s/fossil.db", zXdgHome);
}
/* Step 4: If HOME does not exist -> ERROR
*/
if( zHome==0 ){
if( isOptional ) return 0;
fossil_panic("cannot locate home directory - please set one of the "
"FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment "
"variables");
}
/* Step 5: Otherwise -> $HOME/.config/fossil.db
*/
return mprintf("%s/.config/fossil.db", zHome);
#endif /* unix */
}
/*
** Open the configuration database. Create the database anew if
** it does not already exist.
**
** If the useAttach flag is 0 (the usual case) then the configuration
** database is opened on a separate database connection g.dbConfig.
** This prevents the database from becoming locked on long check-in or sync
** operations which hold an exclusive transaction. In a few cases, though,
** it is convenient for the database to be attached to the main database
** connection so that we can join between the various databases. In that
** case, invoke this routine with useAttach as 1.
*/
int db_open_config(int useAttach, int isOptional){
char *zDbName;
if( g.zConfigDbName ){
int alreadyAttached = db_database_slot("configdb")>0;
if( useAttach==alreadyAttached ) return 1; /* Already open. */
db_close_config();
}
zDbName = db_configdb_name(isOptional);
if( zDbName==0 ) return 0;
if( file_size(zDbName, ExtFILE)<1024*3 ){
char *zHome = file_dirname(zDbName);
int rc;
if( file_isdir(zHome, ExtFILE)==0 ){
file_mkdir(zHome, ExtFILE, 0);
}
rc = file_access(zHome, W_OK);
fossil_free(zHome);
if( rc ){
if( isOptional ) return 0;
fossil_panic("home directory \"%s\" must be writeable", zHome);
}
db_init_database(zDbName, zConfigSchema, (char*)0);
}
if( file_access(zDbName, W_OK) ){
if( isOptional ) return 0;
fossil_panic("configuration file %s must be writeable", zDbName);
}
|
| ︙ | ︙ | |||
2513 2514 2515 2516 2517 2518 2519 |
if( fossil_stricmp(zVal,azOff[i])==0 ) return 1;
}
return 0;
}
/*
** Swap the g.db and g.dbConfig connections so that the various db_* routines
| | | | | | 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 |
if( fossil_stricmp(zVal,azOff[i])==0 ) return 1;
}
return 0;
}
/*
** Swap the g.db and g.dbConfig connections so that the various db_* routines
** work on the configuration database instead of on the repository database.
** Be sure to swap them back after doing the operation.
**
** If the configuration database has already been opened as the main database
** or is attached to the main database, no connection swaps are required so
** this routine is a no-op.
*/
void db_swap_connections(void){
/*
** When swapping the main database connection with the config database
** connection, the config database connection must be open (not simply
** attached); otherwise, the swap would end up leaving the main database
** connection invalid, defeating the very purpose of this routine. This
|
| ︙ | ︙ | |||
3727 3728 3729 3730 3731 3732 3733 | ** file exists. ** ** The "unset" command clears a setting. ** ** Settings can have both a "local" repository-only value and "global" value ** that applies to all repositories. The local values are stored in the ** "config" table of the repository and the global values are stored in the | < | | | | 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 | ** file exists. ** ** The "unset" command clears a setting. ** ** Settings can have both a "local" repository-only value and "global" value ** that applies to all repositories. The local values are stored in the ** "config" table of the repository and the global values are stored in the ** configuration database. If both a local and a global value exists for a ** setting, the local value takes precedence. This command normally operates ** on the local settings. Use the --global option to change global settings. ** ** Options: ** --global set or unset the given property globally instead of ** setting or unsetting it for the open repository only. ** ** --exact only consider exact name matches. ** |
| ︙ | ︙ | |||
3865 3866 3867 3868 3869 3870 3871 | /* ** COMMAND: test-without-rowid ** ** Usage: %fossil test-without-rowid FILENAME... ** ** Change the Fossil repository FILENAME to make use of the WITHOUT ROWID | | | | 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 | /* ** COMMAND: test-without-rowid ** ** Usage: %fossil test-without-rowid FILENAME... ** ** Change the Fossil repository FILENAME to make use of the WITHOUT ROWID ** optimization. FILENAME can also be the configuration database file ** (~/.fossil or ~/.config/fossil.db) or a local .fslckout or _FOSSIL_ file. ** ** The purpose of this command is for testing the WITHOUT ROWID capabilities ** of SQLite. There is no big advantage to using WITHOUT ROWID in Fossil. ** ** Options: ** --dryrun | -n No changes. Just print what would happen. */ |
| ︙ | ︙ |
Changes to www/env-opts.md.
| ︙ | ︙ | |||
110 111 112 113 114 115 116 | `--vfs VFSNAME`: Load the named VFS into SQLite. Environment Variables --------------------- | < | < < < < > | < < | < < < < < < < < < < < | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | `--vfs VFSNAME`: Load the named VFS into SQLite. Environment Variables --------------------- The location of the user's account-wide [configuration database][configdb] depends on the operating system and on the existance of various environment variables and/or files. See the discussion of the [configuration database location algorithm][configloc] for details. `EDITOR`: Name the editor to use for check-in and stash comments. Overridden by the local or global `editor` setting or the `VISUAL` environment variable. `FOSSIL_BREAK`: If set, an opportunity will be created to attach a debugger to the Fossil process prior to any significant work being |
| ︙ | ︙ | |||
400 401 402 403 404 405 406 | in the clone even before any users have been created, and in that case it will be the new admin user. If `default-user` is not set, then the first found environment variable from the list `FOSSIL_USER`, `USER`, `LOGNAME`, and `USERNAME`, is the user name. As a final fallback, if none of those are set, then the default user name is "root". | | | < | < < < | < < < | < | | | < < < < < < < < > < | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | in the clone even before any users have been created, and in that case it will be the new admin user. If `default-user` is not set, then the first found environment variable from the list `FOSSIL_USER`, `USER`, `LOGNAME`, and `USERNAME`, is the user name. As a final fallback, if none of those are set, then the default user name is "root". ### Configuration Database Location Fossil keeps some information pertinent to each user in the user's [configuration database file][configdb]. The configuration database file includes the global settings and the list of repositories and checkouts used by `fossil all`. The location of the configuration database file depends on the operating system and on the existance of various environment variables and/or files. In brief, the configuration database is usually: * Traditional unix → "`$HOME/.fossil`" * Windows → "`%LOCALAPPDATA%/_fossil`" * [XDG-unix][xdg] → "`$HOME/.config/fossil.db`" [xdg]: https://www.freedesktop.org/wiki/ See the [configuration database location algorithm][configloc] discussion for full information. ### SQLite VFS to use See [the SQLite documentation](http://www.sqlite.org/vfs.html) for an explanation of what a VFS actually is and what it does. If the default VFS underneath SQLite is not suitable, an alternative |
| ︙ | ︙ |
Changes to www/tech_overview.wiki.
| ︙ | ︙ | |||
67 68 69 70 71 72 73 | The chart below provides a quick summary of how each of these database files are used by Fossil, with detailed discussion following. <table border="1" width="80%" cellpadding="0" align="center"> <tr> <td width="33%" valign="top"> <h3 align="center">Configuration Database<br>"~/.fossil" or<br> | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | The chart below provides a quick summary of how each of these database files are used by Fossil, with detailed discussion following. <table border="1" width="80%" cellpadding="0" align="center"> <tr> <td width="33%" valign="top"> <h3 align="center">Configuration Database<br>"~/.fossil" or<br> "~/.config/fossil.db"</h3> <ul> <li>Global [/help/settings |settings] <li>List of active repositories used by the [/help/all | all] command </ul> </td> <td width="34%" valign="top"> <h3 align="center">Repository Database<br>"<i>project</i>.fossil"</h3> |
| ︙ | ︙ | |||
126 127 128 129 130 131 132 | The configuration database also maintains a list of repositories. This list is used by the [/help/all | fossil all] command in order to run various operations such as "sync" or "rebuild" on all repositories managed by a user. <a name='configloc'></a> <h4>2.1.1 Location Of The Configuration Database</h4> | | | | > > > | > | > | | > > > | > > > > > | < > < | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
The configuration database also maintains a list of repositories. This
list is used by the [/help/all | fossil all] command in order to run various
operations such as "sync" or "rebuild" on all repositories managed by a user.
<a name='configloc'></a>
<h4>2.1.1 Location Of The Configuration Database</h4>
On Unix systems, the configuration database is named by the following
algorithm:
* if environment variable FOSSIL_HOME exists → $FOSSIL_HOME/.fossil
* if environment variable HOME exists and
if file $HOME/fossil exists → $HOME/.fossil
* if environment variable XDG_CONFIG_HOME exists
→ $XDG_CONFIG_HOME/fossil.db
* if environment variable HOME does not exist → <i>ERROR</i>
* Otherwise $HOME/.config/fossil.db
Another way of thinking of this algorithm is the following:
* Use "$FOSSIL_HOME/.fossil" if the FOSSIL_HOME variable is defined
* Use the traditional unix configuration file name of
"$HOME/.fossil" if HOME is defined and if that file exists.
* Use an XDG compatible name otherwise.
This algorithm is complex due to the need for historical compatibility.
Originally, the database was always named "$HOME/.fossil". Then support
for the FOSSIL_HOME environment variable as added. Later, support for the
[https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html|XDG-compatible configation filenames]
was added. Each of these changes needed to continue to support legacy installs.
On Windows, the configuration database is the first of the following
for which the corresponding environment variables exist:
* %FOSSIL_HOME%/_fossil
* %LOCALAPPDATA%/_fossil
* %APPDATA%/_fossil
* %USERPROFILES%/_fossil
* %HOMEDRIVE%%HOMEPATH%/_fossil
The second case is the one that usually determines the name Note that the
FOSSIL_HOME environment variable can always be set to determine the
location of the configuration database. Note also that the configuration
database file itself is called ".fossil" or "fossil.db" on unix but
"_fossil" on windows.
You can run the [/help?cmd=info|fossil info] command from an open
check-out to see the location of the configuration database.
|
| ︙ | ︙ |