@@ -84,9 +84,9 @@
if( urlOptional ) exit(0);
usage("URL");
}
url_parse(zUrl);
- db_set("last-sync-url", zUrl, 0);
+ db_set("last-sync-url", g.urlIsFile ? g.urlCanonical : zUrl, 0);
user_select();
if( g.argc==2 ){
if( g.urlPort!=g.urlDfltPort ){
printf("Server: %s://%s:%d%s\n",
@@ -102,24 +102,14 @@
** COMMAND: pull
**
** Usage: %fossil pull ?URL? ?-R|--respository REPOSITORY?
**
-** Pull changes in a remote repository into the local repository.
-** The repository is identified by the -R or --repository option.
-** If there is no such option then the open repository is used.
-** The URL of the remote server is specified on the command line
-** If no URL is specified then the URL used by the most recent
-** "pull", "push", or "sync" command is used.
-**
-** The URL is of the following form:
-**
-** http://USER@HOST:PORT/PATH
-**
-** The "USER@" and ":PORT" substrings are optional.
-** The "USER" substring specifies the login user. You will be
-** prompted for the password on the command-line. The PORT
-** specifies the TCP port of the server. The default port is
-** 80.
+** Pull changes from a remote repository into the local repository.
+**
+** If the URL is not specified, then the URL from the most recent
+** clone, push, pull, remote-url, or sync command is used.
+**
+** See also: clone, push, sync, remote-url
*/
void pull_cmd(void){
process_sync_args();
client_sync(0,1,0,0,0);
@@ -130,9 +120,13 @@
**
** Usage: %fossil push ?URL? ?-R|--repository REPOSITORY?
**
** Push changes in the local repository over into a remote repository.
-** See the "pull" command for additional information.
+**
+** If the URL is not specified, then the URL from the most recent
+** clone, push, pull, remote-url, or sync command is used.
+**
+** See also: clone, pull, sync, remote-url
*/
void push_cmd(void){
process_sync_args();
client_sync(1,0,0,0,0);
@@ -145,10 +139,63 @@
** Usage: %fossil sync ?URL? ?-R|--repository REPOSITORY?
**
** Synchronize the local repository with a remote repository. This is
** the equivalent of running both "push" and "pull" at the same time.
-** See the "pull" command for additional information.
+**
+** If a user-id and password are required, specify them as follows:
+**
+** http://userid:password@www.domain.com:1234/path
+**
+** If the URL is not specified, then the URL from the most recent successful
+** clone, push, pull, remote-url, or sync command is used.
+**
+** See also: clone, push, pull, remote-url
*/
void sync_cmd(void){
process_sync_args();
client_sync(1,1,0,0,0);
+}
+
+/*
+** COMMAND: remote-url
+**
+** Usage: %fossil remote-url ?URL|off? --show-pw
+**
+** Query and/or change the default server URL used by the "pull", "push",
+** and "sync" commands.
+**
+** The userid and password are of the URL are not printed unless
+** the --show-pw option is used on the command-line.
+**
+** The remote-url is set automatically by a "clone" command or by any
+** "sync", "push", or "pull" command that specifies an explicit URL.
+** The default remote-url is used by auto-syncing and by "sync", "push",
+** "pull" that omit the server URL.
+**
+** See also: clone, push, pull, sync
+*/
+void remote_url_cmd(void){
+ char *zUrl;
+ int showPw = find_option("show-pw",0,0)!=0;
+ db_find_and_open_repository(1);
+ if( g.argc!=2 && g.argc!=3 ){
+ usage("remote-url ?URL|off?");
+ }
+ if( g.argc==3 ){
+ if( strcmp(g.argv[2],"off")==0 ){
+ db_unset("last-sync-url", 0);
+ }else{
+ url_parse(g.argv[2]);
+ db_set("last-sync-url", g.urlCanonical, 0);
+ }
+ }
+ zUrl = db_get("last-sync-url", 0);
+ if( zUrl==0 ){
+ printf("off\n");
+ return;
+ }else if( showPw ){
+ g.urlCanonical = zUrl;
+ }else{
+ url_parse(zUrl);
+ }
+ printf("%s\n", g.urlCanonical);
}