Differences From:
File
src/db.c
part of check-in
[fff234b77c]
- Updates to the autosync logic. Add the "setting" command.
by
drh on
2007-09-25 20:23:52.
[view]
To:
File
src/db.c
part of check-in
[097479f99a]
- Better defaults for new databases and clones. Use *CURRENT* to identify
the current checkout for TTY timelines.
by
drh on
2007-09-26 02:00:26.
[view]
@@ -674,25 +674,30 @@
** repository. This function is shared between 'create_repository_cmd'
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
** new repositories.
**
-** The caller determines wheter the function inserts an empty root
-** manifest (zRoot == TRUE), or not (zRoot == FALSE).
+** The makeInitialVersion flag determines whether or not an initial
+** manifest is created. The makeServerCodes flag determines whether or
+** not server and project codes are invented for this repository.
*/
-
-void db_initial_setup (int zRoot){
+void db_initial_setup (int makeInitialVersion, int makeServerCodes){
char *zDate;
char *zUser;
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA);
db_set("aux-schema", AUX_SCHEMA);
- db_set_int("authenticate-localhost", 0);
- db_multi_exec(
- "INSERT INTO config(name,value) VALUES('server-code', hex(randomblob(20)));"
- "INSERT INTO config(name,value) VALUES('project-code',hex(randomblob(20)));"
- );
+ if( makeServerCodes ){
+ db_multi_exec(
+ "INSERT INTO config(name,value)"
+ " VALUES('server-code', lower(hex(randomblob(20))));"
+ "INSERT INTO config(name,value)"
+ " VALUES('project-code', lower(hex(randomblob(20))));"
+ );
+ }
+ db_set_int("autosync", 1);
+ db_set_int("localauth", 0);
zUser = db_global_get("default-user", 0);
if( zUser==0 ){
zUser = getenv("USER");
}
@@ -710,9 +715,9 @@
" VALUES('nobody','','jor','Nobody');"
);
user_select();
- if (zRoot){
+ if (makeInitialVersion){
blob_zero(&manifest);
blob_appendf(&manifest, "C initial\\sempty\\sbaseline\n");
zDate = db_text(0, "SELECT datetime('now')");
zDate[10]='T';
@@ -743,9 +748,9 @@
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
db_open_config();
db_begin_transaction();
- db_initial_setup (1);
+ db_initial_setup(1, 1);
db_end_transaction(0);
printf("project-id: %s\n", db_get("project-code", 0));
printf("server-id: %s\n", db_get("server-code", 0));
printf("admin-user: %s (no password set yet!)\n", g.zLogin);
@@ -964,14 +969,23 @@
** %fossil setting ?PROPERTY? ?VALUE?
**
** With no arguments, list all properties and their values. With just
** a property name, show the value of that property. With a value
-** arugment, change the property for the current repository.
+** argument, change the property for the current repository.
+**
+** autosync If enabled, automatically pull prior to
+** commit or update and automatically push
+** after commit or tag or branch creation.
+**
+** localauth If true, require that HTTP connections from
+** 127.0.0.1 be authenticated by password. If
+** false, all HTTP requests from localhost have
+** unrestricted access to the repository.
*/
void setting_cmd(void){
static const char *azName[] = {
"autosync",
- "safemerge"
+ "localauth"
};
int i;
db_find_and_open_repository();
if( g.argc==2 ){