Fossil SCM
Fix the server-side clone so that it is able to operate on a read-only repository database.
Commit
147bf47d6e145686550304ec8061281e5557ac419151e2109c95819e6be02984
Parent
517223eca965c36…
2 files changed
+11
-7
+3
-1
M
src/db.c
+11
-7
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -215,17 +215,21 @@ | ||
| 215 | 215 | /* |
| 216 | 216 | ** Begin a new transaction for writing. |
| 217 | 217 | */ |
| 218 | 218 | void db_begin_write_real(const char *zStartFile, int iStartLine){ |
| 219 | 219 | if( db.nBegin==0 ){ |
| 220 | - db_multi_exec("BEGIN IMMEDIATE"); | |
| 221 | - sqlite3_commit_hook(g.db, db_verify_at_commit, 0); | |
| 222 | - db.nPriorChanges = sqlite3_total_changes(g.db); | |
| 223 | - db.doRollback = 0; | |
| 224 | - db.zStartFile = zStartFile; | |
| 225 | - db.iStartLine = iStartLine; | |
| 226 | - db.wrTxn = 1; | |
| 220 | + if( !db_is_writeable("repository") ){ | |
| 221 | + db_multi_exec("BEGIN"); | |
| 222 | + }else{ | |
| 223 | + db_multi_exec("BEGIN IMMEDIATE"); | |
| 224 | + sqlite3_commit_hook(g.db, db_verify_at_commit, 0); | |
| 225 | + db.nPriorChanges = sqlite3_total_changes(g.db); | |
| 226 | + db.doRollback = 0; | |
| 227 | + db.zStartFile = zStartFile; | |
| 228 | + db.iStartLine = iStartLine; | |
| 229 | + db.wrTxn = 1; | |
| 230 | + } | |
| 227 | 231 | }else if( !db.wrTxn ){ |
| 228 | 232 | fossil_warning("read txn at %s:%d might cause SQLITE_BUSY " |
| 229 | 233 | "for the write txn at %s:%d", |
| 230 | 234 | db.zStartFile, db.iStartLine, zStartFile, iStartLine); |
| 231 | 235 | } |
| 232 | 236 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -215,17 +215,21 @@ | |
| 215 | /* |
| 216 | ** Begin a new transaction for writing. |
| 217 | */ |
| 218 | void db_begin_write_real(const char *zStartFile, int iStartLine){ |
| 219 | if( db.nBegin==0 ){ |
| 220 | db_multi_exec("BEGIN IMMEDIATE"); |
| 221 | sqlite3_commit_hook(g.db, db_verify_at_commit, 0); |
| 222 | db.nPriorChanges = sqlite3_total_changes(g.db); |
| 223 | db.doRollback = 0; |
| 224 | db.zStartFile = zStartFile; |
| 225 | db.iStartLine = iStartLine; |
| 226 | db.wrTxn = 1; |
| 227 | }else if( !db.wrTxn ){ |
| 228 | fossil_warning("read txn at %s:%d might cause SQLITE_BUSY " |
| 229 | "for the write txn at %s:%d", |
| 230 | db.zStartFile, db.iStartLine, zStartFile, iStartLine); |
| 231 | } |
| 232 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -215,17 +215,21 @@ | |
| 215 | /* |
| 216 | ** Begin a new transaction for writing. |
| 217 | */ |
| 218 | void db_begin_write_real(const char *zStartFile, int iStartLine){ |
| 219 | if( db.nBegin==0 ){ |
| 220 | if( !db_is_writeable("repository") ){ |
| 221 | db_multi_exec("BEGIN"); |
| 222 | }else{ |
| 223 | db_multi_exec("BEGIN IMMEDIATE"); |
| 224 | sqlite3_commit_hook(g.db, db_verify_at_commit, 0); |
| 225 | db.nPriorChanges = sqlite3_total_changes(g.db); |
| 226 | db.doRollback = 0; |
| 227 | db.zStartFile = zStartFile; |
| 228 | db.iStartLine = iStartLine; |
| 229 | db.wrTxn = 1; |
| 230 | } |
| 231 | }else if( !db.wrTxn ){ |
| 232 | fossil_warning("read txn at %s:%d might cause SQLITE_BUSY " |
| 233 | "for the write txn at %s:%d", |
| 234 | db.zStartFile, db.iStartLine, zStartFile, iStartLine); |
| 235 | } |
| 236 |
+3
-1
| --- src/hook.c | ||
| +++ src/hook.c | ||
| @@ -122,11 +122,13 @@ | ||
| 122 | 122 | ** |
| 123 | 123 | ** If N==0, then there is no expectation of new artifacts arriving |
| 124 | 124 | ** soon and so post-receive hooks can be run without delay. |
| 125 | 125 | */ |
| 126 | 126 | void hook_expecting_more_artifacts(int N){ |
| 127 | - if( N>0 ){ | |
| 127 | + if( !db_is_writeable("repository") ){ | |
| 128 | + /* No-op */ | |
| 129 | + }else if( N>0 ){ | |
| 128 | 130 | db_unprotect(PROTECT_CONFIG); |
| 129 | 131 | db_multi_exec( |
| 130 | 132 | "REPLACE INTO config(name,value,mtime)" |
| 131 | 133 | "VALUES('hook-embargo',now()+%d,now())", |
| 132 | 134 | N |
| 133 | 135 |
| --- src/hook.c | |
| +++ src/hook.c | |
| @@ -122,11 +122,13 @@ | |
| 122 | ** |
| 123 | ** If N==0, then there is no expectation of new artifacts arriving |
| 124 | ** soon and so post-receive hooks can be run without delay. |
| 125 | */ |
| 126 | void hook_expecting_more_artifacts(int N){ |
| 127 | if( N>0 ){ |
| 128 | db_unprotect(PROTECT_CONFIG); |
| 129 | db_multi_exec( |
| 130 | "REPLACE INTO config(name,value,mtime)" |
| 131 | "VALUES('hook-embargo',now()+%d,now())", |
| 132 | N |
| 133 |
| --- src/hook.c | |
| +++ src/hook.c | |
| @@ -122,11 +122,13 @@ | |
| 122 | ** |
| 123 | ** If N==0, then there is no expectation of new artifacts arriving |
| 124 | ** soon and so post-receive hooks can be run without delay. |
| 125 | */ |
| 126 | void hook_expecting_more_artifacts(int N){ |
| 127 | if( !db_is_writeable("repository") ){ |
| 128 | /* No-op */ |
| 129 | }else if( N>0 ){ |
| 130 | db_unprotect(PROTECT_CONFIG); |
| 131 | db_multi_exec( |
| 132 | "REPLACE INTO config(name,value,mtime)" |
| 133 | "VALUES('hook-embargo',now()+%d,now())", |
| 134 | N |
| 135 |