Fossil SCM

Automatically pull the shunning list when pulling from the "remote-url" server, which we assume is a trusted server. Add the new "auto-shun" setting to disable this feature, if desired.

drh 2010-07-03 15:26 trunk
Commit 515814f8e72ff2cabe62b6c7d84be6c4ac9d76f6
2 files changed +4 +20 -6
+4
--- src/db.c
+++ src/db.c
@@ -1491,10 +1491,13 @@
14911491
** The "unset" command clears a property setting.
14921492
**
14931493
**
14941494
** auto-captcha If enabled, the Login page provides a button to
14951495
** fill in the captcha password. Default: on
1496
+**
1497
+** auto-shun If enabled, automatically pull the shunning list
1498
+** from a server to which the client autosyncs.
14961499
**
14971500
** autosync If enabled, automatically pull prior to commit
14981501
** or update and automatically push after commit or
14991502
** tag or branch creation. If the the value is "pullonly"
15001503
** then only pull operations occur automatically.
@@ -1547,10 +1550,11 @@
15471550
** and "firefox" on Unix.
15481551
*/
15491552
void setting_cmd(void){
15501553
static const char *azName[] = {
15511554
"auto-captcha",
1555
+ "auto-shun",
15521556
"autosync",
15531557
"binary-glob",
15541558
"clearsign",
15551559
"diff-command",
15561560
"dont-push",
15571561
--- src/db.c
+++ src/db.c
@@ -1491,10 +1491,13 @@
1491 ** The "unset" command clears a property setting.
1492 **
1493 **
1494 ** auto-captcha If enabled, the Login page provides a button to
1495 ** fill in the captcha password. Default: on
 
 
 
1496 **
1497 ** autosync If enabled, automatically pull prior to commit
1498 ** or update and automatically push after commit or
1499 ** tag or branch creation. If the the value is "pullonly"
1500 ** then only pull operations occur automatically.
@@ -1547,10 +1550,11 @@
1547 ** and "firefox" on Unix.
1548 */
1549 void setting_cmd(void){
1550 static const char *azName[] = {
1551 "auto-captcha",
 
1552 "autosync",
1553 "binary-glob",
1554 "clearsign",
1555 "diff-command",
1556 "dont-push",
1557
--- src/db.c
+++ src/db.c
@@ -1491,10 +1491,13 @@
1491 ** The "unset" command clears a property setting.
1492 **
1493 **
1494 ** auto-captcha If enabled, the Login page provides a button to
1495 ** fill in the captcha password. Default: on
1496 **
1497 ** auto-shun If enabled, automatically pull the shunning list
1498 ** from a server to which the client autosyncs.
1499 **
1500 ** autosync If enabled, automatically pull prior to commit
1501 ** or update and automatically push after commit or
1502 ** tag or branch creation. If the the value is "pullonly"
1503 ** then only pull operations occur automatically.
@@ -1547,10 +1550,11 @@
1550 ** and "firefox" on Unix.
1551 */
1552 void setting_cmd(void){
1553 static const char *azName[] = {
1554 "auto-captcha",
1555 "auto-shun",
1556 "autosync",
1557 "binary-glob",
1558 "clearsign",
1559 "diff-command",
1560 "dont-push",
1561
+20 -6
--- src/sync.c
+++ src/sync.c
@@ -37,10 +37,11 @@
3737
*/
3838
void autosync(int flags){
3939
const char *zUrl;
4040
const char *zAutosync;
4141
const char *zPw;
42
+ int configSync = 0; /* configuration changes transferred */
4243
if( g.fNoSync ){
4344
return;
4445
}
4546
zAutosync = db_get("autosync", 0);
4647
if( zAutosync ){
@@ -59,33 +60,45 @@
5960
}
6061
zPw = db_get("last-sync-pw", 0);
6162
url_parse(zUrl);
6263
if( g.urlUser!=0 && g.urlPasswd==0 ){
6364
g.urlPasswd = mprintf("%s", zPw);
65
+ }
66
+ if( (flags & AUTOSYNC_PULL)!=0 && db_get_boolean("auto-shun",1) ){
67
+ /* When doing an automatic pull, also automatically pull shuns from
68
+ ** the server if pull_shuns is enabled.
69
+ **
70
+ ** TODO: What happens if the shun list gets really big?
71
+ ** Maybe the shunning list should only be pulled on every 10th
72
+ ** autosync, or something?
73
+ */
74
+ configSync = CONFIGSET_SHUN;
6475
}
6576
printf("Autosync: %s\n", g.urlCanonical);
6677
url_enable_proxy("via proxy: ");
67
- client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, 0, 0);
78
+ client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, configSync, 0);
6879
}
6980
7081
/*
7182
** This routine processes the command-line argument for push, pull,
7283
** and sync. If a command-line argument is given, that is the URL
7384
** of a server to sync against. If no argument is given, use the
7485
** most recently synced URL. Remember the current URL for next time.
7586
*/
76
-void process_sync_args(void){
87
+static int process_sync_args(void){
7788
const char *zUrl = 0;
7889
const char *zPw = 0;
90
+ int configSync = 0;
7991
int urlOptional = find_option("autourl",0,0)!=0;
8092
g.dontKeepUrl = find_option("once",0,0)!=0;
8193
url_proxy_options();
8294
db_find_and_open_repository(1);
8395
db_open_config(0);
8496
if( g.argc==2 ){
8597
zUrl = db_get("last-sync-url", 0);
8698
zPw = db_get("last-sync-pw", 0);
99
+ if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN;
87100
}else if( g.argc==3 ){
88101
zUrl = g.argv[2];
89102
}
90103
if( zUrl==0 ){
91104
if( urlOptional ) exit(0);
@@ -106,10 +119,11 @@
106119
user_select();
107120
if( g.argc==2 ){
108121
printf("Server: %s\n", g.urlCanonical);
109122
}
110123
url_enable_proxy("via proxy: ");
124
+ return configSync;
111125
}
112126
113127
/*
114128
** COMMAND: pull
115129
**
@@ -128,12 +142,12 @@
128142
** saved.
129143
**
130144
** See also: clone, push, sync, remote-url
131145
*/
132146
void pull_cmd(void){
133
- process_sync_args();
134
- client_sync(0,1,0,0,0);
147
+ int syncFlags = process_sync_args();
148
+ client_sync(0,1,0,syncFlags,0);
135149
}
136150
137151
/*
138152
** COMMAND: push
139153
**
@@ -182,12 +196,12 @@
182196
** saved.
183197
**
184198
** See also: clone, push, pull, remote-url
185199
*/
186200
void sync_cmd(void){
187
- process_sync_args();
188
- client_sync(1,1,0,0,0);
201
+ int syncFlags = process_sync_args();
202
+ client_sync(1,1,0,syncFlags,0);
189203
}
190204
191205
/*
192206
** COMMAND: remote-url
193207
**
194208
--- src/sync.c
+++ src/sync.c
@@ -37,10 +37,11 @@
37 */
38 void autosync(int flags){
39 const char *zUrl;
40 const char *zAutosync;
41 const char *zPw;
 
42 if( g.fNoSync ){
43 return;
44 }
45 zAutosync = db_get("autosync", 0);
46 if( zAutosync ){
@@ -59,33 +60,45 @@
59 }
60 zPw = db_get("last-sync-pw", 0);
61 url_parse(zUrl);
62 if( g.urlUser!=0 && g.urlPasswd==0 ){
63 g.urlPasswd = mprintf("%s", zPw);
 
 
 
 
 
 
 
 
 
 
64 }
65 printf("Autosync: %s\n", g.urlCanonical);
66 url_enable_proxy("via proxy: ");
67 client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, 0, 0);
68 }
69
70 /*
71 ** This routine processes the command-line argument for push, pull,
72 ** and sync. If a command-line argument is given, that is the URL
73 ** of a server to sync against. If no argument is given, use the
74 ** most recently synced URL. Remember the current URL for next time.
75 */
76 void process_sync_args(void){
77 const char *zUrl = 0;
78 const char *zPw = 0;
 
79 int urlOptional = find_option("autourl",0,0)!=0;
80 g.dontKeepUrl = find_option("once",0,0)!=0;
81 url_proxy_options();
82 db_find_and_open_repository(1);
83 db_open_config(0);
84 if( g.argc==2 ){
85 zUrl = db_get("last-sync-url", 0);
86 zPw = db_get("last-sync-pw", 0);
 
87 }else if( g.argc==3 ){
88 zUrl = g.argv[2];
89 }
90 if( zUrl==0 ){
91 if( urlOptional ) exit(0);
@@ -106,10 +119,11 @@
106 user_select();
107 if( g.argc==2 ){
108 printf("Server: %s\n", g.urlCanonical);
109 }
110 url_enable_proxy("via proxy: ");
 
111 }
112
113 /*
114 ** COMMAND: pull
115 **
@@ -128,12 +142,12 @@
128 ** saved.
129 **
130 ** See also: clone, push, sync, remote-url
131 */
132 void pull_cmd(void){
133 process_sync_args();
134 client_sync(0,1,0,0,0);
135 }
136
137 /*
138 ** COMMAND: push
139 **
@@ -182,12 +196,12 @@
182 ** saved.
183 **
184 ** See also: clone, push, pull, remote-url
185 */
186 void sync_cmd(void){
187 process_sync_args();
188 client_sync(1,1,0,0,0);
189 }
190
191 /*
192 ** COMMAND: remote-url
193 **
194
--- src/sync.c
+++ src/sync.c
@@ -37,10 +37,11 @@
37 */
38 void autosync(int flags){
39 const char *zUrl;
40 const char *zAutosync;
41 const char *zPw;
42 int configSync = 0; /* configuration changes transferred */
43 if( g.fNoSync ){
44 return;
45 }
46 zAutosync = db_get("autosync", 0);
47 if( zAutosync ){
@@ -59,33 +60,45 @@
60 }
61 zPw = db_get("last-sync-pw", 0);
62 url_parse(zUrl);
63 if( g.urlUser!=0 && g.urlPasswd==0 ){
64 g.urlPasswd = mprintf("%s", zPw);
65 }
66 if( (flags & AUTOSYNC_PULL)!=0 && db_get_boolean("auto-shun",1) ){
67 /* When doing an automatic pull, also automatically pull shuns from
68 ** the server if pull_shuns is enabled.
69 **
70 ** TODO: What happens if the shun list gets really big?
71 ** Maybe the shunning list should only be pulled on every 10th
72 ** autosync, or something?
73 */
74 configSync = CONFIGSET_SHUN;
75 }
76 printf("Autosync: %s\n", g.urlCanonical);
77 url_enable_proxy("via proxy: ");
78 client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, configSync, 0);
79 }
80
81 /*
82 ** This routine processes the command-line argument for push, pull,
83 ** and sync. If a command-line argument is given, that is the URL
84 ** of a server to sync against. If no argument is given, use the
85 ** most recently synced URL. Remember the current URL for next time.
86 */
87 static int process_sync_args(void){
88 const char *zUrl = 0;
89 const char *zPw = 0;
90 int configSync = 0;
91 int urlOptional = find_option("autourl",0,0)!=0;
92 g.dontKeepUrl = find_option("once",0,0)!=0;
93 url_proxy_options();
94 db_find_and_open_repository(1);
95 db_open_config(0);
96 if( g.argc==2 ){
97 zUrl = db_get("last-sync-url", 0);
98 zPw = db_get("last-sync-pw", 0);
99 if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN;
100 }else if( g.argc==3 ){
101 zUrl = g.argv[2];
102 }
103 if( zUrl==0 ){
104 if( urlOptional ) exit(0);
@@ -106,10 +119,11 @@
119 user_select();
120 if( g.argc==2 ){
121 printf("Server: %s\n", g.urlCanonical);
122 }
123 url_enable_proxy("via proxy: ");
124 return configSync;
125 }
126
127 /*
128 ** COMMAND: pull
129 **
@@ -128,12 +142,12 @@
142 ** saved.
143 **
144 ** See also: clone, push, sync, remote-url
145 */
146 void pull_cmd(void){
147 int syncFlags = process_sync_args();
148 client_sync(0,1,0,syncFlags,0);
149 }
150
151 /*
152 ** COMMAND: push
153 **
@@ -182,12 +196,12 @@
196 ** saved.
197 **
198 ** See also: clone, push, pull, remote-url
199 */
200 void sync_cmd(void){
201 int syncFlags = process_sync_args();
202 client_sync(1,1,0,syncFlags,0);
203 }
204
205 /*
206 ** COMMAND: remote-url
207 **
208

Keyboard Shortcuts

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