Fossil SCM
Add the new remote-url command for managing the default server URL. Ticket [c24e486b05].
Commit
a2cbedcb1fee87decc21be2f74e65fa887a66e87
Parent
80457ec79be10b3…
1 file changed
+34
+34
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -150,5 +150,39 @@ | ||
| 150 | 150 | */ |
| 151 | 151 | void sync_cmd(void){ |
| 152 | 152 | process_sync_args(); |
| 153 | 153 | client_sync(1,1,0,0,0); |
| 154 | 154 | } |
| 155 | + | |
| 156 | +/* | |
| 157 | +** COMMAND: remote-url | |
| 158 | +** | |
| 159 | +** Usage: %fossil remote-url ?URL|off? | |
| 160 | +** | |
| 161 | +** Query and optional change the default server named used for syncing | |
| 162 | +** the current check-out. | |
| 163 | +** | |
| 164 | +** WARNING: If the username and password are part of the URL then the | |
| 165 | +** username and password will be displayed by this command. The user | |
| 166 | +** name and password are normally suppressed when echoing the remote-url | |
| 167 | +** during an auto-sync. | |
| 168 | +** | |
| 169 | +** The remote-url is set automatically by a "clone" command or by any | |
| 170 | +** "sync", "push", or "pull" command that specifies an explicit URL. | |
| 171 | +** The default remote-url is used by auto-syncing and by "sync", "push", | |
| 172 | +** "pull" that omit the server URL. | |
| 173 | +*/ | |
| 174 | +void remote_url_cmd(void){ | |
| 175 | + db_must_be_within_tree(); | |
| 176 | + if( g.argc!=2 && g.argc!=3 ){ | |
| 177 | + usage("remote-url ?URL|off?"); | |
| 178 | + } | |
| 179 | + if( g.argc==3 ){ | |
| 180 | + if( strcmp(g.argv[2],"off")==0 ){ | |
| 181 | + db_unset("last-sync-url", 0); | |
| 182 | + }else{ | |
| 183 | + url_parse(g.argv[2]); | |
| 184 | + db_set("last-sync-url", g.urlCanonical, 0); | |
| 185 | + } | |
| 186 | + } | |
| 187 | + printf("%s\n", db_get("last-sync-url", "off")); | |
| 188 | +} | |
| 155 | 189 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -150,5 +150,39 @@ | |
| 150 | */ |
| 151 | void sync_cmd(void){ |
| 152 | process_sync_args(); |
| 153 | client_sync(1,1,0,0,0); |
| 154 | } |
| 155 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -150,5 +150,39 @@ | |
| 150 | */ |
| 151 | void sync_cmd(void){ |
| 152 | process_sync_args(); |
| 153 | client_sync(1,1,0,0,0); |
| 154 | } |
| 155 | |
| 156 | /* |
| 157 | ** COMMAND: remote-url |
| 158 | ** |
| 159 | ** Usage: %fossil remote-url ?URL|off? |
| 160 | ** |
| 161 | ** Query and optional change the default server named used for syncing |
| 162 | ** the current check-out. |
| 163 | ** |
| 164 | ** WARNING: If the username and password are part of the URL then the |
| 165 | ** username and password will be displayed by this command. The user |
| 166 | ** name and password are normally suppressed when echoing the remote-url |
| 167 | ** during an auto-sync. |
| 168 | ** |
| 169 | ** The remote-url is set automatically by a "clone" command or by any |
| 170 | ** "sync", "push", or "pull" command that specifies an explicit URL. |
| 171 | ** The default remote-url is used by auto-syncing and by "sync", "push", |
| 172 | ** "pull" that omit the server URL. |
| 173 | */ |
| 174 | void remote_url_cmd(void){ |
| 175 | db_must_be_within_tree(); |
| 176 | if( g.argc!=2 && g.argc!=3 ){ |
| 177 | usage("remote-url ?URL|off?"); |
| 178 | } |
| 179 | if( g.argc==3 ){ |
| 180 | if( strcmp(g.argv[2],"off")==0 ){ |
| 181 | db_unset("last-sync-url", 0); |
| 182 | }else{ |
| 183 | url_parse(g.argv[2]); |
| 184 | db_set("last-sync-url", g.urlCanonical, 0); |
| 185 | } |
| 186 | } |
| 187 | printf("%s\n", db_get("last-sync-url", "off")); |
| 188 | } |
| 189 |