Fossil SCM

Fix the server-side clone so that it is able to operate on a read-only repository database.

drh 2020-08-27 01:37 trunk
Commit 147bf47d6e145686550304ec8061281e5557ac419151e2109c95819e6be02984
2 files changed +11 -7 +3 -1
+11 -7
--- src/db.c
+++ src/db.c
@@ -215,17 +215,21 @@
215215
/*
216216
** Begin a new transaction for writing.
217217
*/
218218
void db_begin_write_real(const char *zStartFile, int iStartLine){
219219
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
+ }
227231
}else if( !db.wrTxn ){
228232
fossil_warning("read txn at %s:%d might cause SQLITE_BUSY "
229233
"for the write txn at %s:%d",
230234
db.zStartFile, db.iStartLine, zStartFile, iStartLine);
231235
}
232236
--- 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 @@
122122
**
123123
** If N==0, then there is no expectation of new artifacts arriving
124124
** soon and so post-receive hooks can be run without delay.
125125
*/
126126
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 ){
128130
db_unprotect(PROTECT_CONFIG);
129131
db_multi_exec(
130132
"REPLACE INTO config(name,value,mtime)"
131133
"VALUES('hook-embargo',now()+%d,now())",
132134
N
133135
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button