Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the --all option to "fossil sync" and similar, causing the sync to occur against all remote repositories shown in "fossil remote list". |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
6b4a04d4494faae2ad66bb54d85616b0 |
| User & Date: | drh 2021-10-24 19:47:47.805 |
Context
|
2021-10-25
| ||
| 09:22 | Add the "fossil remote scrub" command. Prompt for missing passwords on auxiliary remotes when they are needed. check-in: 7f2e34c5c4 user: drh tags: trunk | |
|
2021-10-24
| ||
| 19:47 | Add the --all option to "fossil sync" and similar, causing the sync to occur against all remote repositories shown in "fossil remote list". check-in: 6b4a04d449 user: drh tags: trunk | |
|
2021-10-22
| ||
| 19:26 | Show notBefore and notAfter timestamps for unknown TLS certificates. check-in: 5623188de3 user: danield tags: trunk | |
Changes
Changes to src/sync.c.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ******************************************************************************* ** ** This file contains code used to push, pull, and sync a repository */ #include "config.h" #include "sync.h" #include <assert.h> /* ** If the repository is configured for autosyncing, then do an ** autosync. Bits of the "flags" parameter determine details of behavior: ** ** SYNC_PULL Pull content from the server to the local repo ** SYNC_PUSH Push content from local up to the server | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
*******************************************************************************
**
** This file contains code used to push, pull, and sync a repository
*/
#include "config.h"
#include "sync.h"
#include <assert.h>
/*
** Explain what type of sync operation is about to occur
*/
static void sync_explain(unsigned syncFlags){
if( g.url.isAlias ){
if( (syncFlags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
fossil_print("Sync with %s\n", g.url.canonical);
}else if( syncFlags & SYNC_PUSH ){
fossil_print("Push to %s\n", g.url.canonical);
}else if( syncFlags & SYNC_PULL ){
fossil_print("Pull from %s\n", g.url.canonical);
}
}
}
/*
** Call client_sync() one or more times in order to complete a
** sync operation. Usually, client_sync() is called only once, though
** is can be called multiple times if the SYNC_ALLURL flags is set.
*/
static int client_sync_all_urls(
unsigned syncFlags, /* Mask of SYNC_* flags */
unsigned configRcvMask, /* Receive these configuration items */
unsigned configSendMask, /* Send these configuration items */
const char *zAltPCode /* Alternative project code (usually NULL) */
){
int nErr;
int nOther;
char **azOther;
int i;
Stmt q;
sync_explain(syncFlags);
nErr = client_sync(syncFlags, configRcvMask, configSendMask, zAltPCode);
if( (syncFlags & SYNC_ALLURL)==0 ) return nErr;
nOther = 0;
azOther = 0;
db_prepare(&q,
"SELECT substr(name,10) FROM config"
" WHERE name glob 'sync-url:*'"
" AND value<>(SELECT value FROM config WHERE name='last-sync-url')"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zUrl = db_column_text(&q, 0);
azOther = fossil_realloc(azOther, sizeof(*azOther)*(nOther+1));
azOther[nOther++] = fossil_strdup(zUrl);
}
db_finalize(&q);
for(i=0; i<nOther; i++){
url_unparse(&g.url);
url_parse(azOther[i], URL_PROMPT_PW);
sync_explain(syncFlags);
nErr += client_sync(syncFlags, configRcvMask, configSendMask, zAltPCode);
fossil_free(azOther[i]);
azOther[i] = 0;
}
fossil_free(azOther);
return nErr;
}
/*
** If the repository is configured for autosyncing, then do an
** autosync. Bits of the "flags" parameter determine details of behavior:
**
** SYNC_PULL Pull content from the server to the local repo
** SYNC_PUSH Push content from local up to the server
|
| ︙ | ︙ | |||
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
}
if( find_option("verbose","v",0)!=0 ){
*pSyncFlags |= SYNC_VERBOSE;
}
if( find_option("no-http-compression",0,0)!=0 ){
*pSyncFlags |= SYNC_NOHTTPCOMPRESS;
}
url_proxy_options();
clone_ssh_find_options();
if( !uvOnly ) db_find_and_open_repository(0, 0);
db_open_config(0, 1);
if( g.argc==2 ){
if( db_get_boolean("auto-shun",0) ) configSync = CONFIGSET_SHUN;
}else if( g.argc==3 ){
zUrl = g.argv[2];
}
if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
&& db_get_boolean("uv-sync",0)
){
*pSyncFlags |= SYNC_UNVERSIONED;
}
urlFlags &= ~urlOmitFlags;
if( urlFlags & URL_REMEMBER ){
clone_ssh_db_set_options();
}
url_parse(zUrl, urlFlags);
remember_or_get_http_auth(zHttpAuth, urlFlags & URL_REMEMBER, zUrl);
url_remember();
if( g.url.protocol==0 ){
if( urlOptional ) fossil_exit(0);
usage("URL");
}
user_select();
| > > > > > > > < < < < < < < < < > > | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 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 |
}
if( find_option("verbose","v",0)!=0 ){
*pSyncFlags |= SYNC_VERBOSE;
}
if( find_option("no-http-compression",0,0)!=0 ){
*pSyncFlags |= SYNC_NOHTTPCOMPRESS;
}
if( find_option("all",0,0)!=0 ){
*pSyncFlags |= SYNC_ALLURL;
}
url_proxy_options();
clone_ssh_find_options();
if( !uvOnly ) db_find_and_open_repository(0, 0);
db_open_config(0, 1);
if( g.argc==2 ){
if( db_get_boolean("auto-shun",0) ) configSync = CONFIGSET_SHUN;
}else if( g.argc==3 ){
zUrl = g.argv[2];
if( (*pSyncFlags) & SYNC_ALLURL ){
fossil_fatal("cannot use both the --all option and specific URL \"%s\"",
zUrl);
}
}
if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
&& db_get_boolean("uv-sync",0)
){
*pSyncFlags |= SYNC_UNVERSIONED;
}
urlFlags &= ~urlOmitFlags;
if( urlFlags & URL_REMEMBER ){
clone_ssh_db_set_options();
}
url_parse(zUrl, urlFlags);
remember_or_get_http_auth(zHttpAuth, urlFlags & URL_REMEMBER, zUrl);
url_remember();
if( g.url.protocol==0 ){
if( urlOptional ) fossil_exit(0);
usage("URL");
}
user_select();
url_enable_proxy("via proxy: ");
*pConfigFlags |= configSync;
}
/*
** COMMAND: pull
**
** Usage: %fossil pull ?URL? ?options?
**
** Pull all sharable changes from a remote repository into the local
** repository. Sharable changes include public check-ins, edits to
** wiki pages, tickets, tech-notes, and forum posts. 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
** details on the URL formats.
**
** Options:
**
** --all Pull from all remotes, not just the default
** -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
** --no-http-compression Do not compress HTTP traffic
** --once Do not remember URL for subsequent syncs
** --private Pull private branches too
|
| ︙ | ︙ | |||
235 236 237 238 239 240 241 | } if( zAltPCode ) urlOmitFlags = URL_REMEMBER; process_sync_args(&configFlags, &syncFlags, 0, urlOmitFlags); /* We should be done with options.. */ verify_all_options(); | | > | 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 325 326 327 328 329 330 331 | } if( zAltPCode ) urlOmitFlags = URL_REMEMBER; process_sync_args(&configFlags, &syncFlags, 0, urlOmitFlags); /* We should be done with options.. */ verify_all_options(); client_sync_all_urls(syncFlags, configFlags, 0, zAltPCode); } /* ** COMMAND: push ** ** Usage: %fossil push ?URL? ?options? ** ** Push all sharable changes from the local repository to a remote ** repository. Sharable changes include public check-ins, edits to ** wiki pages, tickets, tech-notes, and forum posts. 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 ** details on the URL formats. ** ** Options: ** ** --all Push to all remotes, not just the default ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol, ** if required by the remote website ** --ipv4 Use only IPv4, not IPv6 ** --no-http-compression Do not compress HTTP traffic ** --once Do not remember URL for subsequent syncs ** --proxy PROXY Use the specified HTTP proxy ** --private Push private branches too |
| ︙ | ︙ | |||
282 283 284 285 286 287 288 |
/* We should be done with options.. */
verify_all_options();
if( db_get_boolean("dont-push",0) ){
fossil_fatal("pushing is prohibited: the 'dont-push' option is set");
}
| | > | 345 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 |
/* We should be done with options.. */
verify_all_options();
if( db_get_boolean("dont-push",0) ){
fossil_fatal("pushing is prohibited: the 'dont-push' option is set");
}
client_sync_all_urls(syncFlags, 0, 0, 0);
}
/*
** COMMAND: sync
**
** 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, forum posts, 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
** details on the URL formats.
**
** Options:
**
** --all Sync with all remotes, not just the default
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
** if required by the remote website
** --ipv4 Use only IPv4, not IPv6
** --no-http-compression Do not compress HTTP traffic
** --once Do not remember URL for subsequent syncs
** --proxy PROXY Use the specified HTTP proxy
** --private Sync private branches too
|
| ︙ | ︙ | |||
330 331 332 333 334 335 336 |
}
process_sync_args(&configFlags, &syncFlags, 0, 0);
/* We should be done with options.. */
verify_all_options();
if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
| < > | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
}
process_sync_args(&configFlags, &syncFlags, 0, 0);
/* We should be done with options.. */
verify_all_options();
if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
if( (syncFlags & SYNC_PUSH)==0 ){
fossil_warning("pull only: the 'dont-push' option is set");
}
client_sync_all_urls(syncFlags, configFlags, 0, 0);
}
/*
** Handle the "fossil unversioned sync" and "fossil unversioned revert"
** commands.
*/
void sync_unversioned(unsigned syncFlags){
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 |
#define SYNC_UNVERSIONED 0x0100 /* Sync unversioned content */
#define SYNC_UV_REVERT 0x0200 /* Copy server unversioned to client */
#define SYNC_UV_TRACE 0x0400 /* Describe UV activities */
#define SYNC_UV_DRYRUN 0x0800 /* Do not actually exchange files */
#define SYNC_IFABLE 0x1000 /* Inability to sync is not fatal */
#define SYNC_CKIN_LOCK 0x2000 /* Lock the current check-in */
#define SYNC_NOHTTPCOMPRESS 0x4000 /* Do not compression HTTP messages */
#endif
/*
** Floating-point absolute value
*/
static double fossil_fabs(double x){
return x>0.0 ? x : -x;
| > | 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 |
#define SYNC_UNVERSIONED 0x0100 /* Sync unversioned content */
#define SYNC_UV_REVERT 0x0200 /* Copy server unversioned to client */
#define SYNC_UV_TRACE 0x0400 /* Describe UV activities */
#define SYNC_UV_DRYRUN 0x0800 /* Do not actually exchange files */
#define SYNC_IFABLE 0x1000 /* Inability to sync is not fatal */
#define SYNC_CKIN_LOCK 0x2000 /* Lock the current check-in */
#define SYNC_NOHTTPCOMPRESS 0x4000 /* Do not compression HTTP messages */
#define SYNC_ALLURL 0x8000 /* The --all flag - sync to all URLs */
#endif
/*
** Floating-point absolute value
*/
static double fossil_fabs(double x){
return x>0.0 ? x : -x;
|
| ︙ | ︙ |