Fossil SCM
Copy the control settings into the new repository as well. Also, correct the query used to copy the system user column values.
Commit
4bab4459b62857022413e4aee5d6ab94ac67b8d2
Parent
78cf4138d9ab721…
1 file changed
+28
-7
M
src/db.c
+28
-7
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1221,10 +1221,30 @@ | ||
| 1221 | 1221 | "INSERT INTO user(login,pw,cap,info)" |
| 1222 | 1222 | " VALUES('reader','','kptw','Reader');" |
| 1223 | 1223 | ); |
| 1224 | 1224 | } |
| 1225 | 1225 | } |
| 1226 | + | |
| 1227 | +/* | |
| 1228 | +** Return a pointer to a string that contains the RHS of an IN operator | |
| 1229 | +** that will select CONFIG table names that are in the list of control | |
| 1230 | +** settings. | |
| 1231 | +*/ | |
| 1232 | +const char *db_setting_inop_rhs(){ | |
| 1233 | + Blob x; | |
| 1234 | + int i; | |
| 1235 | + const char *zSep = ""; | |
| 1236 | + | |
| 1237 | + blob_zero(&x); | |
| 1238 | + blob_append(&x, "(", 1); | |
| 1239 | + for(i=0; ctrlSettings[i].name; i++){ | |
| 1240 | + blob_appendf(&x, "%s'%s'", zSep, ctrlSettings[i].name); | |
| 1241 | + zSep = ","; | |
| 1242 | + } | |
| 1243 | + blob_append(&x, ")", 1); | |
| 1244 | + return blob_str(&x); | |
| 1245 | +} | |
| 1226 | 1246 | |
| 1227 | 1247 | /* |
| 1228 | 1248 | ** Fill an empty repository database with the basic information for a |
| 1229 | 1249 | ** repository. This function is shared between 'create_repository_cmd' |
| 1230 | 1250 | ** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create |
| @@ -1272,13 +1292,14 @@ | ||
| 1272 | 1292 | ** Copy all settings from the supplied template repository. |
| 1273 | 1293 | */ |
| 1274 | 1294 | db_multi_exec( |
| 1275 | 1295 | "INSERT OR REPLACE INTO config" |
| 1276 | 1296 | " SELECT name,value,mtime FROM settingSrc.config" |
| 1277 | - " WHERE name IN %s" | |
| 1297 | + " WHERE (name IN %s OR name IN %s)" | |
| 1278 | 1298 | " AND name NOT GLOB 'project-*';", |
| 1279 | - configure_inop_rhs(CONFIGSET_ALL) | |
| 1299 | + configure_inop_rhs(CONFIGSET_ALL), | |
| 1300 | + db_setting_inop_rhs() | |
| 1280 | 1301 | ); |
| 1281 | 1302 | db_multi_exec( |
| 1282 | 1303 | "REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;" |
| 1283 | 1304 | ); |
| 1284 | 1305 | |
| @@ -1290,18 +1311,18 @@ | ||
| 1290 | 1311 | ** data specific to the other repository. The list of columns copied |
| 1291 | 1312 | ** by this SQL statement may need to be revised in the future. |
| 1292 | 1313 | */ |
| 1293 | 1314 | db_multi_exec("UPDATE user SET" |
| 1294 | 1315 | " cap = (SELECT u2.cap FROM settingSrc.user u2" |
| 1295 | - " WHERE u2.login = login)," | |
| 1316 | + " WHERE u2.login = user.login)," | |
| 1296 | 1317 | " info = (SELECT u2.info FROM settingSrc.user u2" |
| 1297 | - " WHERE u2.login = login)," | |
| 1318 | + " WHERE u2.login = user.login)," | |
| 1298 | 1319 | " mtime = (SELECT u2.mtime FROM settingSrc.user u2" |
| 1299 | - " WHERE u2.login = login)," | |
| 1320 | + " WHERE u2.login = user.login)," | |
| 1300 | 1321 | " photo = (SELECT u2.photo FROM settingSrc.user u2" |
| 1301 | - " WHERE u2.login = login)" | |
| 1302 | - " WHERE login IN ('anonymous','nobody','developer','reader');" | |
| 1322 | + " WHERE u2.login = user.login)" | |
| 1323 | + " WHERE user.login IN ('anonymous','nobody','developer','reader');" | |
| 1303 | 1324 | ); |
| 1304 | 1325 | } |
| 1305 | 1326 | |
| 1306 | 1327 | if( zInitialDate ){ |
| 1307 | 1328 | int rid; |
| 1308 | 1329 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1221,10 +1221,30 @@ | |
| 1221 | "INSERT INTO user(login,pw,cap,info)" |
| 1222 | " VALUES('reader','','kptw','Reader');" |
| 1223 | ); |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | /* |
| 1228 | ** Fill an empty repository database with the basic information for a |
| 1229 | ** repository. This function is shared between 'create_repository_cmd' |
| 1230 | ** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create |
| @@ -1272,13 +1292,14 @@ | |
| 1272 | ** Copy all settings from the supplied template repository. |
| 1273 | */ |
| 1274 | db_multi_exec( |
| 1275 | "INSERT OR REPLACE INTO config" |
| 1276 | " SELECT name,value,mtime FROM settingSrc.config" |
| 1277 | " WHERE name IN %s" |
| 1278 | " AND name NOT GLOB 'project-*';", |
| 1279 | configure_inop_rhs(CONFIGSET_ALL) |
| 1280 | ); |
| 1281 | db_multi_exec( |
| 1282 | "REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;" |
| 1283 | ); |
| 1284 | |
| @@ -1290,18 +1311,18 @@ | |
| 1290 | ** data specific to the other repository. The list of columns copied |
| 1291 | ** by this SQL statement may need to be revised in the future. |
| 1292 | */ |
| 1293 | db_multi_exec("UPDATE user SET" |
| 1294 | " cap = (SELECT u2.cap FROM settingSrc.user u2" |
| 1295 | " WHERE u2.login = login)," |
| 1296 | " info = (SELECT u2.info FROM settingSrc.user u2" |
| 1297 | " WHERE u2.login = login)," |
| 1298 | " mtime = (SELECT u2.mtime FROM settingSrc.user u2" |
| 1299 | " WHERE u2.login = login)," |
| 1300 | " photo = (SELECT u2.photo FROM settingSrc.user u2" |
| 1301 | " WHERE u2.login = login)" |
| 1302 | " WHERE login IN ('anonymous','nobody','developer','reader');" |
| 1303 | ); |
| 1304 | } |
| 1305 | |
| 1306 | if( zInitialDate ){ |
| 1307 | int rid; |
| 1308 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1221,10 +1221,30 @@ | |
| 1221 | "INSERT INTO user(login,pw,cap,info)" |
| 1222 | " VALUES('reader','','kptw','Reader');" |
| 1223 | ); |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | /* |
| 1228 | ** Return a pointer to a string that contains the RHS of an IN operator |
| 1229 | ** that will select CONFIG table names that are in the list of control |
| 1230 | ** settings. |
| 1231 | */ |
| 1232 | const char *db_setting_inop_rhs(){ |
| 1233 | Blob x; |
| 1234 | int i; |
| 1235 | const char *zSep = ""; |
| 1236 | |
| 1237 | blob_zero(&x); |
| 1238 | blob_append(&x, "(", 1); |
| 1239 | for(i=0; ctrlSettings[i].name; i++){ |
| 1240 | blob_appendf(&x, "%s'%s'", zSep, ctrlSettings[i].name); |
| 1241 | zSep = ","; |
| 1242 | } |
| 1243 | blob_append(&x, ")", 1); |
| 1244 | return blob_str(&x); |
| 1245 | } |
| 1246 | |
| 1247 | /* |
| 1248 | ** Fill an empty repository database with the basic information for a |
| 1249 | ** repository. This function is shared between 'create_repository_cmd' |
| 1250 | ** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create |
| @@ -1272,13 +1292,14 @@ | |
| 1292 | ** Copy all settings from the supplied template repository. |
| 1293 | */ |
| 1294 | db_multi_exec( |
| 1295 | "INSERT OR REPLACE INTO config" |
| 1296 | " SELECT name,value,mtime FROM settingSrc.config" |
| 1297 | " WHERE (name IN %s OR name IN %s)" |
| 1298 | " AND name NOT GLOB 'project-*';", |
| 1299 | configure_inop_rhs(CONFIGSET_ALL), |
| 1300 | db_setting_inop_rhs() |
| 1301 | ); |
| 1302 | db_multi_exec( |
| 1303 | "REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;" |
| 1304 | ); |
| 1305 | |
| @@ -1290,18 +1311,18 @@ | |
| 1311 | ** data specific to the other repository. The list of columns copied |
| 1312 | ** by this SQL statement may need to be revised in the future. |
| 1313 | */ |
| 1314 | db_multi_exec("UPDATE user SET" |
| 1315 | " cap = (SELECT u2.cap FROM settingSrc.user u2" |
| 1316 | " WHERE u2.login = user.login)," |
| 1317 | " info = (SELECT u2.info FROM settingSrc.user u2" |
| 1318 | " WHERE u2.login = user.login)," |
| 1319 | " mtime = (SELECT u2.mtime FROM settingSrc.user u2" |
| 1320 | " WHERE u2.login = user.login)," |
| 1321 | " photo = (SELECT u2.photo FROM settingSrc.user u2" |
| 1322 | " WHERE u2.login = user.login)" |
| 1323 | " WHERE user.login IN ('anonymous','nobody','developer','reader');" |
| 1324 | ); |
| 1325 | } |
| 1326 | |
| 1327 | if( zInitialDate ){ |
| 1328 | int rid; |
| 1329 |