Fossil SCM

Better defaults for new databases and clones. Use *CURRENT* to identify the current checkout for TTY timelines.

drh 2007-09-26 02:00 trunk
Commit 097479f99a066273a51e6c2444b2a4b7892d5026
+5 -3
--- src/clone.c
+++ src/clone.c
@@ -45,23 +45,25 @@
4545
fossil_panic("file already exists: %s", g.argv[3]);
4646
}
4747
url_parse(g.argv[2]);
4848
db_create_repository(g.argv[3]);
4949
db_open_repository(g.argv[3]);
50
+ db_begin_transaction();
51
+ db_initial_setup(0, 0);
5052
user_select();
5153
db_set("content-schema", CONTENT_SCHEMA);
5254
db_set("aux-schema", AUX_SCHEMA);
5355
if( !g.urlIsFile ){
5456
db_set("last-sync-url", g.argv[2]);
5557
}
5658
db_multi_exec(
57
- "INSERT INTO config(name,value) VALUES('server-code', hex(randomblob(20)));"
59
+ "INSERT INTO config(name,value)"
60
+ " VALUES('server-code', lower(hex(randomblob(20))));"
5861
);
5962
if( g.urlIsFile ){
6063
Stmt q;
6164
db_multi_exec("ATTACH DATABASE %Q AS orig", g.urlName);
62
- db_begin_transaction();
6365
db_prepare(&q,
6466
"SELECT name FROM orig.sqlite_master"
6567
" WHERE type='table'"
6668
);
6769
while( db_step(&q)==SQLITE_ROW ){
@@ -68,10 +70,10 @@
6870
const char *zTab = db_column_text(&q, 0);
6971
db_multi_exec("INSERT OR IGNORE INTO %Q SELECT * FROM orig.%Q",
7072
zTab, zTab);
7173
}
7274
db_finalize(&q);
73
- db_end_transaction(0);
7475
}else{
7576
client_sync(0,0,1);
7677
}
78
+ db_end_transaction(0);
7779
}
7880
--- src/clone.c
+++ src/clone.c
@@ -45,23 +45,25 @@
45 fossil_panic("file already exists: %s", g.argv[3]);
46 }
47 url_parse(g.argv[2]);
48 db_create_repository(g.argv[3]);
49 db_open_repository(g.argv[3]);
 
 
50 user_select();
51 db_set("content-schema", CONTENT_SCHEMA);
52 db_set("aux-schema", AUX_SCHEMA);
53 if( !g.urlIsFile ){
54 db_set("last-sync-url", g.argv[2]);
55 }
56 db_multi_exec(
57 "INSERT INTO config(name,value) VALUES('server-code', hex(randomblob(20)));"
 
58 );
59 if( g.urlIsFile ){
60 Stmt q;
61 db_multi_exec("ATTACH DATABASE %Q AS orig", g.urlName);
62 db_begin_transaction();
63 db_prepare(&q,
64 "SELECT name FROM orig.sqlite_master"
65 " WHERE type='table'"
66 );
67 while( db_step(&q)==SQLITE_ROW ){
@@ -68,10 +70,10 @@
68 const char *zTab = db_column_text(&q, 0);
69 db_multi_exec("INSERT OR IGNORE INTO %Q SELECT * FROM orig.%Q",
70 zTab, zTab);
71 }
72 db_finalize(&q);
73 db_end_transaction(0);
74 }else{
75 client_sync(0,0,1);
76 }
 
