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.
Commit
515814f8e72ff2cabe62b6c7d84be6c4ac9d76f6
Parent
ba14c7549c8c6d0…
2 files changed
+4
+20
-6
M
src/db.c
+4
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1491,10 +1491,13 @@ | ||
| 1491 | 1491 | ** The "unset" command clears a property setting. |
| 1492 | 1492 | ** |
| 1493 | 1493 | ** |
| 1494 | 1494 | ** auto-captcha If enabled, the Login page provides a button to |
| 1495 | 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. | |
| 1496 | 1499 | ** |
| 1497 | 1500 | ** autosync If enabled, automatically pull prior to commit |
| 1498 | 1501 | ** or update and automatically push after commit or |
| 1499 | 1502 | ** tag or branch creation. If the the value is "pullonly" |
| 1500 | 1503 | ** then only pull operations occur automatically. |
| @@ -1547,10 +1550,11 @@ | ||
| 1547 | 1550 | ** and "firefox" on Unix. |
| 1548 | 1551 | */ |
| 1549 | 1552 | void setting_cmd(void){ |
| 1550 | 1553 | static const char *azName[] = { |
| 1551 | 1554 | "auto-captcha", |
| 1555 | + "auto-shun", | |
| 1552 | 1556 | "autosync", |
| 1553 | 1557 | "binary-glob", |
| 1554 | 1558 | "clearsign", |
| 1555 | 1559 | "diff-command", |
| 1556 | 1560 | "dont-push", |
| 1557 | 1561 |
| --- 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 @@ | ||
| 37 | 37 | */ |
| 38 | 38 | void autosync(int flags){ |
| 39 | 39 | const char *zUrl; |
| 40 | 40 | const char *zAutosync; |
| 41 | 41 | const char *zPw; |
| 42 | + int configSync = 0; /* configuration changes transferred */ | |
| 42 | 43 | if( g.fNoSync ){ |
| 43 | 44 | return; |
| 44 | 45 | } |
| 45 | 46 | zAutosync = db_get("autosync", 0); |
| 46 | 47 | if( zAutosync ){ |
| @@ -59,33 +60,45 @@ | ||
| 59 | 60 | } |
| 60 | 61 | zPw = db_get("last-sync-pw", 0); |
| 61 | 62 | url_parse(zUrl); |
| 62 | 63 | if( g.urlUser!=0 && g.urlPasswd==0 ){ |
| 63 | 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; | |
| 64 | 75 | } |
| 65 | 76 | printf("Autosync: %s\n", g.urlCanonical); |
| 66 | 77 | 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); | |
| 68 | 79 | } |
| 69 | 80 | |
| 70 | 81 | /* |
| 71 | 82 | ** This routine processes the command-line argument for push, pull, |
| 72 | 83 | ** and sync. If a command-line argument is given, that is the URL |
| 73 | 84 | ** of a server to sync against. If no argument is given, use the |
| 74 | 85 | ** most recently synced URL. Remember the current URL for next time. |
| 75 | 86 | */ |
| 76 | -void process_sync_args(void){ | |
| 87 | +static int process_sync_args(void){ | |
| 77 | 88 | const char *zUrl = 0; |
| 78 | 89 | const char *zPw = 0; |
| 90 | + int configSync = 0; | |
| 79 | 91 | int urlOptional = find_option("autourl",0,0)!=0; |
| 80 | 92 | g.dontKeepUrl = find_option("once",0,0)!=0; |
| 81 | 93 | url_proxy_options(); |
| 82 | 94 | db_find_and_open_repository(1); |
| 83 | 95 | db_open_config(0); |
| 84 | 96 | if( g.argc==2 ){ |
| 85 | 97 | zUrl = db_get("last-sync-url", 0); |
| 86 | 98 | zPw = db_get("last-sync-pw", 0); |
| 99 | + if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN; | |
| 87 | 100 | }else if( g.argc==3 ){ |
| 88 | 101 | zUrl = g.argv[2]; |
| 89 | 102 | } |
| 90 | 103 | if( zUrl==0 ){ |
| 91 | 104 | if( urlOptional ) exit(0); |
| @@ -106,10 +119,11 @@ | ||
| 106 | 119 | user_select(); |
| 107 | 120 | if( g.argc==2 ){ |
| 108 | 121 | printf("Server: %s\n", g.urlCanonical); |
| 109 | 122 | } |
| 110 | 123 | url_enable_proxy("via proxy: "); |
| 124 | + return configSync; | |
| 111 | 125 | } |
| 112 | 126 | |
| 113 | 127 | /* |
| 114 | 128 | ** COMMAND: pull |
| 115 | 129 | ** |
| @@ -128,12 +142,12 @@ | ||
| 128 | 142 | ** saved. |
| 129 | 143 | ** |
| 130 | 144 | ** See also: clone, push, sync, remote-url |
| 131 | 145 | */ |
| 132 | 146 | 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); | |
| 135 | 149 | } |
| 136 | 150 | |
| 137 | 151 | /* |
| 138 | 152 | ** COMMAND: push |
| 139 | 153 | ** |
| @@ -182,12 +196,12 @@ | ||
| 182 | 196 | ** saved. |
| 183 | 197 | ** |
| 184 | 198 | ** See also: clone, push, pull, remote-url |
| 185 | 199 | */ |
| 186 | 200 | 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); | |
| 189 | 203 | } |
| 190 | 204 | |
| 191 | 205 | /* |
| 192 | 206 | ** COMMAND: remote-url |
| 193 | 207 | ** |
| 194 | 208 |
| --- 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 |