Fossil SCM

Add the ability to modify global settings (such as the proxy setting) even when there are no repositories defined.

drh 2008-05-05 17:24 trunk
Commit 4e683ef07b04f5f27ab860c8737fb8b92975ac54
+1 -1
--- src/branch.c
+++ src/branch.c
@@ -176,11 +176,11 @@
176176
** List all branches
177177
**
178178
*/
179179
void branch_cmd(void){
180180
int n;
181
- db_find_and_open_repository();
181
+ db_find_and_open_repository(1);
182182
if( g.argc<3 ){
183183
usage("new|list ...");
184184
}
185185
n = strlen(g.argv[2]);
186186
if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
187187
--- src/branch.c
+++ src/branch.c
@@ -176,11 +176,11 @@
176 ** List all branches
177 **
178 */
179 void branch_cmd(void){
180 int n;
181 db_find_and_open_repository();
182 if( g.argc<3 ){
183 usage("new|list ...");
184 }
185 n = strlen(g.argv[2]);
186 if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
187
--- src/branch.c
+++ src/branch.c
@@ -176,11 +176,11 @@
176 ** List all branches
177 **
178 */
179 void branch_cmd(void){
180 int n;
181 db_find_and_open_repository(1);
182 if( g.argc<3 ){
183 usage("new|list ...");
184 }
185 n = strlen(g.argv[2]);
186 if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
187
+1 -1
--- src/construct.c
+++ src/construct.c
@@ -88,11 +88,11 @@
8888
Blob zOut;
8989
Stmt q;
9090
if( (g.argc != 3) && (g.argc != 5) ){
9191
usage ("?-R|--repository REPOSITORY? DESTINATION");
9292
}
93
- db_find_and_open_repository ();
93
+ db_find_and_open_repository(1);
9494
zDestination = g.argv[g.argc-1];
9595
if( !file_isdir (zDestination) ){
9696
fossil_panic("not a directory: %s", zDestination);
9797
}
9898
/* Iterate over all blobs in the repository, retrieve their
9999
--- src/construct.c
+++ src/construct.c
@@ -88,11 +88,11 @@
88 Blob zOut;
89 Stmt q;
90 if( (g.argc != 3) && (g.argc != 5) ){
91 usage ("?-R|--repository REPOSITORY? DESTINATION");
92 }
93 db_find_and_open_repository ();
94 zDestination = g.argv[g.argc-1];
95 if( !file_isdir (zDestination) ){
96 fossil_panic("not a directory: %s", zDestination);
97 }
98 /* Iterate over all blobs in the repository, retrieve their
99
--- src/construct.c
+++ src/construct.c
@@ -88,11 +88,11 @@
88 Blob zOut;
89 Stmt q;
90 if( (g.argc != 3) && (g.argc != 5) ){
91 usage ("?-R|--repository REPOSITORY? DESTINATION");
92 }
93 db_find_and_open_repository(1);
94 zDestination = g.argv[g.argc-1];
95 if( !file_isdir (zDestination) ){
96 fossil_panic("not a directory: %s", zDestination);
97 }
98 /* Iterate over all blobs in the repository, retrieve their
99
+22 -9
--- src/db.c
+++ src/db.c
@@ -672,11 +672,11 @@
672672
** option to locate the repository. If no such option is available, then
673673
** use the repository of the open checkout if there is one.
674674
**
675675
** Error out if the repository cannot be opened.
676676
*/
677
-void db_find_and_open_repository(void){
677
+void db_find_and_open_repository(int errIfNotFound){
678678
const char *zRep = find_option("repository", "R", 1);
679679
if( zRep==0 ){
680680
if( db_open_local()==0 ){
681681
goto rep_not_found;
682682
}
@@ -688,11 +688,13 @@
688688
db_open_repository(zRep);
689689
if( g.repositoryOpen ){
690690
return;
691691
}
692692
rep_not_found:
693
- fossil_fatal("use --repository or -R to specific the repository database");
693
+ if( errIfNotFound ){
694
+ fossil_fatal("use --repository or -R to specific the repository database");
695
+ }
694696
}
695697
696698
/*
697699
** Open the local database. If unable, exit with an error.
698700
*/
@@ -1036,16 +1038,23 @@
10361038
/*
10371039
** Print the value of a setting named zName
10381040
*/
10391041
static void print_setting(const char *zName){
10401042
Stmt q;
1041
- db_prepare(&q,
1042
- "SELECT '(local)', value FROM config WHERE name=%Q"
1043
- " UNION ALL "
1044
- "SELECT '(global)', value FROM global_config WHERE name=%Q",
1045
- zName, zName
1046
- );
1043
+ if( g.repositoryOpen ){
1044
+ db_prepare(&q,
1045
+ "SELECT '(local)', value FROM config WHERE name=%Q"
1046
+ " UNION ALL "
1047
+ "SELECT '(global)', value FROM global_config WHERE name=%Q",
1048
+ zName, zName
1049
+ );
1050
+ }else{
1051
+ db_prepare(&q,
1052
+ "SELECT '(global)', value FROM global_config WHERE name=%Q",
1053
+ zName
1054
+ );
1055
+ }
10471056
if( db_step(&q)==SQLITE_ROW ){
10481057
printf("%-20s %-8s %s\n", zName, db_column_text(&q, 0),
10491058
db_column_text(&q, 1));
10501059
}else{
10511060
printf("%-20s\n", zName);
@@ -1098,11 +1107,15 @@
10981107
"diff-command",
10991108
"gdiff-command",
11001109
};
11011110
int i;
11021111
int globalFlag = find_option("global","g",0)!=0;
1103
- db_find_and_open_repository();
1112
+ db_find_and_open_repository(0);
1113
+ if( !g.repositoryOpen ){
1114
+ db_open_config();
1115
+ globalFlag = 1;
1116
+ }
11041117
if( g.argc==2 ){
11051118
for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
11061119
print_setting(azName[i]);
11071120
}
11081121
}else if( g.argc==3 || g.argc==4 ){
11091122
--- src/db.c
+++ src/db.c
@@ -672,11 +672,11 @@
672 ** option to locate the repository. If no such option is available, then
673 ** use the repository of the open checkout if there is one.
674 **
675 ** Error out if the repository cannot be opened.
676 */
677 void db_find_and_open_repository(void){
678 const char *zRep = find_option("repository", "R", 1);
679 if( zRep==0 ){
680 if( db_open_local()==0 ){
681 goto rep_not_found;
682 }
@@ -688,11 +688,13 @@
688 db_open_repository(zRep);
689 if( g.repositoryOpen ){
690 return;
691 }
692 rep_not_found:
693 fossil_fatal("use --repository or -R to specific the repository database");
 
 
694 }
695
696 /*
697 ** Open the local database. If unable, exit with an error.
698 */
@@ -1036,16 +1038,23 @@
1036 /*
1037 ** Print the value of a setting named zName
1038 */
1039 static void print_setting(const char *zName){
1040 Stmt q;
1041 db_prepare(&q,
1042 "SELECT '(local)', value FROM config WHERE name=%Q"
1043 " UNION ALL "
1044 "SELECT '(global)', value FROM global_config WHERE name=%Q",
1045 zName, zName
1046 );
 
 
 
 
 
 
 
1047 if( db_step(&q)==SQLITE_ROW ){
1048 printf("%-20s %-8s %s\n", zName, db_column_text(&q, 0),
1049 db_column_text(&q, 1));
1050 }else{
1051 printf("%-20s\n", zName);
@@ -1098,11 +1107,15 @@
1098 "diff-command",
1099 "gdiff-command",
1100 };
1101 int i;
1102 int globalFlag = find_option("global","g",0)!=0;
1103 db_find_and_open_repository();
 
 
 
 
1104 if( g.argc==2 ){
1105 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
1106 print_setting(azName[i]);
1107 }
1108 }else if( g.argc==3 || g.argc==4 ){
1109
--- src/db.c
+++ src/db.c
@@ -672,11 +672,11 @@
672 ** option to locate the repository. If no such option is available, then
673 ** use the repository of the open checkout if there is one.
674 **
675 ** Error out if the repository cannot be opened.
676 */
677 void db_find_and_open_repository(int errIfNotFound){
678 const char *zRep = find_option("repository", "R", 1);
679 if( zRep==0 ){
680 if( db_open_local()==0 ){
681 goto rep_not_found;
682 }
@@ -688,11 +688,13 @@
688 db_open_repository(zRep);
689 if( g.repositoryOpen ){
690 return;
691 }
692 rep_not_found:
693 if( errIfNotFound ){
694 fossil_fatal("use --repository or -R to specific the repository database");
695 }
696 }
697
698 /*
699 ** Open the local database. If unable, exit with an error.
700 */
@@ -1036,16 +1038,23 @@
1038 /*
1039 ** Print the value of a setting named zName
1040 */
1041 static void print_setting(const char *zName){
1042 Stmt q;
1043 if( g.repositoryOpen ){
1044 db_prepare(&q,
1045 "SELECT '(local)', value FROM config WHERE name=%Q"
1046 " UNION ALL "
1047 "SELECT '(global)', value FROM global_config WHERE name=%Q",
1048 zName, zName
1049 );
1050 }else{
1051 db_prepare(&q,
1052 "SELECT '(global)', value FROM global_config WHERE name=%Q",
1053 zName
1054 );
1055 }
1056 if( db_step(&q)==SQLITE_ROW ){
1057 printf("%-20s %-8s %s\n", zName, db_column_text(&q, 0),
1058 db_column_text(&q, 1));
1059 }else{
1060 printf("%-20s\n", zName);
@@ -1098,11 +1107,15 @@
1107 "diff-command",
1108 "gdiff-command",
1109 };
1110 int i;
1111 int globalFlag = find_option("global","g",0)!=0;
1112 db_find_and_open_repository(0);
1113 if( !g.repositoryOpen ){
1114 db_open_config();
1115 globalFlag = 1;
1116 }
1117 if( g.argc==2 ){
1118 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
1119 print_setting(azName[i]);
1120 }
1121 }else if( g.argc==3 || g.argc==4 ){
1122
+1 -1
--- src/sync.c
+++ src/sync.c
@@ -71,11 +71,11 @@
7171
** of a server to sync against. If no argument is given, use the
7272
** most recently synced URL. Remember the current URL for next time.
7373
*/
7474
static void process_sync_args(void){
7575
const char *zUrl = 0;
76
- db_find_and_open_repository();
76
+ db_find_and_open_repository(1);
7777
if( g.argc==2 ){
7878
zUrl = db_get("last-sync-url", 0);
7979
}else if( g.argc==3 ){
8080
zUrl = g.argv[2];
8181
}
8282
--- src/sync.c
+++ src/sync.c
@@ -71,11 +71,11 @@
71 ** of a server to sync against. If no argument is given, use the
72 ** most recently synced URL. Remember the current URL for next time.
73 */
74 static void process_sync_args(void){
75 const char *zUrl = 0;
76 db_find_and_open_repository();
77 if( g.argc==2 ){
78 zUrl = db_get("last-sync-url", 0);
79 }else if( g.argc==3 ){
80 zUrl = g.argv[2];
81 }
82
--- src/sync.c
+++ src/sync.c
@@ -71,11 +71,11 @@
71 ** of a server to sync against. If no argument is given, use the
72 ** most recently synced URL. Remember the current URL for next time.
73 */
74 static void process_sync_args(void){
75 const char *zUrl = 0;
76 db_find_and_open_repository(1);
77 if( g.argc==2 ){
78 zUrl = db_get("last-sync-url", 0);
79 }else if( g.argc==3 ){
80 zUrl = g.argv[2];
81 }
82
+1 -1
--- src/tag.c
+++ src/tag.c
@@ -329,11 +329,11 @@
329329
** List all tags, or if UUID is supplied, list
330330
** all tags and their values for UUID.
331331
*/
332332
void tag_cmd(void){
333333
int n;
334
- db_find_and_open_repository();
334
+ db_find_and_open_repository(1);
335335
if( g.argc<3 ){
336336
goto tag_cmd_usage;
337337
}
338338
n = strlen(g.argv[2]);
339339
if( n==0 ){
340340
--- src/tag.c
+++ src/tag.c
@@ -329,11 +329,11 @@
329 ** List all tags, or if UUID is supplied, list
330 ** all tags and their values for UUID.
331 */
332 void tag_cmd(void){
333 int n;
334 db_find_and_open_repository();
335 if( g.argc<3 ){
336 goto tag_cmd_usage;
337 }
338 n = strlen(g.argv[2]);
339 if( n==0 ){
340
--- src/tag.c
+++ src/tag.c
@@ -329,11 +329,11 @@
329 ** List all tags, or if UUID is supplied, list
330 ** all tags and their values for UUID.
331 */
332 void tag_cmd(void){
333 int n;
334 db_find_and_open_repository(1);
335 if( g.argc<3 ){
336 goto tag_cmd_usage;
337 }
338 n = strlen(g.argv[2]);
339 if( n==0 ){
340
-1
--- src/th.c
+++ src/th.c
@@ -2669,6 +2669,5 @@
26692669
26702670
error_out:
26712671
Th_ErrorMessage(interp, "expected pointer, got: \"", z, n);
26722672
return TH_ERROR;
26732673
}
2674
-
26752674
--- src/th.c
+++ src/th.c
@@ -2669,6 +2669,5 @@
2669
2670 error_out:
2671 Th_ErrorMessage(interp, "expected pointer, got: \"", z, n);
2672 return TH_ERROR;
2673 }
2674
2675
--- src/th.c
+++ src/th.c
@@ -2669,6 +2669,5 @@
2669
2670 error_out:
2671 Th_ErrorMessage(interp, "expected pointer, got: \"", z, n);
2672 return TH_ERROR;
2673 }
 
2674
+1 -1
--- src/timeline.c
+++ src/timeline.c
@@ -588,11 +588,11 @@
588588
char *zDate;
589589
char *zSQL;
590590
int objid = 0;
591591
Blob uuid;
592592
int mode = 1 ; /* 1: before 2:after 3:children 4:parents */
593
- db_find_and_open_repository();
593
+ db_find_and_open_repository(1);
594594
zCount = find_option("n","count",1);
595595
if( zCount ){
596596
n = atoi(zCount);
597597
}else{
598598
n = 20;
599599
--- src/timeline.c
+++ src/timeline.c
@@ -588,11 +588,11 @@
588 char *zDate;
589 char *zSQL;
590 int objid = 0;
591 Blob uuid;
592 int mode = 1 ; /* 1: before 2:after 3:children 4:parents */
593 db_find_and_open_repository();
594 zCount = find_option("n","count",1);
595 if( zCount ){
596 n = atoi(zCount);
597 }else{
598 n = 20;
599
--- src/timeline.c
+++ src/timeline.c
@@ -588,11 +588,11 @@
588 char *zDate;
589 char *zSQL;
590 int objid = 0;
591 Blob uuid;
592 int mode = 1 ; /* 1: before 2:after 3:children 4:parents */
593 db_find_and_open_repository(1);
594 zCount = find_option("n","count",1);
595 if( zCount ){
596 n = atoi(zCount);
597 }else{
598 n = 20;
599
+1 -1
--- src/user.c
+++ src/user.c
@@ -177,11 +177,11 @@
177177
**
178178
** Change the web access password for a user.
179179
*/
180180
void user_cmd(void){
181181
int n;
182
- db_find_and_open_repository();
182
+ db_find_and_open_repository(1);
183183
if( g.argc<3 ){
184184
usage("capabilities|default|list|new|password ...");
185185
}
186186
n = strlen(g.argv[2]);
187187
if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
188188
--- src/user.c
+++ src/user.c
@@ -177,11 +177,11 @@
177 **
178 ** Change the web access password for a user.
179 */
180 void user_cmd(void){
181 int n;
182 db_find_and_open_repository();
183 if( g.argc<3 ){
184 usage("capabilities|default|list|new|password ...");
185 }
186 n = strlen(g.argv[2]);
187 if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
188
--- src/user.c
+++ src/user.c
@@ -177,11 +177,11 @@
177 **
178 ** Change the web access password for a user.
179 */
180 void user_cmd(void){
181 int n;
182 db_find_and_open_repository(1);
183 if( g.argc<3 ){
184 usage("capabilities|default|list|new|password ...");
185 }
186 n = strlen(g.argv[2]);
187 if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
188

Keyboard Shortcuts

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