Fossil SCM

Copy the control settings into the new repository as well. Also, correct the query used to copy the system user column values.

mistachkin 2012-09-18 20:59 UTC newTemplate
Commit 4bab4459b62857022413e4aee5d6ab94ac67b8d2
1 file changed +28 -7
+28 -7
--- src/db.c
+++ src/db.c
@@ -1221,10 +1221,30 @@
12211221
"INSERT INTO user(login,pw,cap,info)"
12221222
" VALUES('reader','','kptw','Reader');"
12231223
);
12241224
}
12251225
}
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
+}
12261246
12271247
/*
12281248
** Fill an empty repository database with the basic information for a
12291249
** repository. This function is shared between 'create_repository_cmd'
12301250
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
@@ -1272,13 +1292,14 @@
12721292
** Copy all settings from the supplied template repository.
12731293
*/
12741294
db_multi_exec(
12751295
"INSERT OR REPLACE INTO config"
12761296
" SELECT name,value,mtime FROM settingSrc.config"
1277
- " WHERE name IN %s"
1297
+ " WHERE (name IN %s OR name IN %s)"
12781298
" AND name NOT GLOB 'project-*';",
1279
- configure_inop_rhs(CONFIGSET_ALL)
1299
+ configure_inop_rhs(CONFIGSET_ALL),
1300
+ db_setting_inop_rhs()
12801301
);
12811302
db_multi_exec(
12821303
"REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;"
12831304
);
12841305
@@ -1290,18 +1311,18 @@
12901311
** data specific to the other repository. The list of columns copied
12911312
** by this SQL statement may need to be revised in the future.
12921313
*/
12931314
db_multi_exec("UPDATE user SET"
12941315
" cap = (SELECT u2.cap FROM settingSrc.user u2"
1295
- " WHERE u2.login = login),"
1316
+ " WHERE u2.login = user.login),"
12961317
" info = (SELECT u2.info FROM settingSrc.user u2"
1297
- " WHERE u2.login = login),"
1318
+ " WHERE u2.login = user.login),"
12981319
" mtime = (SELECT u2.mtime FROM settingSrc.user u2"
1299
- " WHERE u2.login = login),"
1320
+ " WHERE u2.login = user.login),"
13001321
" 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');"
13031324
);
13041325
}
13051326
13061327
if( zInitialDate ){
13071328
int rid;
13081329
--- 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

Keyboard Shortcuts

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