Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Disconnect the global configuration database in ~/.fossil from the respository database in most cases. This allows multiple "sync" or "commit" operations to be running on different repositories at the same time. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
00ac7945a9ead7200d6ad4404ca432c6 |
| User & Date: | drh 2009-08-13 14:27:24.000 |
References
|
2009-08-15
| ||
| 21:41 | • Ticket [c7c36ef52e] recent fossil on non English variant of winXP fails to create new repo status still Open with 2 other changes artifact: 99b8395b94 user: drh | |
Context
|
2009-08-13
| ||
| 14:36 | In the "remote-url" command, omit the userid and password from the URL unless the "--show-pw" command-line option is used. check-in: 9cbef7a104 user: drh tags: trunk | |
| 14:27 | Disconnect the global configuration database in ~/.fossil from the respository database in most cases. This allows multiple "sync" or "commit" operations to be running on different repositories at the same time. check-in: 00ac7945a9 user: drh tags: trunk | |
|
2009-08-12
| ||
| 17:35 | Rephrasing the text of the Login page. check-in: c15ec20d5a user: drh tags: trunk | |
Changes
Changes to src/allrepo.c.
| ︙ | ︙ | |||
87 88 89 90 91 92 93 |
char *zQFilename;
int nMissing;
if( g.argc<3 ){
usage("list|ls|pull|push|rebuild|sync");
}
n = strlen(g.argv[2]);
| | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
char *zQFilename;
int nMissing;
if( g.argc<3 ){
usage("list|ls|pull|push|rebuild|sync");
}
n = strlen(g.argv[2]);
db_open_config(1);
zCmd = g.argv[2];
if( strncmp(zCmd, "list", n)==0 ){
zCmd = "list";
}else if( strncmp(zCmd, "ls", n)==0 ){ /* alias for "list" above */
zCmd = "list";
}else if( strncmp(zCmd, "push", n)==0 ){
zCmd = "push -autourl -R";
|
| ︙ | ︙ |
Changes to src/cgi.c.
| ︙ | ︙ | |||
676 677 678 679 680 681 682 |
cgi_destination(CGI_BODY);
z = (char*)P("QUERY_STRING");
if( z ){
z = mprintf("%s",z);
add_param_list(z, '&');
}
| | | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
cgi_destination(CGI_BODY);
z = (char*)P("QUERY_STRING");
if( z ){
z = mprintf("%s",z);
add_param_list(z, '&');
}
z = (char*)P("REMOTE_ADDR");
if( z ) g.zIpAddr = mprintf("%s", z);
len = atoi(PD("CONTENT_LENGTH", "0"));
g.zContentType = zType = P("CONTENT_TYPE");
if( len>0 && zType ){
blob_zero(&g.cgiIn);
if( strcmp(zType,"application/x-www-form-urlencoded")==0
|
| ︙ | ︙ |
Changes to src/clone.c.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 |
*/
void clone_cmd(void){
char *zPassword;
url_proxy_options();
if( g.argc!=4 ){
usage("FILE-OR-URL NEW-REPOSITORY");
}
| | < | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
*/
void clone_cmd(void){
char *zPassword;
url_proxy_options();
if( g.argc!=4 ){
usage("FILE-OR-URL NEW-REPOSITORY");
}
db_open_config(0);
if( file_size(g.argv[3])>0 ){
fossil_panic("file already exists: %s", g.argv[3]);
}
url_parse(g.argv[2]);
if( g.urlIsFile ){
file_copy(g.urlName, g.argv[3]);
db_close();
db_open_repository(g.argv[3]);
db_record_repository_filename(g.argv[3]);
db_multi_exec(
"REPLACE INTO config(name,value)"
" VALUES('server-code', lower(hex(randomblob(20))));"
"REPLACE INTO config(name,value)"
" VALUES('last-sync-url', '%q');",
g.urlCanonical
|
| ︙ | ︙ |
Changes to src/construct.c.
| ︙ | ︙ | |||
135 136 137 138 139 140 141 |
if( !file_isdir (zOrigin) ){
fossil_panic("not a directory: %s", zOrigin);
}
/* Create the foundation */
db_create_repository(zRepository);
db_open_repository(zRepository);
| | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
if( !file_isdir (zOrigin) ){
fossil_panic("not a directory: %s", zOrigin);
}
/* Create the foundation */
db_create_repository(zRepository);
db_open_repository(zRepository);
db_open_config(0);
db_begin_transaction();
db_initial_setup(0, 1);
printf("project-id: %s\n", db_get("project-code", 0));
printf("server-id: %s\n", db_get("server-code", 0));
printf("admin-user: %s (no password set yet!)\n", g.zLogin);
|
| ︙ | ︙ |
Changes to src/db.c.
| ︙ | ︙ | |||
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
db_err(sqlite3_errmsg(db));
}
}
va_end(ap);
sqlite3_exec(db, "COMMIT", 0, 0, 0);
sqlite3_close(db);
}
/*
** zDbName is the name of a database file. If no other database
** file is open, then open this one. If another database file is
** already open, then attach zDbName using the name zLabel.
*/
void db_open_or_attach(const char *zDbName, const char *zLabel){
#ifdef __MINGW32__
zDbName = mbcsToUtf8(zDbName);
#endif
if( !g.db ){
| > > > > > > > > > > > > > > > > > > > > > > > < < | < < < < < < < < < < > > > > > > > > | | 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
db_err(sqlite3_errmsg(db));
}
}
va_end(ap);
sqlite3_exec(db, "COMMIT", 0, 0, 0);
sqlite3_close(db);
}
/*
** Open a database file. Return a pointer to the new database
** connection. An error results in process abort.
*/
static sqlite3 *openDatabase(const char *zDbName){
int rc;
const char *zVfs;
sqlite3 *db;
zVfs = getenv("FOSSIL_VFS");
rc = sqlite3_open_v2(
zDbName, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
zVfs
);
if( rc!=SQLITE_OK ){
db_err(sqlite3_errmsg(db));
}
sqlite3_busy_timeout(db, 5000);
return db;
}
/*
** zDbName is the name of a database file. If no other database
** file is open, then open this one. If another database file is
** already open, then attach zDbName using the name zLabel.
*/
void db_open_or_attach(const char *zDbName, const char *zLabel){
#ifdef __MINGW32__
zDbName = mbcsToUtf8(zDbName);
#endif
if( !g.db ){
g.db = openDatabase(zDbName);
db_connection_init();
}else{
db_multi_exec("ATTACH DATABASE %Q AS %s", zDbName, zLabel);
}
}
/*
** Open the user database in "~/.fossil". Create the database anew if
** it does not already exist.
**
** If the useAttach flag is 0 (the usual case) then the user database is
** opened on a separate database connection g.dbConfig. This prevents
** the ~/.fossil 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 ~/.fossil 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.
*/
void db_open_config(int useAttach){
char *zDbName;
const char *zHome;
if( g.configOpen ) return;
#ifdef __MINGW32__
zHome = getenv("LOCALAPPDATA");
if( zHome==0 ){
zHome = getenv("APPDATA");
|
| ︙ | ︙ | |||
682 683 684 685 686 687 688 |
zDbName = mprintf("%//_fossil", zHome);
#else
zDbName = mprintf("%s/.fossil", zHome);
#endif
if( file_size(zDbName)<1024*3 ){
db_init_database(zDbName, zConfigSchema, (char*)0);
}
| > > | > > > > | | 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
zDbName = mprintf("%//_fossil", zHome);
#else
zDbName = mprintf("%s/.fossil", zHome);
#endif
if( file_size(zDbName)<1024*3 ){
db_init_database(zDbName, zConfigSchema, (char*)0);
}
g.useAttach = useAttach;
if( useAttach ){
db_open_or_attach(zDbName, "configdb");
g.dbConfig = 0;
}else{
g.dbConfig = openDatabase(zDbName);
}
g.configOpen = 1;
}
/*
** If zDbName is a valid local database file, open it and return
** true. If it is not a valid local database file, return 0.
*/
static int isValidLocalDb(const char *zDbName){
i64 lsize;
int rc;
sqlite3_stmt *pStmt;
if( access(zDbName, F_OK) ) return 0;
lsize = file_size(zDbName);
if( lsize%1024!=0 || lsize<4096 ) return 0;
db_open_or_attach(zDbName, "localdb");
g.localOpen = 1;
db_open_config(0);
db_open_repository(0);
/* If the "mtime" column is missing from the vfile table, then
** add it now. This code added on 2008-12-06. After all users have
** upgraded, this code can be safely deleted.
*/
rc = sqlite3_prepare(g.db, "SELECT mtime FROM vfile", -1, &pStmt, 0);
|
| ︙ | ︙ | |||
985 986 987 988 989 990 991 |
zDate = find_option("date-override",0,1);
if( zDate==0 ) zDate = "now";
if( g.argc!=3 ){
usage("REPOSITORY-NAME");
}
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
| | | 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 |
zDate = find_option("date-override",0,1);
if( zDate==0 ) zDate = "now";
if( g.argc!=3 ){
usage("REPOSITORY-NAME");
}
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
db_open_config(0);
db_begin_transaction();
db_initial_setup(zDate, 1);
db_end_transaction(0);
printf("project-id: %s\n", db_get("project-code", 0));
printf("server-id: %s\n", db_get("server-code", 0));
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
printf("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
|
| ︙ | ︙ | |||
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 |
static const char *azOff[] = { "off", "no", "false", "0" };
int i;
for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
if( strcmp(zVal,azOff[i])==0 ) return 1;
}
return 0;
}
/*
** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the
** repository and local databases.
*/
char *db_get(const char *zName, char *zDefault){
char *z = 0;
if( g.repositoryOpen ){
z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName);
}
if( z==0 && g.configOpen ){
z = db_text(0, "SELECT value FROM global_config WHERE name=%Q", zName);
}
if( z==0 ){
z = zDefault;
}
return z;
}
void db_set(const char *zName, const char *zValue, int globalFlag){
db_begin_transaction();
| > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > | > > | > > > | < < > > > > > | > > > > | | > < | 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 |
static const char *azOff[] = { "off", "no", "false", "0" };
int i;
for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
if( strcmp(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 ~/.fossil database instead of on the repository database.
** Be sure to swap them back after doing the operation.
**
** If g.useAttach that means the ~/.fossil database was opened with
** the useAttach flag set to 1. In that case no connection swap is required
** so this routine is a no-op.
*/
void db_swap_connections(void){
if( !g.useAttach ){
sqlite3 *dbTemp = g.db;
g.db = g.dbConfig;
g.dbConfig = dbTemp;
}
}
/*
** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the
** repository and local databases.
*/
char *db_get(const char *zName, char *zDefault){
char *z = 0;
if( g.repositoryOpen ){
z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName);
}
if( z==0 && g.configOpen ){
db_swap_connections();
z = db_text(0, "SELECT value FROM global_config WHERE name=%Q", zName);
db_swap_connections();
}
if( z==0 ){
z = zDefault;
}
return z;
}
void db_set(const char *zName, const char *zValue, int globalFlag){
db_begin_transaction();
if( globalFlag ){
db_swap_connections();
db_multi_exec("REPLACE INTO global_config(name,value) VALUES(%Q,%Q)",
zName, zValue);
db_swap_connections();
}else{
db_multi_exec("REPLACE INTO config(name,value) VALUES(%Q,%Q)",
zName, zValue);
}
if( globalFlag && g.repositoryOpen ){
db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
}
db_end_transaction(0);
}
void db_unset(const char *zName, int globalFlag){
db_begin_transaction();
if( globalFlag ){
db_swap_connections();
db_multi_exec("DELETE INTO global_config WHERE name=%Q", zName);
db_swap_connections();
}else{
db_multi_exec("DELETE INTO config WHERE name=%Q", zName);
}
if( globalFlag && g.repositoryOpen ){
db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
}
db_end_transaction(0);
}
int db_is_global(const char *zName){
int rc = 0;
if( g.configOpen ){
db_swap_connections();
rc = db_exists("SELECT 1 FROM global_config WHERE name=%Q", zName);
db_swap_connections();
}
return rc;
}
int db_get_int(const char *zName, int dflt){
int v = dflt;
int rc;
if( g.repositoryOpen ){
Stmt q;
db_prepare(&q, "SELECT value FROM config WHERE name=%Q", zName);
rc = db_step(&q);
if( rc==SQLITE_ROW ){
v = db_column_int(&q, 0);
}
db_finalize(&q);
}else{
rc = SQLITE_DONE;
}
if( rc==SQLITE_DONE && g.configOpen ){
db_swap_connections();
v = db_int(dflt, "SELECT value FROM global_config WHERE name=%Q", zName);
db_swap_connections();
}
return v;
}
void db_set_int(const char *zName, int value, int globalFlag){
if( globalFlag ){
db_swap_connections();
db_multi_exec("REPLACE INTO global_config(name,value) VALUES(%Q,%d)",
zName, value);
db_swap_connections();
}else{
db_multi_exec("REPLACE INTO config(name,value) VALUES(%Q,%d)",
zName, value);
}
if( globalFlag && g.repositoryOpen ){
db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
}
}
int db_get_boolean(const char *zName, int dflt){
char *zVal = db_get(zName, dflt ? "on" : "off");
if( is_truth(zVal) ) return 1;
if( is_false(zVal) ) return 0;
return dflt;
}
|
| ︙ | ︙ | |||
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 |
void db_record_repository_filename(const char *zName){
Blob full;
if( zName==0 ){
if( !g.localOpen ) return;
zName = db_lget("repository", 0);
}
file_canonical_name(zName, &full);
db_multi_exec(
"INSERT OR IGNORE INTO global_config(name,value)"
"VALUES('repo:%q',1)",
blob_str(&full)
);
blob_reset(&full);
}
/*
** COMMAND: open
**
** Usage: %fossil open FILENAME ?VERSION? ?--keep?
| > > | 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 |
void db_record_repository_filename(const char *zName){
Blob full;
if( zName==0 ){
if( !g.localOpen ) return;
zName = db_lget("repository", 0);
}
file_canonical_name(zName, &full);
db_swap_connections();
db_multi_exec(
"INSERT OR IGNORE INTO global_config(name,value)"
"VALUES('repo:%q',1)",
blob_str(&full)
);
db_swap_connections();
blob_reset(&full);
}
/*
** COMMAND: open
**
** Usage: %fossil open FILENAME ?VERSION? ?--keep?
|
| ︙ | ︙ | |||
1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 |
"mtime-changes",
"proxy",
"web-browser",
};
int i;
int globalFlag = find_option("global","g",0)!=0;
int unsetFlag = g.argv[1][0]=='u';
db_find_and_open_repository(0);
if( !g.repositoryOpen ){
globalFlag = 1;
}
| > < | 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 |
"mtime-changes",
"proxy",
"web-browser",
};
int i;
int globalFlag = find_option("global","g",0)!=0;
int unsetFlag = g.argv[1][0]=='u';
db_open_config(1);
db_find_and_open_repository(0);
if( !g.repositoryOpen ){
globalFlag = 1;
}
if( unsetFlag && g.argc!=3 ){
usage("PROPERTY ?-global?");
}
if( g.argc==2 ){
for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
print_setting(azName[i]);
}
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
95 96 97 98 99 100 101 |
*/
void info_cmd(void){
i64 fsize;
if( g.argc!=2 && g.argc!=3 ){
usage("?FILENAME|ARTIFACT-ID?");
}
if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){
| | | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
*/
void info_cmd(void){
i64 fsize;
if( g.argc!=2 && g.argc!=3 ){
usage("?FILENAME|ARTIFACT-ID?");
}
if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){
db_open_config(0);
db_record_repository_filename(g.argv[2]);
db_open_repository(g.argv[2]);
printf("project-code: %s\n", db_get("project-code", "<none>"));
printf("project-name: %s\n", db_get("project-name", "<unnamed>"));
printf("server-code: %s\n", db_get("server-code", "<none>"));
return;
}
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
/*
** All global variables are in this structure.
*/
struct Global {
int argc; char **argv; /* Command-line arguments to the program */
int isConst; /* True if the output is unchanging */
sqlite3 *db; /* The connection to the databases */
int configOpen; /* True if the config database is open */
long long int now; /* Seconds since 1970 */
int repositoryOpen; /* True if the main repository database is open */
char *zRepositoryName; /* Name of the repository database */
int localOpen; /* True if the local database is open */
char *zLocalRoot; /* The directory holding the local database */
int minPrefix; /* Number of digits needed for a distinct UUID */
| > > | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
/*
** All global variables are in this structure.
*/
struct Global {
int argc; char **argv; /* Command-line arguments to the program */
int isConst; /* True if the output is unchanging */
sqlite3 *db; /* The connection to the databases */
sqlite3 *dbConfig; /* Separate connection for global_config table */
int useAttach; /* True if global_config is attached to repository */
int configOpen; /* True if the config database is open */
long long int now; /* Seconds since 1970 */
int repositoryOpen; /* True if the main repository database is open */
char *zRepositoryName; /* Name of the repository database */
int localOpen; /* True if the local database is open */
char *zLocalRoot; /* The directory holding the local database */
int minPrefix; /* Number of digits needed for a distinct UUID */
|
| ︙ | ︙ |