77 }
78
--- src/clone.c
+++ src/clone.c
@@ -45,23 +45,25 @@
45 fossil_panic("file already exists: %s", g.argv[3]);
46 }
47 url_parse(g.argv[2]);
48 db_create_repository(g.argv[3]);
49 db_open_repository(g.argv[3]);
50 db_begin_transaction();
51 db_initial_setup(0, 0);
52 user_select();
53 db_set("content-schema", CONTENT_SCHEMA);
54 db_set("aux-schema", AUX_SCHEMA);
55 if( !g.urlIsFile ){
56 db_set("last-sync-url", g.argv[2]);
57 }
58 db_multi_exec(
59 "INSERT INTO config(name,value)"
60 " VALUES('server-code', lower(hex(randomblob(20))));"
61 );
62 if( g.urlIsFile ){
63 Stmt q;
64 db_multi_exec("ATTACH DATABASE %Q AS orig", g.urlName);
 
65 db_prepare(&q,
66 "SELECT name FROM orig.sqlite_master"
67 " WHERE type='table'"
68 );
69 while( db_step(&q)==SQLITE_ROW ){
@@ -68,10 +70,10 @@
70 const char *zTab = db_column_text(&q, 0);
71 db_multi_exec("INSERT OR IGNORE INTO %Q SELECT * FROM orig.%Q",
72 zTab, zTab);
73 }
74 db_finalize(&q);
 
75 }else{
76 client_sync(0,0,1);
77 }
78 db_end_transaction(0);
79 }
80
+1 -1
--- src/construct.c
+++ src/construct.c
@@ -140,11 +140,11 @@
140140
db_create_repository(zRepository);
141141
db_open_repository(zRepository);
142142
db_open_config();
143143
db_begin_transaction();
144144
145
- db_initial_setup(0);
145
+ db_initial_setup(0, 1);
146146
147147
printf("project-id: %s\n", db_get("project-code", 0));
148148
printf("server-id: %s\n", db_get("server-code", 0));
149149
printf("admin-user: %s (no password set yet!)\n", g.zLogin);
150150
printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
151151
--- src/construct.c
+++ src/construct.c
@@ -140,11 +140,11 @@
140 db_create_repository(zRepository);
141 db_open_repository(zRepository);
142 db_open_config();
143 db_begin_transaction();
144
145 db_initial_setup(0);
146
147 printf("project-id: %s\n", db_get("project-code", 0));
148 printf("server-id: %s\n", db_get("server-code", 0));
149 printf("admin-user: %s (no password set yet!)\n", g.zLogin);
150 printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
151
--- src/construct.c
+++ src/construct.c
@@ -140,11 +140,11 @@
140 db_create_repository(zRepository);
141 db_open_repository(zRepository);
142 db_open_config();
143 db_begin_transaction();
144
145 db_initial_setup(0, 1);
146
147 printf("project-id: %s\n", db_get("project-code", 0));
148 printf("server-id: %s\n", db_get("server-code", 0));
149 printf("admin-user: %s (no password set yet!)\n", g.zLogin);
150 printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
151
+27 -13
--- src/db.c
+++ src/db.c
@@ -673,27 +673,32 @@
673673
** Fill an empty repository database with the basic information for a
674674
** repository. This function is shared between 'create_repository_cmd'
675675
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
676676
** new repositories.
677677
**
678
-** The caller determines wheter the function inserts an empty root
679
-** manifest (zRoot == TRUE), or not (zRoot == FALSE).
678
+** The makeInitialVersion flag determines whether or not an initial
679
+** manifest is created. The makeServerCodes flag determines whether or
680
+** not server and project codes are invented for this repository.
680681
*/
681
-
682
-void db_initial_setup (int zRoot){
682
+void db_initial_setup (int makeInitialVersion, int makeServerCodes){
683683
char *zDate;
684684
char *zUser;
685685
Blob hash;
686686
Blob manifest;
687687
688688
db_set("content-schema", CONTENT_SCHEMA);
689689
db_set("aux-schema", AUX_SCHEMA);
690
- db_set_int("authenticate-localhost", 0);
691
- db_multi_exec(
692
- "INSERT INTO config(name,value) VALUES('server-code', hex(randomblob(20)));"
693
- "INSERT INTO config(name,value) VALUES('project-code',hex(randomblob(20)));"
694
- );
690
+ if( makeServerCodes ){
691
+ db_multi_exec(
692
+ "INSERT INTO config(name,value)"
693
+ " VALUES('server-code', lower(hex(randomblob(20))));"
694
+ "INSERT INTO config(name,value)"
695
+ " VALUES('project-code', lower(hex(randomblob(20))));"
696
+ );
697
+ }
698
+ db_set_int("autosync", 1);
699
+ db_set_int("localauth", 0);
695700
zUser = db_global_get("default-user", 0);
696701
if( zUser==0 ){
697702
zUser = getenv("USER");
698703
}
699704
if( zUser==0 ){
@@ -709,11 +714,11 @@
709714
"INSERT INTO user(login,pw,cap,info)"
710715
" VALUES('nobody','','jor','Nobody');"
711716
);
712717
user_select();
713718
714
- if (zRoot){
719
+ if (makeInitialVersion){
715720
blob_zero(&manifest);
716721
blob_appendf(&manifest, "C initial\\sempty\\sbaseline\n");
717722
zDate = db_text(0, "SELECT datetime('now')");
718723
zDate[10]='T';
719724
blob_appendf(&manifest, "D %s\n", zDate);
@@ -742,11 +747,11 @@
742747
}
743748
db_create_repository(g.argv[2]);
744749
db_open_repository(g.argv[2]);
745750
db_open_config();
746751
db_begin_transaction();
747
- db_initial_setup (1);
752
+ db_initial_setup(1, 1);
748753
db_end_transaction(0);
749754
printf("project-id: %s\n", db_get("project-code", 0));
750755
printf("server-id: %s\n", db_get("server-code", 0));
751756
printf("admin-user: %s (no password set yet!)\n", g.zLogin);
752757
printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
@@ -963,16 +968,25 @@
963968
** COMMAND: setting
964969
** %fossil setting ?PROPERTY? ?VALUE?
965970
**
966971
** With no arguments, list all properties and their values. With just
967972
** a property name, show the value of that property. With a value
968
-** arugment, change the property for the current repository.
973
+** argument, change the property for the current repository.
974
+**
975
+** autosync If enabled, automatically pull prior to
976
+** commit or update and automatically push
977
+** after commit or tag or branch creation.
978
+**
979
+** localauth If true, require that HTTP connections from
980
+** 127.0.0.1 be authenticated by password. If
981
+** false, all HTTP requests from localhost have
982
+** unrestricted access to the repository.
969983
*/
970984
void setting_cmd(void){
971985
static const char *azName[] = {
972986
"autosync",
973
- "safemerge"
987
+ "localauth"
974988
};
975989
int i;
976990
db_find_and_open_repository();
977991
if( g.argc==2 ){
978992
for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
979993
--- src/db.c
+++ src/db.c
@@ -673,27 +673,32 @@
673 ** Fill an empty repository database with the basic information for a
674 ** repository. This function is shared between 'create_repository_cmd'
675 ** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
676 ** new repositories.
677 **
678 ** The caller determines wheter the function inserts an empty root
679 ** manifest (zRoot == TRUE), or not (zRoot == FALSE).
 
680 */
681
682 void db_initial_setup (int zRoot){
683 char *zDate;
684 char *zUser;
685 Blob hash;
686 Blob manifest;
687
688 db_set("content-schema", CONTENT_SCHEMA);
689 db_set("aux-schema", AUX_SCHEMA);
690 db_set_int("authenticate-localhost", 0);
691 db_multi_exec(
692 "INSERT INTO config(name,value) VALUES('server-code', hex(randomblob(20)));"
693 "INSERT INTO config(name,value) VALUES('project-code',hex(randomblob(20)));"
694 );
 
 
 
 
 
695 zUser = db_global_get("default-user", 0);
696 if( zUser==0 ){
697 zUser = getenv("USER");
698 }
699 if( zUser==0 ){
@@ -709,11 +714,11 @@
709 "INSERT INTO user(login,pw,cap,info)"
710 " VALUES('nobody','','jor','Nobody');"
711 );
712 user_select();
713
714 if (zRoot){
715 blob_zero(&manifest);
716 blob_appendf(&manifest, "C initial\\sempty\\sbaseline\n");
717 zDate = db_text(0, "SELECT datetime('now')");
718 zDate[10]='T';
719 blob_appendf(&manifest, "D %s\n", zDate);
@@ -742,11 +747,11 @@
742 }
743 db_create_repository(g.argv[2]);
744 db_open_repository(g.argv[2]);
745 db_open_config();
746 db_begin_transaction();
747 db_initial_setup (1);
748 db_end_transaction(0);
749 printf("project-id: %s\n", db_get("project-code", 0));
750 printf("server-id: %s\n", db_get("server-code", 0));
751 printf("admin-user: %s (no password set yet!)\n", g.zLogin);
752 printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
@@ -963,16 +968,25 @@
963 ** COMMAND: setting
964 ** %fossil setting ?PROPERTY? ?VALUE?
965 **
966 ** With no arguments, list all properties and their values. With just
967 ** a property name, show the value of that property. With a value
968 ** arugment, change the property for the current repository.
 
 
 
 
 
 
 
 
 
969 */
970 void setting_cmd(void){
971 static const char *azName[] = {
972 "autosync",
973 "safemerge"
974 };
975 int i;
976 db_find_and_open_repository();
977 if( g.argc==2 ){
978 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
979
--- src/db.c
+++ src/db.c
@@ -673,27 +673,32 @@
673 ** Fill an empty repository database with the basic information for a
674 ** repository. This function is shared between 'create_repository_cmd'
675 ** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
676 ** new repositories.
677 **
678 ** The makeInitialVersion flag determines whether or not an initial
679 ** manifest is created. The makeServerCodes flag determines whether or
680 ** not server and project codes are invented for this repository.
681 */
682 void db_initial_setup (int makeInitialVersion, int makeServerCodes){
 
683 char *zDate;
684 char *zUser;
685 Blob hash;
686 Blob manifest;
687
688 db_set("content-schema", CONTENT_SCHEMA);
689 db_set("aux-schema", AUX_SCHEMA);
690 if( makeServerCodes ){
691 db_multi_exec(
692 "INSERT INTO config(name,value)"
693 " VALUES('server-code', lower(hex(randomblob(20))));"
694 "INSERT INTO config(name,value)"
695 " VALUES('project-code', lower(hex(randomblob(20))));"
696 );
697 }
698 db_set_int("autosync", 1);
699 db_set_int("localauth", 0);
700 zUser = db_global_get("default-user", 0);
701 if( zUser==0 ){
702 zUser = getenv("USER");
703 }
704 if( zUser==0 ){
@@ -709,11 +714,11 @@
714 "INSERT INTO user(login,pw,cap,info)"
715 " VALUES('nobody','','jor','Nobody');"
716 );
717 user_select();
718
719 if (makeInitialVersion){
720 blob_zero(&manifest);
721 blob_appendf(&manifest, "C initial\\sempty\\sbaseline\n");
722 zDate = db_text(0, "SELECT datetime('now')");
723 zDate[10]='T';
724 blob_appendf(&manifest, "D %s\n", zDate);
@@ -742,11 +747,11 @@
747 }
748 db_create_repository(g.argv[2]);
749 db_open_repository(g.argv[2]);
750 db_open_config();
751 db_begin_transaction();
752 db_initial_setup(1, 1);
753 db_end_transaction(0);
754 printf("project-id: %s\n", db_get("project-code", 0));
755 printf("server-id: %s\n", db_get("server-code", 0));
756 printf("admin-user: %s (no password set yet!)\n", g.zLogin);
757 printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
@@ -963,16 +968,25 @@
968 ** COMMAND: setting
969 ** %fossil setting ?PROPERTY? ?VALUE?
970 **
971 ** With no arguments, list all properties and their values. With just
972 ** a property name, show the value of that property. With a value
973 ** argument, change the property for the current repository.
974 **
975 ** autosync If enabled, automatically pull prior to
976 ** commit or update and automatically push
977 ** after commit or tag or branch creation.
978 **
979 ** localauth If true, require that HTTP connections from
980 ** 127.0.0.1 be authenticated by password. If
981 ** false, all HTTP requests from localhost have
982 ** unrestricted access to the repository.
983 */
984 void setting_cmd(void){
985 static const char *azName[] = {
986 "autosync",
987 "localauth"
988 };
989 int i;
990 db_find_and_open_repository();
991 if( g.argc==2 ){
992 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
993
+1 -2
--- src/login.c
+++ src/login.c
@@ -228,12 +228,11 @@
228228
/* If the HTTP connection is coming over 127.0.0.1 and if
229229
** local login is disabled, then there is no need to check
230230
** user credentials.
231231
*/
232232
zRemoteAddr = PD("REMOTE_ADDR","nil");
233
- if( strcmp(zRemoteAddr, "127.0.0.1")==0
234
- && db_get_int("authenticate-localhost",1)==0 ){
233
+ if( strcmp(zRemoteAddr, "127.0.0.1")==0 && db_get_int("localauth",0)==0 ){
235234
uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
236235
g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
237236
zCap = "s";
238237
g.noPswd = 1;
239238
}
240239
--- src/login.c
+++ src/login.c
@@ -228,12 +228,11 @@
228 /* If the HTTP connection is coming over 127.0.0.1 and if
229 ** local login is disabled, then there is no need to check
230 ** user credentials.
231 */
232 zRemoteAddr = PD("REMOTE_ADDR","nil");
233 if( strcmp(zRemoteAddr, "127.0.0.1")==0
234 && db_get_int("authenticate-localhost",1)==0 ){
235 uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
236 g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
237 zCap = "s";
238 g.noPswd = 1;
239 }
240
--- src/login.c
+++ src/login.c
@@ -228,12 +228,11 @@
228 /* If the HTTP connection is coming over 127.0.0.1 and if
229 ** local login is disabled, then there is no need to check
230 ** user credentials.
231 */
232 zRemoteAddr = PD("REMOTE_ADDR","nil");
233 if( strcmp(zRemoteAddr, "127.0.0.1")==0 && db_get_int("localauth",0)==0 ){
 
234 uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
235 g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
236 zCap = "s";
237 g.noPswd = 1;
238 }
239
+1 -1
--- src/setup.c
+++ src/setup.c
@@ -497,11 +497,11 @@
497497
db_begin_transaction();
498498
@ <form action="%s(g.zBaseURL)/setup_access" method="POST">
499499
500500
@ <hr>
501501
onoff_attribute("Require password for local access",
502
- "authenticate-localhost", "localauth", 1);
502
+ "localauth", "localauth", 1);
503503
@ <p>When enabled, the password sign-in is required for
504504
@ web access coming from 127.0.0.1. When disabled, web access
505505
@ from 127.0.0.1 is allows without any login - the user id is selected
506506
@ from the ~/.fossil database. Password login is always required
507507
@ for incoming web connections on internet addresses other than
508508
--- src/setup.c
+++ src/setup.c
@@ -497,11 +497,11 @@
497 db_begin_transaction();
498 @ <form action="%s(g.zBaseURL)/setup_access" method="POST">
499
500 @ <hr>
501 onoff_attribute("Require password for local access",
502 "authenticate-localhost", "localauth", 1);
503 @ <p>When enabled, the password sign-in is required for
504 @ web access coming from 127.0.0.1. When disabled, web access
505 @ from 127.0.0.1 is allows without any login - the user id is selected
506 @ from the ~/.fossil database. Password login is always required
507 @ for incoming web connections on internet addresses other than
508
--- src/setup.c
+++ src/setup.c
@@ -497,11 +497,11 @@
497 db_begin_transaction();
498 @ <form action="%s(g.zBaseURL)/setup_access" method="POST">
499
500 @ <hr>
501 onoff_attribute("Require password for local access",
502 "localauth", "localauth", 1);
503 @ <p>When enabled, the password sign-in is required for
504 @ web access coming from 127.0.0.1. When disabled, web access
505 @ from 127.0.0.1 is allows without any login - the user id is selected
506 @ from the ~/.fossil database. Password login is always required
507 @ for incoming web connections on internet addresses other than
508
+1 -1
--- src/sync.c
+++ src/sync.c
@@ -37,11 +37,11 @@
3737
const char *zUrl;
3838
if( db_get_int("autosync", 0)==0 ){
3939
return 0;
4040
}
4141
zUrl = db_get("last-sync-url", 0);
42
- if( zUrl ){
42
+ if( zUrl==0 ){
4343
return 0; /* No default server */
4444
}
4545
url_parse(zUrl);
4646
if( g.urlIsFile ){
4747
return 0; /* Network sync only */
4848
--- src/sync.c
+++ src/sync.c
@@ -37,11 +37,11 @@
37 const char *zUrl;
38 if( db_get_int("autosync", 0)==0 ){
39 return 0;
40 }
41 zUrl = db_get("last-sync-url", 0);
42 if( zUrl ){
43 return 0; /* No default server */
44 }
45 url_parse(zUrl);
46 if( g.urlIsFile ){
47 return 0; /* Network sync only */
48
--- src/sync.c
+++ src/sync.c
@@ -37,11 +37,11 @@
37 const char *zUrl;
38 if( db_get_int("autosync", 0)==0 ){
39 return 0;
40 }
41 zUrl = db_get("last-sync-url", 0);
42 if( zUrl==0 ){
43 return 0; /* No default server */
44 }
45 url_parse(zUrl);
46 if( g.urlIsFile ){
47 return 0; /* Network sync only */
48
+16 -23
--- src/timeline.c
+++ src/timeline.c
@@ -395,11 +395,10 @@
395395
** 5. Number of parents
396396
*/
397397
void print_timeline(Stmt *q, int mxLine){
398398
int nLine = 0;
399399
char zPrevDate[20];
400
- char *delims;
401400
const char *zCurrentUuid=0;
402401
Stmt currentQ;
403402
int rid = db_lget_int("checkout", 0);
404403
zPrevDate[0] = 0;
405404
@@ -416,42 +415,36 @@
416415
const char *zDate = db_column_text(q, 2);
417416
const char *zCom = db_column_text(q, 3);
418417
int nChild = db_column_int(q, 4);
419418
int nParent = db_column_int(q, 5);
420419
char *zFree = 0;
420
+ int n = 0;
421
+ char zPrefix[80];
421422
char zUuid[UUID_SIZE+1];
422423
423
- if( strcmp(zCurrentUuid, zId)==0 ){
424
- delims = "<>";
425
- }else{
426
- delims = "[]";
427
- }
428
-
429424
sprintf(zUuid, "%.10s", zId);
430425
if( memcmp(zDate, zPrevDate, 10) ){
431426
printf("=== %.10s ===\n", zDate);
432427
memcpy(zPrevDate, zDate, 10);
433428
nLine++;
434429
}
435430
if( zCom==0 ) zCom = "";
436431
printf("%.8s ", &zDate[11]);
437
- if( nChild>1 || nParent>1 ){
438
- int n = 0;
439
- char zPrefix[50];
440
- if( nParent>1 ){
441
- sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
442
- n = strlen(zPrefix);
443
- }
444
- if( nChild>1 ){
445
- sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* ");
446
- n = strlen(zPrefix);
447
- }
448
- zFree = sqlite3_mprintf("%c%.10s%c %s%s", delims[0], zUuid, delims[1],
449
- zPrefix, zCom);
450
- }else{
451
- zFree = sqlite3_mprintf("%c%.10s%c %s", delims[0], zUuid, delims[1], zCom);
452
- }
432
+ zPrefix[0] = 0;
433
+ if( nParent>1 ){
434
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
435
+ n = strlen(zPrefix);
436
+ }
437
+ if( nChild>1 ){
438
+ sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* ");
439
+ n = strlen(zPrefix);
440
+ }
441
+ if( strcmp(zCurrentUuid,zId)==0 ){
442
+ sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
443
+ n += strlen(zPrefix);
444
+ }
445
+ zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
453446
nLine += comment_print(zFree, 9, 79);
454447
sqlite3_free(zFree);
455448
}
456449
db_finalize(&currentQ);
457450
}
458451
--- src/timeline.c
+++ src/timeline.c
@@ -395,11 +395,10 @@
395 ** 5. Number of parents
396 */
397 void print_timeline(Stmt *q, int mxLine){
398 int nLine = 0;
399 char zPrevDate[20];
400 char *delims;
401 const char *zCurrentUuid=0;
402 Stmt currentQ;
403 int rid = db_lget_int("checkout", 0);
404 zPrevDate[0] = 0;
405
@@ -416,42 +415,36 @@
416 const char *zDate = db_column_text(q, 2);
417 const char *zCom = db_column_text(q, 3);
418 int nChild = db_column_int(q, 4);
419 int nParent = db_column_int(q, 5);
420 char *zFree = 0;
 
 
421 char zUuid[UUID_SIZE+1];
422
423 if( strcmp(zCurrentUuid, zId)==0 ){
424 delims = "<>";
425 }else{
426 delims = "[]";
427 }
428
429 sprintf(zUuid, "%.10s", zId);
430 if( memcmp(zDate, zPrevDate, 10) ){
431 printf("=== %.10s ===\n", zDate);
432 memcpy(zPrevDate, zDate, 10);
433 nLine++;
434 }
435 if( zCom==0 ) zCom = "";
436 printf("%.8s ", &zDate[11]);
437 if( nChild>1 || nParent>1 ){
438 int n = 0;
439 char zPrefix[50];
440 if( nParent>1 ){
441 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
442 n = strlen(zPrefix);
443 }
444 if( nChild>1 ){
445 sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* ");
446 n = strlen(zPrefix);
447 }
448 zFree = sqlite3_mprintf("%c%.10s%c %s%s", delims[0], zUuid, delims[1],
449 zPrefix, zCom);
450 }else{
451 zFree = sqlite3_mprintf("%c%.10s%c %s", delims[0], zUuid, delims[1], zCom);
452 }
453 nLine += comment_print(zFree, 9, 79);
454 sqlite3_free(zFree);
455 }
456 db_finalize(&currentQ);
457 }
458
--- src/timeline.c
+++ src/timeline.c
@@ -395,11 +395,10 @@
395 ** 5. Number of parents
396 */
397 void print_timeline(Stmt *q, int mxLine){
398 int nLine = 0;
399 char zPrevDate[20];
 
400 const char *zCurrentUuid=0;
401 Stmt currentQ;
402 int rid = db_lget_int("checkout", 0);
403 zPrevDate[0] = 0;
404
@@ -416,42 +415,36 @@
415 const char *zDate = db_column_text(q, 2);
416 const char *zCom = db_column_text(q, 3);
417 int nChild = db_column_int(q, 4);
418 int nParent = db_column_int(q, 5);
419 char *zFree = 0;
420 int n = 0;
421 char zPrefix[80];
422 char zUuid[UUID_SIZE+1];
423
 
 
 
 
 
 
424 sprintf(zUuid, "%.10s", zId);
425 if( memcmp(zDate, zPrevDate, 10) ){
426 printf("=== %.10s ===\n", zDate);
427 memcpy(zPrevDate, zDate, 10);
428 nLine++;
429 }
430 if( zCom==0 ) zCom = "";
431 printf("%.8s ", &zDate[11]);
432 zPrefix[0] = 0;
433 if( nParent>1 ){
434 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
435 n = strlen(zPrefix);
436 }
437 if( nChild>1 ){
438 sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* ");
439 n = strlen(zPrefix);
440 }
441 if( strcmp(zCurrentUuid,zId)==0 ){
442 sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
443 n += strlen(zPrefix);
444 }
445 zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
 
 
446 nLine += comment_print(zFree, 9, 79);
447 sqlite3_free(zFree);
448 }
449 db_finalize(&currentQ);
450 }
451
+3 -2
--- src/user.c
+++ src/user.c
@@ -292,11 +292,12 @@
292292
293293
if( attempt_user(db_get("default-user", 0)) ) return;
294294
295295
if( attempt_user(getenv("USER")) ) return;
296296
297
- db_prepare(&s, "SELECT uid, login FROM user WHERE login<>'anonymous'");
297
+ db_prepare(&s, "SELECT uid, login FROM user"
298
+ " WHERE login NOT IN ('anonymous','nobody')");
298299
if( db_step(&s)==SQLITE_ROW ){
299300
g.userUid = db_column_int(&s, 0);
300301
g.zLogin = mprintf("%s", db_column_text(&s, 1));
301302
}
302303
db_finalize(&s);
@@ -311,11 +312,11 @@
311312
}
312313
313314
if( g.userUid==0 ){
314315
db_multi_exec(
315316
"INSERT INTO user(login, pw, cap, info)"
316
- "VALUES('anonymous', '', '', '')"
317
+ "VALUES('anonymous', '', 'cfghjkmnoqw', '')"
317318
);
318319
g.userUid = db_last_insert_rowid();
319320
g.zLogin = "anonymous";
320321
}
321322
}
322323
--- src/user.c
+++ src/user.c
@@ -292,11 +292,12 @@
292
293 if( attempt_user(db_get("default-user", 0)) ) return;
294
295 if( attempt_user(getenv("USER")) ) return;
296
297 db_prepare(&s, "SELECT uid, login FROM user WHERE login<>'anonymous'");
 
298 if( db_step(&s)==SQLITE_ROW ){
299 g.userUid = db_column_int(&s, 0);
300 g.zLogin = mprintf("%s", db_column_text(&s, 1));
301 }
302 db_finalize(&s);
@@ -311,11 +312,11 @@
311 }
312
313 if( g.userUid==0 ){
314 db_multi_exec(
315 "INSERT INTO user(login, pw, cap, info)"
316 "VALUES('anonymous', '', '', '')"
317 );
318 g.userUid = db_last_insert_rowid();
319 g.zLogin = "anonymous";
320 }
321 }
322
--- src/user.c
+++ src/user.c
@@ -292,11 +292,12 @@
292
293 if( attempt_user(db_get("default-user", 0)) ) return;
294
295 if( attempt_user(getenv("USER")) ) return;
296
297 db_prepare(&s, "SELECT uid, login FROM user"
298 " WHERE login NOT IN ('anonymous','nobody')");
299 if( db_step(&s)==SQLITE_ROW ){
300 g.userUid = db_column_int(&s, 0);
301 g.zLogin = mprintf("%s", db_column_text(&s, 1));
302 }
303 db_finalize(&s);
@@ -311,11 +312,11 @@
312 }
313
314 if( g.userUid==0 ){
315 db_multi_exec(
316 "INSERT INTO user(login, pw, cap, info)"
317 "VALUES('anonymous', '', 'cfghjkmnoqw', '')"
318 );
319 g.userUid = db_last_insert_rowid();
320 g.zLogin = "anonymous";
321 }
322 }
323

Keyboard Shortcuts

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