195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
-
+
-
+
|
** Pull all sharable changes from a remote repository into the local
** repository. Sharable changes include public check-ins, edits to
** wiki pages, tickets, and tech-notes, as well as forum content. Add
** the --private option to pull private branches. Use the
** "configuration pull" command to pull website configuration details.
**
** If URL is not specified, then the URL from the most recent clone, push,
** pull, remote, or sync command is used. See "fossil help clone" for
** pull, remote-url, or sync command is used. See "fossil help clone" for
** details on the URL formats.
**
** Options:
**
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
** if required by the remote website
** --from-parent-project Pull content from the parent project
** --ipv4 Use only IPv4, not IPv6
** --once Do not remember URL for subsequent syncs
** --private Pull private branches too
** --project-code CODE Use CODE as the project code
** --proxy PROXY Use the specified HTTP proxy
** -R|--repository REPO Local repository to pull into
** --ssl-identity FILE Local SSL credentials, if requested by remote
** --ssh-command SSH Use SSH as the "ssh" command
** -v|--verbose Additional (debugging) output
** --verily Exchange extra information with the remote
** to ensure no content is overlooked
**
** See also: [[clone]], [[config]], [[push]], [[remote]], [[sync]]
** See also: [[clone]], [[config]], [[push]], [[remote-url]], [[sync]]
*/
void pull_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PULL;
unsigned urlOmitFlags = 0;
const char *zAltPCode = find_option("project-code",0,1);
if( find_option("from-parent-project",0,0)!=0 ){
|
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
-
+
-
+
|
** Push all sharable changes from the local repository to a remote
** repository. Sharable changes include public check-ins, edits to
** wiki pages, tickets, and tech-notes, as well as forum content. Use
** --private to also push private branches. Use the "configuration
** push" command to push website configuration details.
**
** If URL is not specified, then the URL from the most recent clone, push,
** pull, remote, or sync command is used. See "fossil help clone" for
** pull, remote-url, or sync command is used. See "fossil help clone" for
** details on the URL formats.
**
** Options:
**
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
** if required by the remote website
** --ipv4 Use only IPv4, not IPv6
** --once Do not remember URL for subsequent syncs
** --proxy PROXY Use the specified HTTP proxy
** --private Push private branches too
** -R|--repository REPO Local repository to push from
** --ssl-identity FILE Local SSL credentials, if requested by remote
** --ssh-command SSH Use SSH as the "ssh" command
** -v|--verbose Additional (debugging) output
** --verily Exchange extra information with the remote
** to ensure no content is overlooked
**
** See also: [[clone]], [[config]], [[pull]], [[remote]], [[sync]]
** See also: [[clone]], [[config]], [[pull]], [[remote-url]], [[sync]]
*/
void push_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PUSH;
process_sync_args(&configFlags, &syncFlags, 0, 0);
/* We should be done with options.. */
|
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
-
+
-
+
|
** Usage: %fossil sync ?URL? ?options?
**
** Synchronize all sharable changes between the local repository and a
** remote repository. Sharable changes include public check-ins and
** edits to wiki pages, tickets, and technical notes.
**
** If URL is not specified, then the URL from the most recent clone, push,
** pull, remote, or sync command is used. See "fossil help clone" for
** pull, remote-url, or sync command is used. See "fossil help clone" for
** details on the URL formats.
**
** Options:
**
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
** if required by the remote website
** --ipv4 Use only IPv4, not IPv6
** --once Do not remember URL for subsequent syncs
** --proxy PROXY Use the specified HTTP proxy
** --private Sync private branches too
** -R|--repository REPO Local repository to sync with
** --ssl-identity FILE Local SSL credentials, if requested by remote
** --ssh-command SSH Use SSH as the "ssh" command
** -u|--unversioned Also sync unversioned content
** -v|--verbose Additional (debugging) output
** --verily Exchange extra information with the remote
** to ensure no content is overlooked
**
** See also: [[clone]], [[pull]], [[push]], [[remote]]
** See also: [[clone]], [[pull]], [[push]], [[remote-url]]
*/
void sync_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
if( find_option("unversioned","u",0)!=0 ){
syncFlags |= SYNC_UNVERSIONED;
}
|
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
-
-
+
+
+
+
+
+
|
client_sync(syncFlags, 0, 0, 0);
}
/*
** COMMAND: remote
** COMMAND: remote-url*
**
** Usage: %fossil remote ?SUBCOMMAND ...?
** Usage: %fossil remote-url ?URL|off?
**
** Use this command to view or modify the set of remote repositories
** used as the default target for sync, push, and pull and for autosync.
** Query and/or change the default server URL used by the "pull", "push",
** and "sync" commands.
**
** The default remote is set automatically by a "clone" command or by any
** "sync", "push", or "pull" command that specifies an explicit URL
** and omits the --once flag. The default remote is used by
** auto-syncing and by "sync", "push", and "pull" that omit the server URL.
** 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.
** Additional remotes can be added using the "add" command or deleted
** using the "delete" command. The name of any additional remote can be
** used as an argument to the "sync", "push", and "pull" commands where
** one would normally put a URL argument.
**
** See "fossil help clone" for further information about URL formats.
** See "fossil help clone" for further information about URL formats
**
** The official name of this command is "remote-url" but most people
** use the shortened name "remote".
**
** > fossil remote
** See also: clone, push, pull, sync
**
** With no arguments, this command shows the current default remote.
** Or if there is no default, it shows "off". The default remote is
** used by autosync. The default remote is whatever URL was specified
** for the most recent "sync", "push", or "pull" command that omitted
** the --once option.
**
** > fossil remote add NAME URL
**
** Add a new URL to the set of remotes. The new URL is assigned the
** symbolic identifier "NAME". Subsequently, NAME can be used in place
** of the full URL on commands like "push" and "pull".
**
** > fossil remote delete NAME
**
** Delete a URL previously added by the "add" subcommand.
**
** > fossil remote list
**
** Show all remote URLs
**
** > fossil remote off
**
** Disable the default URL. Use this as a shorthand to prevent
** autosync while in airplane mode, for example.
**
** > fossil remote URL
**
** Make URL the new default URL. The prior default URL is replaced.
*/
void remote_url_cmd(void){
char *zUrl, *zArg;
char *zUrl;
int nArg;
db_find_and_open_repository(0, 0);
/* We should be done with options.. */
verify_all_options();
if( g.argc==2 ){
if( g.argc!=2 && g.argc!=3 ){
/* "fossil remote" with no arguments: Show the last sync URL. */
zUrl = db_get("last-sync-url", 0);
if( zUrl==0 ){
fossil_print("off\n");
}else{
url_parse(zUrl, 0);
fossil_print("%s\n", g.url.canonical);
}
return;
}
zArg = g.argv[2];
nArg = (int)strlen(zArg);
if( strcmp(zArg,"off")==0 ){
/* fossil remote off
** Forget the last-sync-URL and its password
*/
if( g.argc!=3 ) usage("off");
usage("?URL|off?");
remote_delete_default:
db_multi_exec(
"DELETE FROM config WHERE name GLOB 'last-sync-*';"
);
return;
}
if( strncmp(zArg, "list", nArg)==0 || strcmp(zArg,"ls")==0 ){
Stmt q;
if( g.argc!=3 ) usage("list");
if( g.argc==3 ){
db_prepare(&q,
"SELECT 'default', value FROM config WHERE name='last-sync-url'"
" UNION ALL "
"SELECT substr(name,10), value FROM config"
" WHERE name GLOB 'sync-url:*'"
" ORDER BY 1"
);
while( db_step(&q)==SQLITE_ROW ){
fossil_print("%-18s %s\n", db_column_text(&q,0), db_column_text(&q,1));
}
db_finalize(&q);
return;
}
if( strcmp(zArg, "add")==0 ){
char *zName;
char *zUrl;
UrlData x;
if( g.argc!=5 ) usage("add NAME URL");
memset(&x, 0, sizeof(x));
zName = g.argv[3];
zUrl = g.argv[4];
if( strcmp(zName,"default")==0 ) goto remote_add_default;
url_parse_local(zUrl, URL_PROMPT_PW, &x);
db_begin_write();
db_multi_exec(
"REPLACE INTO config(name, value, mtime)"
" VALUES('sync-url:%q',%Q,now())",
zName, x.canonical
);
db_multi_exec(
"REPLACE INTO config(name, value, mtime)"
" VALUES('sync-pw:%q',obscure(%Q),now())",
zName, x.passwd
);
db_commit_transaction();
return;
}
if( strncmp(zArg, "delete", nArg)==0 ){
char *zName;
if( g.argc!=4 ) usage("delete NAME");
zName = g.argv[3];
if( strcmp(zName,"default")==0 ) goto remote_delete_default;
db_begin_write();
db_multi_exec("DELETE FROM config WHERE name glob 'sync-url:%q'", zName);
db_multi_exec("DELETE FROM config WHERE name glob 'sync-pw:%q'", zName);
db_commit_transaction();
return;
}
if( sqlite3_strlike("http://%",zArg,0)==0
|| sqlite3_strlike("https://%",zArg,0)==0
|| sqlite3_strlike("ssh:%",zArg,0)==0
|| sqlite3_strlike("file:%",zArg,0)==0
|| db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
){
remote_add_default:
db_unset("last-sync-url", 0);
db_unset("last-sync-pw", 0);
if( is_false(g.argv[2]) ) return;
url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
url_remember();
return;
}
url_remember();
zUrl = db_get("last-sync-url", 0);
if( zUrl==0 ){
fossil_fatal("unknown command \"%s\" - should be a URL or one of: "
"add delete list off", zArg);
fossil_print("off\n");
return;
}else{
url_parse(zUrl, 0);
fossil_print("%s\n", g.url.canonical);
}
}
/*
** COMMAND: backup*
**
** Usage: %fossil backup ?OPTIONS? FILE|DIRECTORY
**
|