Check-in [82332148a2]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:82332148a2aa3cb6c7272c2708beff50536bf688
Date: 2012-04-29 17:08:44
User: drh
Comment:Merge in recent trunk changes so that the branches can be more easily compared.
Tags And Properties
Changes

Changes to src/checkout.c

289 */ 289 */ 290 void close_cmd(void){ 290 void close_cmd(void){ 291 int forceFlag = find_option("force","f",0)!=0; 291 int forceFlag = find_option("force","f",0)!=0; 292 db_must_be_within_tree(); 292 db_must_be_within_tree(); 293 if( !forceFlag && unsaved_changes()==1 ){ 293 if( !forceFlag && unsaved_changes()==1 ){ 294 fossil_fatal("there are unsaved changes in the current checkout"); 294 fossil_fatal("there are unsaved changes in the current checkout"); 295 } 295 } > 296 if( db_is_writeable("repository") ){ > 297 db_multi_exec("DELETE FROM config WHERE name='ckout:%q'", g.zLocalRoot); > 298 } 296 unlink_local_database(1); 299 unlink_local_database(1); 297 db_close(1); 300 db_close(1); 298 unlink_local_database(0); 301 unlink_local_database(0); 299 } 302 }

Changes to src/db.c

500 } 500 } 501 501 502 /* 502 /* 503 ** Optionally make the following changes to the database if feasible and 503 ** Optionally make the following changes to the database if feasible and 504 ** convenient. Do not start a transaction for these changes, but only 504 ** convenient. Do not start a transaction for these changes, but only 505 ** make these changes if other changes are also being made. 505 ** make these changes if other changes are also being made. 506 */ 506 */ 507 void db_optional_sql(const char *zSql, ...){ | 507 void db_optional_sql(const char *zDb, const char *zSql, ...){ 508 if( db.nBeforeCommit < count(db.azBeforeCommit) ){ | 508 if( db_is_writeable(zDb) && db.nBeforeCommit < count(db.azBeforeCommit) ){ 509 va_list ap; 509 va_list ap; 510 va_start(ap, zSql); 510 va_start(ap, zSql); 511 db.azBeforeCommit[db.nBeforeCommit++] = sqlite3_vmprintf(zSql, ap); 511 db.azBeforeCommit[db.nBeforeCommit++] = sqlite3_vmprintf(zSql, ap); 512 va_end(ap); 512 va_end(ap); 513 } 513 } 514 } 514 } 515 515 ................................................................................................................................................................................ 1018 ** Return TRUE if the schema is out-of-date 1018 ** Return TRUE if the schema is out-of-date 1019 */ 1019 */ 1020 int db_schema_is_outofdate(void){ 1020 int db_schema_is_outofdate(void){ 1021 return db_exists("SELECT 1 FROM config" 1021 return db_exists("SELECT 1 FROM config" 1022 " WHERE name='aux-schema'" 1022 " WHERE name='aux-schema'" 1023 " AND value<>'%s'", AUX_SCHEMA); 1023 " AND value<>'%s'", AUX_SCHEMA); 1024 } 1024 } > 1025 > 1026 /* > 1027 ** Return true if the database is writeable > 1028 */ > 1029 int db_is_writeable(const char *zName){ > 1030 return !sqlite3_db_readonly(g.db, db_name(zName)); > 1031 } 1025 1032 1026 /* 1033 /* 1027 ** Verify that the repository schema is correct. If it is not correct, 1034 ** Verify that the repository schema is correct. If it is not correct, 1028 ** issue a fatal error and die. 1035 ** issue a fatal error and die. 1029 */ 1036 */ 1030 void db_verify_schema(void){ 1037 void db_verify_schema(void){ 1031 if( db_schema_is_outofdate() ){ 1038 if( db_schema_is_outofdate() ){ ................................................................................................................................................................................ 1734 Blob localRoot; 1741 Blob localRoot; 1735 file_canonical_name(g.zLocalRoot, &localRoot, 1); 1742 file_canonical_name(g.zLocalRoot, &localRoot, 1); 1736 db_multi_exec( 1743 db_multi_exec( 1737 "REPLACE INTO global_config(name, value)" 1744 "REPLACE INTO global_config(name, value)" 1738 "VALUES('ckout:%q','%q');", 1745 "VALUES('ckout:%q','%q');", 1739 blob_str(&localRoot), blob_str(&full) 1746 blob_str(&localRoot), blob_str(&full) 1740 ); 1747 ); > 1748 db_swap_connections(); > 1749 db_optional_sql("repository", 1741 db_optional_sql("REPLACE INTO config(name,value,mtime)" | 1750 "REPLACE INTO config(name,value,mtime)" 1742 "VALUES('ckout:%q',1,now())", | 1751 "VALUES('ckout:%q',1,now())", 1743 blob_str(&localRoot)); | 1752 blob_str(&localRoot) > 1753 ); 1744 blob_reset(&localRoot); 1754 blob_reset(&localRoot); 1745 } < > 1755 }else{ 1746 db_swap_connections(); | 1756 db_swap_connections(); > 1757 } 1747 blob_reset(&full); 1758 blob_reset(&full); 1748 } 1759 } 1749 1760 1750 /* 1761 /* 1751 ** COMMAND: open 1762 ** COMMAND: open 1752 ** 1763 ** 1753 ** Usage: %fossil open FILENAME ?VERSION? ?OPTIONS? 1764 ** Usage: %fossil open FILENAME ?VERSION? ?OPTIONS?

Changes to src/main.c

1090 if( fossil_stricmp(zMode,"on")==0 ){ 1090 if( fossil_stricmp(zMode,"on")==0 ){ 1091 g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur); 1091 g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur); 1092 g.zTop = &g.zBaseURL[8+strlen(zHost)]; 1092 g.zTop = &g.zBaseURL[8+strlen(zHost)]; 1093 }else{ 1093 }else{ 1094 g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur); 1094 g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur); 1095 g.zTop = &g.zBaseURL[7+strlen(zHost)]; 1095 g.zTop = &g.zBaseURL[7+strlen(zHost)]; 1096 } 1096 } > 1097 if( db_is_writeable("repository") ){ 1097 if( !db_exists("SELECT 1 FROM config WHERE name='baseurl:%q'", g.zBaseURL) ){ | 1098 if( !db_exists("SELECT 1 FROM config WHERE name='baseurl:%q'", g.zBaseURL) ) 1098 db_multi_exec("INSERT INTO config(name,value,mtime)" | 1099 db_multi_exec("INSERT INTO config(name,value,mtime)" 1099 "VALUES('baseurl:%q',1,now())", g.zBaseURL); | 1100 "VALUES('baseurl:%q',1,now())", g.zBaseURL); 1100 }else{ | 1101 }else{ > 1102 db_optional_sql("repository", 1101 db_optional_sql("REPLACE INTO config(name,value,mtime)" | 1103 "REPLACE INTO config(name,value,mtime)" 1102 "VALUES('baseurl:%q',1,now())", g.zBaseURL); | 1104 "VALUES('baseurl:%q',1,now())", g.zBaseURL > 1105 ); > 1106 } 1103 } 1107 } 1104 } 1108 } 1105 1109 1106 /* 1110 /* 1107 ** Send an HTTP redirect back to the designated Index Page. 1111 ** Send an HTTP redirect back to the designated Index Page. 1108 */ 1112 */ 1109 NORETURN void fossil_redirect_home(void){ 1113 NORETURN void fossil_redirect_home(void){