Fossil SCM

Temporarily back out "fossil remote" improvements until "fossil clone" is fixed: [https://fossil-scm.org/forum/forumpost/158a67cc53]

andygoth 2020-07-18 01:33 trunk
Commit 0a7526522085631f9133dc06ffa87a3a8f61b06ab0b7c31ab3bfdc4d5ced6aae
3 files changed +1 -3 +35 -144 +4 -27
+1 -3
--- src/rebuild.c
+++ src/rebuild.c
@@ -758,12 +758,11 @@
758758
*/
759759
void test_detach_cmd(void){
760760
db_find_and_open_repository(0, 2);
761761
db_begin_transaction();
762762
db_multi_exec(
763
- "DELETE FROM config WHERE name GLOB 'last-sync-*';"
764
- "DELETE FROM config WHERE name GLOB 'sync-*:*';"
763
+ "DELETE FROM config WHERE name='last-sync-url';"
765764
"UPDATE config SET value=lower(hex(randomblob(20)))"
766765
" WHERE name='project-code';"
767766
"UPDATE config SET value='detached-' || value"
768767
" WHERE name='project-name' AND value NOT GLOB 'detached-*';"
769768
);
@@ -915,11 +914,10 @@
915914
}
916915
if( !privateOnly ){
917916
db_multi_exec(
918917
"UPDATE user SET pw='';"
919918
"DELETE FROM config WHERE name GLOB 'last-sync-*';"
920
- "DELETE FROM config WHERE name GLOB 'sync-*:*';"
921919
"DELETE FROM config WHERE name GLOB 'peer-*';"
922920
"DELETE FROM config WHERE name GLOB 'login-group-*';"
923921
"DELETE FROM config WHERE name GLOB 'skin:*';"
924922
"DELETE FROM config WHERE name GLOB 'subrepo:*';"
925923
"DELETE FROM config WHERE name GLOB 'http-auth:*';"
926924
--- src/rebuild.c
+++ src/rebuild.c
@@ -758,12 +758,11 @@
758 */
759 void test_detach_cmd(void){
760 db_find_and_open_repository(0, 2);
761 db_begin_transaction();
762 db_multi_exec(
763 "DELETE FROM config WHERE name GLOB 'last-sync-*';"
764 "DELETE FROM config WHERE name GLOB 'sync-*:*';"
765 "UPDATE config SET value=lower(hex(randomblob(20)))"
766 " WHERE name='project-code';"
767 "UPDATE config SET value='detached-' || value"
768 " WHERE name='project-name' AND value NOT GLOB 'detached-*';"
769 );
@@ -915,11 +914,10 @@
915 }
916 if( !privateOnly ){
917 db_multi_exec(
918 "UPDATE user SET pw='';"
919 "DELETE FROM config WHERE name GLOB 'last-sync-*';"
920 "DELETE FROM config WHERE name GLOB 'sync-*:*';"
921 "DELETE FROM config WHERE name GLOB 'peer-*';"
922 "DELETE FROM config WHERE name GLOB 'login-group-*';"
923 "DELETE FROM config WHERE name GLOB 'skin:*';"
924 "DELETE FROM config WHERE name GLOB 'subrepo:*';"
925 "DELETE FROM config WHERE name GLOB 'http-auth:*';"
926
--- src/rebuild.c
+++ src/rebuild.c
@@ -758,12 +758,11 @@
758 */
759 void test_detach_cmd(void){
760 db_find_and_open_repository(0, 2);
761 db_begin_transaction();
762 db_multi_exec(
763 "DELETE FROM config WHERE name='last-sync-url';"
 
764 "UPDATE config SET value=lower(hex(randomblob(20)))"
765 " WHERE name='project-code';"
766 "UPDATE config SET value='detached-' || value"
767 " WHERE name='project-name' AND value NOT GLOB 'detached-*';"
768 );
@@ -915,11 +914,10 @@
914 }
915 if( !privateOnly ){
916 db_multi_exec(
917 "UPDATE user SET pw='';"
918 "DELETE FROM config WHERE name GLOB 'last-sync-*';"
 
919 "DELETE FROM config WHERE name GLOB 'peer-*';"
920 "DELETE FROM config WHERE name GLOB 'login-group-*';"
921 "DELETE FROM config WHERE name GLOB 'skin:*';"
922 "DELETE FROM config WHERE name GLOB 'subrepo:*';"
923 "DELETE FROM config WHERE name GLOB 'http-auth:*';"
924
+35 -144
--- src/sync.c
+++ src/sync.c
@@ -172,11 +172,11 @@
172172
if( g.url.protocol==0 ){
173173
if( urlOptional ) fossil_exit(0);
174174
usage("URL");
175175
}
176176
user_select();
177
- if( g.url.isAlias ){
177
+ if( g.argc==2 ){
178178
if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
179179
fossil_print("Sync with %s\n", g.url.canonical);
180180
}else if( (*pSyncFlags) & SYNC_PUSH ){
181181
fossil_print("Push to %s\n", g.url.canonical);
182182
}else if( (*pSyncFlags) & SYNC_PULL ){
@@ -197,11 +197,11 @@
197197
** wiki pages, tickets, and tech-notes, as well as forum content. Add
198198
** the --private option to pull private branches. Use the
199199
** "configuration pull" command to pull website configuration details.
200200
**
201201
** If URL is not specified, then the URL from the most recent clone, push,
202
-** pull, remote, or sync command is used. See "fossil help clone" for
202
+** pull, remote-url, or sync command is used. See "fossil help clone" for
203203
** details on the URL formats.
204204
**
205205
** Options:
206206
**
207207
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -217,11 +217,11 @@
217217
** --ssh-command SSH Use SSH as the "ssh" command
218218
** -v|--verbose Additional (debugging) output
219219
** --verily Exchange extra information with the remote
220220
** to ensure no content is overlooked
221221
**
222
-** See also: clone, config pull, push, remote, sync
222
+** See also: clone, config pull, push, remote-url, sync
223223
*/
224224
void pull_cmd(void){
225225
unsigned configFlags = 0;
226226
unsigned syncFlags = SYNC_PULL;
227227
unsigned urlOmitFlags = 0;
@@ -248,11 +248,11 @@
248248
** wiki pages, tickets, and tech-notes, as well as forum content. Use
249249
** --private to also push private branches. Use the "configuration
250250
** push" command to push website configuration details.
251251
**
252252
** If URL is not specified, then the URL from the most recent clone, push,
253
-** pull, remote, or sync command is used. See "fossil help clone" for
253
+** pull, remote-url, or sync command is used. See "fossil help clone" for
254254
** details on the URL formats.
255255
**
256256
** Options:
257257
**
258258
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -266,11 +266,11 @@
266266
** --ssh-command SSH Use SSH as the "ssh" command
267267
** -v|--verbose Additional (debugging) output
268268
** --verily Exchange extra information with the remote
269269
** to ensure no content is overlooked
270270
**
271
-** See also: clone, config push, pull, remote, sync
271
+** See also: clone, config push, pull, remote-url, sync
272272
*/
273273
void push_cmd(void){
274274
unsigned configFlags = 0;
275275
unsigned syncFlags = SYNC_PUSH;
276276
process_sync_args(&configFlags, &syncFlags, 0, 0);
@@ -293,11 +293,11 @@
293293
** Synchronize all sharable changes between the local repository and a
294294
** remote repository. Sharable changes include public check-ins and
295295
** edits to wiki pages, tickets, and technical notes.
296296
**
297297
** If URL is not specified, then the URL from the most recent clone, push,
298
-** pull, remote, or sync command is used. See "fossil help clone" for
298
+** pull, remote-url, or sync command is used. See "fossil help clone" for
299299
** details on the URL formats.
300300
**
301301
** Options:
302302
**
303303
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -312,11 +312,11 @@
312312
** -u|--unversioned Also sync unversioned content
313313
** -v|--verbose Additional (debugging) output
314314
** --verily Exchange extra information with the remote
315315
** to ensure no content is overlooked
316316
**
317
-** See also: clone, pull, push, remote
317
+** See also: clone, pull, push, remote-url
318318
*/
319319
void sync_cmd(void){
320320
unsigned configFlags = 0;
321321
unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
322322
if( find_option("unversioned","u",0)!=0 ){
@@ -347,158 +347,49 @@
347347
}
348348
349349
/*
350350
** COMMAND: remote-url
351351
**
352
-** Usage: %fossil remote ?SUBCOMMAND ...?
353
-**
354
-** Use this command to view or modify the set of remote repositories
355
-** used as the default target for sync, push, and pull and for autosync.
356
-**
357
-** The default remote is set automatically by a "clone" command or by any
358
-** "sync", "push", or "pull" command that specifies an explicit URL
359
-** and omits the --once flag. The default remote is used by
360
-** auto-syncing and by "sync", "push", and "pull" that omit the server URL.
361
-** Additional remotes can be added using the "add" command or deleted
362
-** using the "delete" command. The name of any additional remote can be
363
-** used as an argument to the "sync", "push", and "pull" commands where
364
-** one would normally put a URL argument.
365
-**
366
-** See "fossil help clone" for further information about URL formats.
367
-**
368
-** The official name of this command is "remote-url" but most people
369
-** use the shortened name "remote".
370
-**
371
-** > fossil remote
372
-**
373
-** With no arguments, this command shows the current default remote.
374
-** Or if there is no default, it shows "off". The default remote is
375
-** used by autosync. The default remote is whatever URL was specified
376
-** for the most recent "sync", "push", or "pull" command that omitted
377
-** the --once option.
378
-**
379
-** > fossil remote add NAME URL
380
-**
381
-** Add a new URL to the set of remotes. The new URL is assigned the
382
-** symbolic identifier "NAME". Subsequently, NAME can be used in place
383
-** of the full URL on commands like "push" and "pull".
384
-**
385
-** > fossil remote delete NAME
386
-**
387
-** Delete a URL previously added by the "add" subcommand.
388
-**
389
-** > fossil remote list
390
-**
391
-** Show all remote URLs
392
-**
393
-** > fossil remote off
394
-**
395
-** Disable the default URL. Use this as a shorthand to prevent
396
-** autosync while in airplane mode, for example.
397
-**
398
-** > fossil remote URL
399
-**
400
-** Make URL the new default URL. The prior default URL is replaced.
352
+** Usage: %fossil remote-url ?URL|off?
353
+**
354
+** Query and/or change the default server URL used by the "pull", "push",
355
+** and "sync" commands.
356
+**
357
+** The remote-url is set automatically by a "clone" command or by any
358
+** "sync", "push", or "pull" command that specifies an explicit URL.
359
+** The default remote-url is used by auto-syncing and by "sync", "push",
360
+** "pull" that omit the server URL.
361
+**
362
+** See "fossil help clone" for further information about URL formats
363
+**
364
+** See also: clone, push, pull, sync
401365
*/
402366
void remote_url_cmd(void){
403
- char *zUrl, *zArg;
404
- int nArg;
367
+ char *zUrl;
405368
db_find_and_open_repository(0, 0);
406369
407370
/* We should be done with options.. */
408371
verify_all_options();
409372
410
- if( g.argc==2 ){
411
- /* "fossil remote" with no arguments: Show the last sync URL. */
412
- zUrl = db_get("last-sync-url", 0);
413
- if( zUrl==0 ){
414
- fossil_print("off\n");
415
- }else{
416
- url_parse(zUrl, 0);
417
- fossil_print("%s\n", g.url.canonical);
418
- }
419
- return;
420
- }
421
- zArg = g.argv[2];
422
- nArg = (int)strlen(zArg);
423
- if( strcmp(zArg,"off")==0 ){
424
- /* fossil remote off
425
- ** Forget the last-sync-URL and its password
426
- */
427
- if( g.argc!=3 ) usage("off");
428
-remote_delete_default:
429
- db_multi_exec(
430
- "DELETE FROM config WHERE name GLOB 'last-sync-*';"
431
- );
432
- return;
433
- }
434
- if( strncmp(zArg, "list", nArg)==0 || strcmp(zArg,"ls")==0 ){
435
- Stmt q;
436
- if( g.argc!=3 ) usage("list");
437
- db_prepare(&q,
438
- "SELECT 'default', value FROM config WHERE name='last-sync-url'"
439
- " UNION ALL "
440
- "SELECT substr(name,10), value FROM config"
441
- " WHERE name GLOB 'sync-url:*'"
442
- " ORDER BY 1"
443
- );
444
- while( db_step(&q)==SQLITE_ROW ){
445
- fossil_print("%-18s %s\n", db_column_text(&q,0), db_column_text(&q,1));
446
- }
447
- db_finalize(&q);
448
- return;
449
- }
450
- if( strcmp(zArg, "add")==0 ){
451
- char *zName;
452
- char *zUrl;
453
- UrlData x;
454
- if( g.argc!=5 ) usage("add NAME URL");
455
- memset(&x, 0, sizeof(x));
456
- zName = g.argv[3];
457
- zUrl = g.argv[4];
458
- if( strcmp(zName,"default")==0 ) goto remote_add_default;
459
- url_parse_local(zUrl, URL_PROMPT_PW, &x);
460
- db_begin_write();
461
- db_multi_exec(
462
- "REPLACE INTO config(name, value, mtime)"
463
- " VALUES('sync-url:%q',%Q,now())",
464
- zName, x.canonical
465
- );
466
- db_multi_exec(
467
- "REPLACE INTO config(name, value, mtime)"
468
- " VALUES('sync-pw:%q',obscure(%Q),now())",
469
- zName, x.passwd
470
- );
471
- db_commit_transaction();
472
- return;
473
- }
474
- if( strncmp(zArg, "delete", nArg)==0 ){
475
- char *zName;
476
- if( g.argc!=4 ) usage("delete NAME");
477
- zName = g.argv[3];
478
- if( strcmp(zName,"default")==0 ) goto remote_delete_default;
479
- db_begin_write();
480
- db_multi_exec("DELETE FROM config WHERE name glob 'sync-url:%q'", zName);
481
- db_multi_exec("DELETE FROM config WHERE name glob 'sync-pw:%q'", zName);
482
- db_commit_transaction();
483
- return;
484
- }
485
- if( sqlite3_strlike("http://%",zArg,0)==0
486
- || sqlite3_strlike("https://%",zArg,0)==0
487
- || sqlite3_strlike("ssh:%",zArg,0)==0
488
- || sqlite3_strlike("file:%",zArg,0)==0
489
- || db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
490
- ){
491
-remote_add_default:
373
+ if( g.argc!=2 && g.argc!=3 ){
374
+ usage("?URL|off?");
375
+ }
376
+ if( g.argc==3 ){
492377
db_unset("last-sync-url", 0);
493378
db_unset("last-sync-pw", 0);
379
+ if( is_false(g.argv[2]) ) return;
494380
url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
495
- url_remember();
496
- return;
497381
}
498
- fossil_fatal("unknown command \"%s\" - should be a URL or one of: "
499
- "add delete list off", zArg);
382
+ url_remember();
383
+ zUrl = db_get("last-sync-url", 0);
384
+ if( zUrl==0 ){
385
+ fossil_print("off\n");
386
+ return;
387
+ }else{
388
+ url_parse(zUrl, 0);
389
+ fossil_print("%s\n", g.url.canonical);
390
+ }
500391
}
501392
502393
/*
503394
** COMMAND: backup*
504395
**
505396
--- src/sync.c
+++ src/sync.c
@@ -172,11 +172,11 @@
172 if( g.url.protocol==0 ){
173 if( urlOptional ) fossil_exit(0);
174 usage("URL");
175 }
176 user_select();
177 if( g.url.isAlias ){
178 if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
179 fossil_print("Sync with %s\n", g.url.canonical);
180 }else if( (*pSyncFlags) & SYNC_PUSH ){
181 fossil_print("Push to %s\n", g.url.canonical);
182 }else if( (*pSyncFlags) & SYNC_PULL ){
@@ -197,11 +197,11 @@
197 ** wiki pages, tickets, and tech-notes, as well as forum content. Add
198 ** the --private option to pull private branches. Use the
199 ** "configuration pull" command to pull website configuration details.
200 **
201 ** If URL is not specified, then the URL from the most recent clone, push,
202 ** pull, remote, or sync command is used. See "fossil help clone" for
203 ** details on the URL formats.
204 **
205 ** Options:
206 **
207 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -217,11 +217,11 @@
217 ** --ssh-command SSH Use SSH as the "ssh" command
218 ** -v|--verbose Additional (debugging) output
219 ** --verily Exchange extra information with the remote
220 ** to ensure no content is overlooked
221 **
222 ** See also: clone, config pull, push, remote, sync
223 */
224 void pull_cmd(void){
225 unsigned configFlags = 0;
226 unsigned syncFlags = SYNC_PULL;
227 unsigned urlOmitFlags = 0;
@@ -248,11 +248,11 @@
248 ** wiki pages, tickets, and tech-notes, as well as forum content. Use
249 ** --private to also push private branches. Use the "configuration
250 ** push" command to push website configuration details.
251 **
252 ** If URL is not specified, then the URL from the most recent clone, push,
253 ** pull, remote, or sync command is used. See "fossil help clone" for
254 ** details on the URL formats.
255 **
256 ** Options:
257 **
258 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -266,11 +266,11 @@
266 ** --ssh-command SSH Use SSH as the "ssh" command
267 ** -v|--verbose Additional (debugging) output
268 ** --verily Exchange extra information with the remote
269 ** to ensure no content is overlooked
270 **
271 ** See also: clone, config push, pull, remote, sync
272 */
273 void push_cmd(void){
274 unsigned configFlags = 0;
275 unsigned syncFlags = SYNC_PUSH;
276 process_sync_args(&configFlags, &syncFlags, 0, 0);
@@ -293,11 +293,11 @@
293 ** Synchronize all sharable changes between the local repository and a
294 ** remote repository. Sharable changes include public check-ins and
295 ** edits to wiki pages, tickets, and technical notes.
296 **
297 ** If URL is not specified, then the URL from the most recent clone, push,
298 ** pull, remote, or sync command is used. See "fossil help clone" for
299 ** details on the URL formats.
300 **
301 ** Options:
302 **
303 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -312,11 +312,11 @@
312 ** -u|--unversioned Also sync unversioned content
313 ** -v|--verbose Additional (debugging) output
314 ** --verily Exchange extra information with the remote
315 ** to ensure no content is overlooked
316 **
317 ** See also: clone, pull, push, remote
318 */
319 void sync_cmd(void){
320 unsigned configFlags = 0;
321 unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
322 if( find_option("unversioned","u",0)!=0 ){
@@ -347,158 +347,49 @@
347 }
348
349 /*
350 ** COMMAND: remote-url
351 **
352 ** Usage: %fossil remote ?SUBCOMMAND ...?
353 **
354 ** Use this command to view or modify the set of remote repositories
355 ** used as the default target for sync, push, and pull and for autosync.
356 **
357 ** The default remote is set automatically by a "clone" command or by any
358 ** "sync", "push", or "pull" command that specifies an explicit URL
359 ** and omits the --once flag. The default remote is used by
360 ** auto-syncing and by "sync", "push", and "pull" that omit the server URL.
361 ** Additional remotes can be added using the "add" command or deleted
362 ** using the "delete" command. The name of any additional remote can be
363 ** used as an argument to the "sync", "push", and "pull" commands where
364 ** one would normally put a URL argument.
365 **
366 ** See "fossil help clone" for further information about URL formats.
367 **
368 ** The official name of this command is "remote-url" but most people
369 ** use the shortened name "remote".
370 **
371 ** > fossil remote
372 **
373 ** With no arguments, this command shows the current default remote.
374 ** Or if there is no default, it shows "off". The default remote is
375 ** used by autosync. The default remote is whatever URL was specified
376 ** for the most recent "sync", "push", or "pull" command that omitted
377 ** the --once option.
378 **
379 ** > fossil remote add NAME URL
380 **
381 ** Add a new URL to the set of remotes. The new URL is assigned the
382 ** symbolic identifier "NAME". Subsequently, NAME can be used in place
383 ** of the full URL on commands like "push" and "pull".
384 **
385 ** > fossil remote delete NAME
386 **
387 ** Delete a URL previously added by the "add" subcommand.
388 **
389 ** > fossil remote list
390 **
391 ** Show all remote URLs
392 **
393 ** > fossil remote off
394 **
395 ** Disable the default URL. Use this as a shorthand to prevent
396 ** autosync while in airplane mode, for example.
397 **
398 ** > fossil remote URL
399 **
400 ** Make URL the new default URL. The prior default URL is replaced.
401 */
402 void remote_url_cmd(void){
403 char *zUrl, *zArg;
404 int nArg;
405 db_find_and_open_repository(0, 0);
406
407 /* We should be done with options.. */
408 verify_all_options();
409
410 if( g.argc==2 ){
411 /* "fossil remote" with no arguments: Show the last sync URL. */
412 zUrl = db_get("last-sync-url", 0);
413 if( zUrl==0 ){
414 fossil_print("off\n");
415 }else{
416 url_parse(zUrl, 0);
417 fossil_print("%s\n", g.url.canonical);
418 }
419 return;
420 }
421 zArg = g.argv[2];
422 nArg = (int)strlen(zArg);
423 if( strcmp(zArg,"off")==0 ){
424 /* fossil remote off
425 ** Forget the last-sync-URL and its password
426 */
427 if( g.argc!=3 ) usage("off");
428 remote_delete_default:
429 db_multi_exec(
430 "DELETE FROM config WHERE name GLOB 'last-sync-*';"
431 );
432 return;
433 }
434 if( strncmp(zArg, "list", nArg)==0 || strcmp(zArg,"ls")==0 ){
435 Stmt q;
436 if( g.argc!=3 ) usage("list");
437 db_prepare(&q,
438 "SELECT 'default', value FROM config WHERE name='last-sync-url'"
439 " UNION ALL "
440 "SELECT substr(name,10), value FROM config"
441 " WHERE name GLOB 'sync-url:*'"
442 " ORDER BY 1"
443 );
444 while( db_step(&q)==SQLITE_ROW ){
445 fossil_print("%-18s %s\n", db_column_text(&q,0), db_column_text(&q,1));
446 }
447 db_finalize(&q);
448 return;
449 }
450 if( strcmp(zArg, "add")==0 ){
451 char *zName;
452 char *zUrl;
453 UrlData x;
454 if( g.argc!=5 ) usage("add NAME URL");
455 memset(&x, 0, sizeof(x));
456 zName = g.argv[3];
457 zUrl = g.argv[4];
458 if( strcmp(zName,"default")==0 ) goto remote_add_default;
459 url_parse_local(zUrl, URL_PROMPT_PW, &x);
460 db_begin_write();
461 db_multi_exec(
462 "REPLACE INTO config(name, value, mtime)"
463 " VALUES('sync-url:%q',%Q,now())",
464 zName, x.canonical
465 );
466 db_multi_exec(
467 "REPLACE INTO config(name, value, mtime)"
468 " VALUES('sync-pw:%q',obscure(%Q),now())",
469 zName, x.passwd
470 );
471 db_commit_transaction();
472 return;
473 }
474 if( strncmp(zArg, "delete", nArg)==0 ){
475 char *zName;
476 if( g.argc!=4 ) usage("delete NAME");
477 zName = g.argv[3];
478 if( strcmp(zName,"default")==0 ) goto remote_delete_default;
479 db_begin_write();
480 db_multi_exec("DELETE FROM config WHERE name glob 'sync-url:%q'", zName);
481 db_multi_exec("DELETE FROM config WHERE name glob 'sync-pw:%q'", zName);
482 db_commit_transaction();
483 return;
484 }
485 if( sqlite3_strlike("http://%",zArg,0)==0
486 || sqlite3_strlike("https://%",zArg,0)==0
487 || sqlite3_strlike("ssh:%",zArg,0)==0
488 || sqlite3_strlike("file:%",zArg,0)==0
489 || db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
490 ){
491 remote_add_default:
492 db_unset("last-sync-url", 0);
493 db_unset("last-sync-pw", 0);
 
494 url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
495 url_remember();
496 return;
497 }
498 fossil_fatal("unknown command \"%s\" - should be a URL or one of: "
499 "add delete list off", zArg);
 
 
 
 
 
 
 
500 }
501
502 /*
503 ** COMMAND: backup*
504 **
505
--- src/sync.c
+++ src/sync.c
@@ -172,11 +172,11 @@
172 if( g.url.protocol==0 ){
173 if( urlOptional ) fossil_exit(0);
174 usage("URL");
175 }
176 user_select();
177 if( g.argc==2 ){
178 if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
179 fossil_print("Sync with %s\n", g.url.canonical);
180 }else if( (*pSyncFlags) & SYNC_PUSH ){
181 fossil_print("Push to %s\n", g.url.canonical);
182 }else if( (*pSyncFlags) & SYNC_PULL ){
@@ -197,11 +197,11 @@
197 ** wiki pages, tickets, and tech-notes, as well as forum content. Add
198 ** the --private option to pull private branches. Use the
199 ** "configuration pull" command to pull website configuration details.
200 **
201 ** If URL is not specified, then the URL from the most recent clone, push,
202 ** pull, remote-url, or sync command is used. See "fossil help clone" for
203 ** details on the URL formats.
204 **
205 ** Options:
206 **
207 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -217,11 +217,11 @@
217 ** --ssh-command SSH Use SSH as the "ssh" command
218 ** -v|--verbose Additional (debugging) output
219 ** --verily Exchange extra information with the remote
220 ** to ensure no content is overlooked
221 **
222 ** See also: clone, config pull, push, remote-url, sync
223 */
224 void pull_cmd(void){
225 unsigned configFlags = 0;
226 unsigned syncFlags = SYNC_PULL;
227 unsigned urlOmitFlags = 0;
@@ -248,11 +248,11 @@
248 ** wiki pages, tickets, and tech-notes, as well as forum content. Use
249 ** --private to also push private branches. Use the "configuration
250 ** push" command to push website configuration details.
251 **
252 ** If URL is not specified, then the URL from the most recent clone, push,
253 ** pull, remote-url, or sync command is used. See "fossil help clone" for
254 ** details on the URL formats.
255 **
256 ** Options:
257 **
258 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -266,11 +266,11 @@
266 ** --ssh-command SSH Use SSH as the "ssh" command
267 ** -v|--verbose Additional (debugging) output
268 ** --verily Exchange extra information with the remote
269 ** to ensure no content is overlooked
270 **
271 ** See also: clone, config push, pull, remote-url, sync
272 */
273 void push_cmd(void){
274 unsigned configFlags = 0;
275 unsigned syncFlags = SYNC_PUSH;
276 process_sync_args(&configFlags, &syncFlags, 0, 0);
@@ -293,11 +293,11 @@
293 ** Synchronize all sharable changes between the local repository and a
294 ** remote repository. Sharable changes include public check-ins and
295 ** edits to wiki pages, tickets, and technical notes.
296 **
297 ** If URL is not specified, then the URL from the most recent clone, push,
298 ** pull, remote-url, or sync command is used. See "fossil help clone" for
299 ** details on the URL formats.
300 **
301 ** Options:
302 **
303 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
@@ -312,11 +312,11 @@
312 ** -u|--unversioned Also sync unversioned content
313 ** -v|--verbose Additional (debugging) output
314 ** --verily Exchange extra information with the remote
315 ** to ensure no content is overlooked
316 **
317 ** See also: clone, pull, push, remote-url
318 */
319 void sync_cmd(void){
320 unsigned configFlags = 0;
321 unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
322 if( find_option("unversioned","u",0)!=0 ){
@@ -347,158 +347,49 @@
347 }
348
349 /*
350 ** COMMAND: remote-url
351 **
352 ** Usage: %fossil remote-url ?URL|off?
353 **
354 ** Query and/or change the default server URL used by the "pull", "push",
355 ** and "sync" commands.
356 **
357 ** The remote-url is set automatically by a "clone" command or by any
358 ** "sync", "push", or "pull" command that specifies an explicit URL.
359 ** The default remote-url is used by auto-syncing and by "sync", "push",
360 ** "pull" that omit the server URL.
361 **
362 ** See "fossil help clone" for further information about URL formats
363 **
364 ** See also: clone, push, pull, sync
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365 */
366 void remote_url_cmd(void){
367 char *zUrl;
 
368 db_find_and_open_repository(0, 0);
369
370 /* We should be done with options.. */
371 verify_all_options();
372
373 if( g.argc!=2 && g.argc!=3 ){
374 usage("?URL|off?");
375 }
376 if( g.argc==3 ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377 db_unset("last-sync-url", 0);
378 db_unset("last-sync-pw", 0);
379 if( is_false(g.argv[2]) ) return;
380 url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
 
 
381 }
382 url_remember();
383 zUrl = db_get("last-sync-url", 0);
384 if( zUrl==0 ){
385 fossil_print("off\n");
386 return;
387 }else{
388 url_parse(zUrl, 0);
389 fossil_print("%s\n", g.url.canonical);
390 }
391 }
392
393 /*
394 ** COMMAND: backup*
395 **
396
+4 -27
--- src/url.c
+++ src/url.c
@@ -47,11 +47,10 @@
4747
*/
4848
struct UrlData {
4949
int isFile; /* True if a "file:" url */
5050
int isHttps; /* True if a "https:" url */
5151
int isSsh; /* True if an "ssh:" url */
52
- int isAlias; /* Input URL was an alias */
5352
char *name; /* Hostname for http: or filename for file: */
5453
char *hostname; /* The HOST: parameter on http headers */
5554
const char *protocol; /* "http" or "https" or "ssh" */
5655
int port; /* TCP port number for http: or https: */
5756
int dfltPort; /* The default port for the given protocol */
@@ -68,13 +67,11 @@
6867
};
6968
#endif /* INTERFACE */
7069
7170
7271
/*
73
-** Parse the given URL. Or if zUrl is NULL, parse the URL in the
74
-** last-sync-url setting using last-sync-pw as the password. Store
75
-** the parser results in the pUrlData object. Populate members of pUrlData
72
+** Parse the given URL. Populate members of the provided UrlData structure
7673
** as follows:
7774
**
7875
** isFile True if FILE:
7976
** isHttps True if HTTPS:
8077
** isSsh True if SSH:
@@ -86,42 +83,25 @@
8683
** user Userid.
8784
** passwd Password.
8885
** hostname HOST:PORT or just HOST if port is the default.
8986
** canonical The URL in canonical form, omitting the password
9087
**
91
-** This routine differs from url_parse() in that this routine stores the
92
-** results in pUrlData and does not change the values of global variables.
93
-** The url_parse() routine puts its result in g.url.
9488
*/
9589
void url_parse_local(
9690
const char *zUrl,
9791
unsigned int urlFlags,
9892
UrlData *pUrlData
9993
){
10094
int i, j, c;
10195
char *zFile = 0;
10296
103
- if( zUrl==0 || strcmp(zUrl,"default")==0 ){
97
+ if( zUrl==0 ){
10498
zUrl = db_get("last-sync-url", 0);
10599
if( zUrl==0 ) return;
106100
if( pUrlData->passwd==0 ){
107101
pUrlData->passwd = unobscure(db_get("last-sync-pw", 0));
108102
}
109
- pUrlData->isAlias = 1;
110
- }else{
111
- char *zAlt;
112
- zAlt = db_text(0, "SELECT value FROM config WHERE name='sync-url:%q'",zUrl);
113
- if( zAlt ){
114
- pUrlData->passwd = unobscure(
115
- db_text(0, "SELECT value FROM config WHERE name='sync-pw:%q'",zUrl)
116
- );
117
- zUrl = zAlt;
118
- urlFlags |= URL_REMEMBER_PW;
119
- pUrlData->isAlias = 1;
120
- }else{
121
- pUrlData->isAlias = 0;
122
- }
123103
}
124104
125105
if( strncmp(zUrl, "http://", 7)==0
126106
|| strncmp(zUrl, "https://", 8)==0
127107
|| strncmp(zUrl, "ssh://", 6)==0
@@ -281,12 +261,11 @@
281261
pUrlData->protocol = "file";
282262
pUrlData->path = "";
283263
pUrlData->name = mprintf("%b", &cfile);
284264
pUrlData->canonical = mprintf("file://%T", pUrlData->name);
285265
blob_reset(&cfile);
286
- }else if( pUrlData->user!=0 && pUrlData->passwd==0
287
- && (urlFlags & URL_PROMPT_PW)!=0 ){
266
+ }else if( pUrlData->user!=0 && pUrlData->passwd==0 && (urlFlags & URL_PROMPT_PW) ){
288267
url_prompt_for_password_local(pUrlData);
289268
}else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){
290269
if( isatty(fileno(stdin)) && ( urlFlags & URL_REMEMBER_PW )==0 ){
291270
if( save_password_prompt(pUrlData->passwd) ){
292271
pUrlData->flags = urlFlags |= URL_REMEMBER_PW;
@@ -297,13 +276,11 @@
297276
}
298277
}
299278
300279
/*
301280
** Parse the given URL, which describes a sync server. Populate variables
302
-** in the global "g.url" structure as shown below. If zUrl is NULL, then
303
-** parse the URL given in the last-sync-url setting, taking the password
304
-** form last-sync-pw.
281
+** in the global "g" structure as follows:
305282
**
306283
** g.url.isFile True if FILE:
307284
** g.url.isHttps True if HTTPS:
308285
** g.url.isSsh True if SSH:
309286
** g.url.protocol "http" or "https" or "file"
310287
--- src/url.c
+++ src/url.c
@@ -47,11 +47,10 @@
47 */
48 struct UrlData {
49 int isFile; /* True if a "file:" url */
50 int isHttps; /* True if a "https:" url */
51 int isSsh; /* True if an "ssh:" url */
52 int isAlias; /* Input URL was an alias */
53 char *name; /* Hostname for http: or filename for file: */
54 char *hostname; /* The HOST: parameter on http headers */
55 const char *protocol; /* "http" or "https" or "ssh" */
56 int port; /* TCP port number for http: or https: */
57 int dfltPort; /* The default port for the given protocol */
@@ -68,13 +67,11 @@
68 };
69 #endif /* INTERFACE */
70
71
72 /*
73 ** Parse the given URL. Or if zUrl is NULL, parse the URL in the
74 ** last-sync-url setting using last-sync-pw as the password. Store
75 ** the parser results in the pUrlData object. Populate members of pUrlData
76 ** as follows:
77 **
78 ** isFile True if FILE:
79 ** isHttps True if HTTPS:
80 ** isSsh True if SSH:
@@ -86,42 +83,25 @@
86 ** user Userid.
87 ** passwd Password.
88 ** hostname HOST:PORT or just HOST if port is the default.
89 ** canonical The URL in canonical form, omitting the password
90 **
91 ** This routine differs from url_parse() in that this routine stores the
92 ** results in pUrlData and does not change the values of global variables.
93 ** The url_parse() routine puts its result in g.url.
94 */
95 void url_parse_local(
96 const char *zUrl,
97 unsigned int urlFlags,
98 UrlData *pUrlData
99 ){
100 int i, j, c;
101 char *zFile = 0;
102
103 if( zUrl==0 || strcmp(zUrl,"default")==0 ){
104 zUrl = db_get("last-sync-url", 0);
105 if( zUrl==0 ) return;
106 if( pUrlData->passwd==0 ){
107 pUrlData->passwd = unobscure(db_get("last-sync-pw", 0));
108 }
109 pUrlData->isAlias = 1;
110 }else{
111 char *zAlt;
112 zAlt = db_text(0, "SELECT value FROM config WHERE name='sync-url:%q'",zUrl);
113 if( zAlt ){
114 pUrlData->passwd = unobscure(
115 db_text(0, "SELECT value FROM config WHERE name='sync-pw:%q'",zUrl)
116 );
117 zUrl = zAlt;
118 urlFlags |= URL_REMEMBER_PW;
119 pUrlData->isAlias = 1;
120 }else{
121 pUrlData->isAlias = 0;
122 }
123 }
124
125 if( strncmp(zUrl, "http://", 7)==0
126 || strncmp(zUrl, "https://", 8)==0
127 || strncmp(zUrl, "ssh://", 6)==0
@@ -281,12 +261,11 @@
281 pUrlData->protocol = "file";
282 pUrlData->path = "";
283 pUrlData->name = mprintf("%b", &cfile);
284 pUrlData->canonical = mprintf("file://%T", pUrlData->name);
285 blob_reset(&cfile);
286 }else if( pUrlData->user!=0 && pUrlData->passwd==0
287 && (urlFlags & URL_PROMPT_PW)!=0 ){
288 url_prompt_for_password_local(pUrlData);
289 }else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){
290 if( isatty(fileno(stdin)) && ( urlFlags & URL_REMEMBER_PW )==0 ){
291 if( save_password_prompt(pUrlData->passwd) ){
292 pUrlData->flags = urlFlags |= URL_REMEMBER_PW;
@@ -297,13 +276,11 @@
297 }
298 }
299
300 /*
301 ** Parse the given URL, which describes a sync server. Populate variables
302 ** in the global "g.url" structure as shown below. If zUrl is NULL, then
303 ** parse the URL given in the last-sync-url setting, taking the password
304 ** form last-sync-pw.
305 **
306 ** g.url.isFile True if FILE:
307 ** g.url.isHttps True if HTTPS:
308 ** g.url.isSsh True if SSH:
309 ** g.url.protocol "http" or "https" or "file"
310
--- src/url.c
+++ src/url.c
@@ -47,11 +47,10 @@
47 */
48 struct UrlData {
49 int isFile; /* True if a "file:" url */
50 int isHttps; /* True if a "https:" url */
51 int isSsh; /* True if an "ssh:" url */
 
52 char *name; /* Hostname for http: or filename for file: */
53 char *hostname; /* The HOST: parameter on http headers */
54 const char *protocol; /* "http" or "https" or "ssh" */
55 int port; /* TCP port number for http: or https: */
56 int dfltPort; /* The default port for the given protocol */
@@ -68,13 +67,11 @@
67 };
68 #endif /* INTERFACE */
69
70
71 /*
72 ** Parse the given URL. Populate members of the provided UrlData structure
 
 
73 ** as follows:
74 **
75 ** isFile True if FILE:
76 ** isHttps True if HTTPS:
77 ** isSsh True if SSH:
@@ -86,42 +83,25 @@
83 ** user Userid.
84 ** passwd Password.
85 ** hostname HOST:PORT or just HOST if port is the default.
86 ** canonical The URL in canonical form, omitting the password
87 **
 
 
 
88 */
89 void url_parse_local(
90 const char *zUrl,
91 unsigned int urlFlags,
92 UrlData *pUrlData
93 ){
94 int i, j, c;
95 char *zFile = 0;
96
97 if( zUrl==0 ){
98 zUrl = db_get("last-sync-url", 0);
99 if( zUrl==0 ) return;
100 if( pUrlData->passwd==0 ){
101 pUrlData->passwd = unobscure(db_get("last-sync-pw", 0));
102 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103 }
104
105 if( strncmp(zUrl, "http://", 7)==0
106 || strncmp(zUrl, "https://", 8)==0
107 || strncmp(zUrl, "ssh://", 6)==0
@@ -281,12 +261,11 @@
261 pUrlData->protocol = "file";
262 pUrlData->path = "";
263 pUrlData->name = mprintf("%b", &cfile);
264 pUrlData->canonical = mprintf("file://%T", pUrlData->name);
265 blob_reset(&cfile);
266 }else if( pUrlData->user!=0 && pUrlData->passwd==0 && (urlFlags & URL_PROMPT_PW) ){
 
267 url_prompt_for_password_local(pUrlData);
268 }else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){
269 if( isatty(fileno(stdin)) && ( urlFlags & URL_REMEMBER_PW )==0 ){
270 if( save_password_prompt(pUrlData->passwd) ){
271 pUrlData->flags = urlFlags |= URL_REMEMBER_PW;
@@ -297,13 +276,11 @@
276 }
277 }
278
279 /*
280 ** Parse the given URL, which describes a sync server. Populate variables
281 ** in the global "g" structure as follows:
 
 
282 **
283 ** g.url.isFile True if FILE:
284 ** g.url.isHttps True if HTTPS:
285 ** g.url.isSsh True if SSH:
286 ** g.url.protocol "http" or "https" or "file"
287

Keyboard Shortcuts

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