Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Enhanced interpretation of the "autosync" setting. It is now possible to set the setting to "on,open=off" to cause autosync to be on by default but off for the "open" command, as an example. Use the "help autosync" command for further detail. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
346e45702cabbfeb000ba94c179343bd |
| User & Date: | drh 2022-04-15 13:51:12.600 |
References
|
2022-04-25
| ||
| 05:21 | Follow-up to [346e45702c]: Remove the (unused) --sync option for the open command, as considering it and overriding local/global/per-subsystem/pull-only/push-pull/dont-push settings in a fashion that is transparent for the user to anticipate what's really going on seems quite convoluted. Also mention that --force allows to continue if auto-sync fails. Closed-Leaf check-in: b3ed9d37d5 user: florian tags: open-sync | |
Context
|
2022-04-15
| ||
| 13:56 | Merge the enhanced load control measure to trunk. check-in: 9413395f5b user: drh tags: trunk | |
| 13:51 | Enhanced interpretation of the "autosync" setting. It is now possible to set the setting to "on,open=off" to cause autosync to be on by default but off for the "open" command, as an example. Use the "help autosync" command for further detail. check-in: 346e45702c user: drh tags: trunk | |
| 12:41 | Fix the "fossil open" command so that it honors global settings. check-in: 24420b4e63 user: drh tags: trunk | |
Changes
Changes to src/branch.c.
| ︙ | ︙ | |||
219 220 221 222 223 224 225 | } /* Commit */ db_end_transaction(0); /* Do an autosync push, if requested */ | | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | } /* Commit */ db_end_transaction(0); /* Do an autosync push, if requested */ if( !isPrivate ) autosync_loop(SYNC_PUSH, 0, "branch"); } /* ** Create a TEMP table named "tmp_brlist" with 7 columns: ** ** name Name of the branch ** mtime Time of last checkin on this branch |
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
2344 2345 2346 2347 2348 2349 2350 |
** Autosync if autosync is enabled and this is not a private check-in.
*/
if( !g.markPrivate ){
int syncFlags = SYNC_PULL;
if( vid!=0 && !allowFork && !forceFlag ){
syncFlags |= SYNC_CKIN_LOCK;
}
| | | 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 |
** Autosync if autosync is enabled and this is not a private check-in.
*/
if( !g.markPrivate ){
int syncFlags = SYNC_PULL;
if( vid!=0 && !allowFork && !forceFlag ){
syncFlags |= SYNC_CKIN_LOCK;
}
if( autosync_loop(syncFlags, 1, "commit") ){
fossil_exit(1);
}
}
/* So that older versions of Fossil (that do not understand delta-
** manifest) can continue to use this repository, do not create a new
** delta-manifest unless this repository already contains one or more
|
| ︙ | ︙ | |||
2550 2551 2552 2553 2554 2555 2556 |
db_end_transaction(0);
db_begin_transaction();
if( !g.markPrivate && vid!=0 && !allowFork && !forceFlag ){
/* Do another auto-pull, renewing the check-in lock. Then set
** bRecheck so that we loop back above to verify that the check-in
** is still not against a closed branch and still won't fork. */
int syncFlags = SYNC_PULL|SYNC_CKIN_LOCK;
| | | 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 |
db_end_transaction(0);
db_begin_transaction();
if( !g.markPrivate && vid!=0 && !allowFork && !forceFlag ){
/* Do another auto-pull, renewing the check-in lock. Then set
** bRecheck so that we loop back above to verify that the check-in
** is still not against a closed branch and still won't fork. */
int syncFlags = SYNC_PULL|SYNC_CKIN_LOCK;
if( autosync_loop(syncFlags, 1, "commit") ){
fossil_fatal("Auto-pull failed. Commit aborted.");
}
bRecheck = 1;
}
}else{
blob_zero(&comment);
}
|
| ︙ | ︙ | |||
2863 2864 2865 2866 2867 2868 2869 |
blob_write_to_file(&tagslist, zManifestFile);
blob_reset(&tagslist);
free(zManifestFile);
}
if( !g.markPrivate ){
int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE;
| | | 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 |
blob_write_to_file(&tagslist, zManifestFile);
blob_reset(&tagslist);
free(zManifestFile);
}
if( !g.markPrivate ){
int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE;
autosync_loop(syncFlags, 0, "commit");
}
if( count_nonbranch_children(vid)>1 ){
fossil_print("**** warning: a fork has occurred *****\n");
}else{
leaf_ambiguity_warning(nvid,nvid);
}
}
|
Changes to src/db.c.
| ︙ | ︙ | |||
3476 3477 3478 3479 3480 3481 3482 | va_start(ap, zFormat); zName = vmprintf(zFormat, ap); va_end(ap); db_unset(zName/*works-like:"x"*/, iGlobal); fossil_free(zName); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > | 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 |
va_start(ap, zFormat);
zName = vmprintf(zFormat, ap);
va_end(ap);
db_unset(zName/*works-like:"x"*/, iGlobal);
fossil_free(zName);
}
/*
** Get a setting that is taylored to subsystem. The return value is
** NULL if the setting does not exist, or a string obtained from mprintf()
** if the setting is available.
**
** The actual setting can be a comma-separated list of value of the form:
**
** * VALUE
** * SUBSYSTEM=VALUE
**
** A VALUE without the SUBSYSTEM= prefix is the default. This routine
** returns the VALUE that with the matching SUBSYSTEM, or the default
** VALUE if there is no match.
*/
char *db_get_for_subsystem(const char *zName, const char *zSubsys){
int nSubsys;
char *zToFree = 0;
char *zCopy;
char *zNext;
char *zResult = 0;
const char *zSetting = db_get(zName, 0);
if( zSetting==0 ) return 0;
zCopy = zToFree = fossil_strdup(zSetting);
if( zSubsys==0 ) zSubsys = "";
nSubsys = (int)strlen(zSubsys);
while( zCopy ){
zNext = strchr(zCopy, ',');
if( zNext ){
zNext[0] = 0;
do{ zNext++; }while( fossil_isspace(zNext[0]) );
if( zNext[0]==0 ) zNext = 0;
}
if( strchr(zCopy,'=')==0 ){
if( zResult==0 ) zResult = zCopy;
}else
if( nSubsys
&& strncmp(zCopy, zSubsys, nSubsys)==0
&& zCopy[nSubsys]=='='
){
zResult = &zCopy[nSubsys+1];
break;
}
zCopy = zNext;
}
if( zResult ) zResult = fossil_strdup(zResult);
fossil_free(zToFree);
return zResult;
}
#if INTERFACE
/* Manifest generation flags */
#define MFESTFLG_RAW 0x01
#define MFESTFLG_UUID 0x02
#define MFESTFLG_TAGS 0x04
#endif /* INTERFACE */
|
| ︙ | ︙ | |||
3622 3623 3624 3625 3626 3627 3628 | ** with the local repository. If you commit this checkout, ** it will become a new "initial" commit in the repository. ** -f|--force Continue with the open even if the working directory is ** not empty. ** --force-missing Force opening a repository with missing content ** -k|--keep Only modify the manifest and manifest.uuid files ** --nested Allow opening a repository inside an opened checkout | | > > > | 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 | ** with the local repository. If you commit this checkout, ** it will become a new "initial" commit in the repository. ** -f|--force Continue with the open even if the working directory is ** not empty. ** --force-missing Force opening a repository with missing content ** -k|--keep Only modify the manifest and manifest.uuid files ** --nested Allow opening a repository inside an opened checkout ** --nosync Do not auto-sync the repository prior to opening even ** if the autosync setting is on. ** --repodir DIR If REPOSITORY is a URI that will be cloned, store ** the clone in DIR rather than in "." ** --setmtime Set timestamps of all files to match their SCM-side ** times (the timestamp of the last checkin which modified ** them). ** --sync Auto-sync prior to opening even if the autosync setting ** is off. ** --verbose If passed a URI then this flag is passed on to the clone ** operation, otherwise it has no effect. ** --workdir DIR Use DIR as the working directory instead of ".". The DIR ** directory is created if it does not exist. ** ** See also: [[close]], [[clone]] */ |
| ︙ | ︙ | |||
3649 3650 3651 3652 3653 3654 3655 |
static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
const char *zWorkDir; /* --workdir value */
const char *zRepo = 0; /* Name of the repository file */
const char *zRepoDir = 0; /* --repodir value */
char *zPwd; /* Initial working directory */
int isUri = 0; /* True if REPOSITORY is a URI */
int nLocal; /* Number of preexisting files in cwd */
| < | | < | 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 |
static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
const char *zWorkDir; /* --workdir value */
const char *zRepo = 0; /* Name of the repository file */
const char *zRepoDir = 0; /* --repodir value */
char *zPwd; /* Initial working directory */
int isUri = 0; /* True if REPOSITORY is a URI */
int nLocal; /* Number of preexisting files in cwd */
int bVerbose = 0; /* --verbose option for clone */
url_proxy_options();
emptyFlag = find_option("empty",0,0)!=0;
keepFlag = find_option("keep","k",0)!=0;
forceMissingFlag = find_option("force-missing",0,0)!=0;
allowNested = find_option("nested",0,0)!=0;
setmtimeFlag = find_option("setmtime",0,0)!=0;
zWorkDir = find_option("workdir",0,1);
zRepoDir = find_option("repodir",0,1);
bForce = find_option("force","f",0)!=0;
if( find_option("nosync",0,0) ) g.fNoSync = 1;
bVerbose = find_option("verbose",0,0)!=0;
zPwd = file_getcwd(0,0);
/* We should be done with options.. */
verify_all_options();
if( g.argc!=3 && g.argc!=4 ){
usage("REPOSITORY-FILENAME ?VERSION?");
}
|
| ︙ | ︙ | |||
3764 3765 3766 3767 3768 3769 3770 |
/* Figure out which revision to open. */
if( !emptyFlag ){
if( g.argc==4 ){
g.zOpenRevision = g.argv[3];
}else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
g.zOpenRevision = db_get("main-branch", 0);
}
| < | < < | 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 |
/* Figure out which revision to open. */
if( !emptyFlag ){
if( g.argc==4 ){
g.zOpenRevision = g.argv[3];
}else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
g.zOpenRevision = db_get("main-branch", 0);
}
if( autosync_loop(SYNC_PULL, !bForce, "open") && !bForce ){
fossil_fatal("unable to auto-sync the repository");
}
}
#if defined(_WIN32) || defined(__CYGWIN__)
# define LOCALDB_NAME "./_FOSSIL_"
|
| ︙ | ︙ | |||
3971 3972 3973 3974 3975 3976 3977 | /* ** SETTING: auto-shun boolean default=on ** If enabled, automatically pull the shunning list ** from a server to which the client autosyncs. */ /* ** SETTING: autosync width=16 default=on | | > | < | | | | | > | > > > > > > > > > | 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 |
/*
** SETTING: auto-shun boolean default=on
** If enabled, automatically pull the shunning list
** from a server to which the client autosyncs.
*/
/*
** SETTING: autosync width=16 default=on
** This setting determines when autosync occurs. The setting is a
** string that provides a lot of flexibility for determining when and
** when not to autosync. Examples:
**
** on Always autosync for command where autosync
** makes sense ("commit", "merge", "open", "update")
**
** off Never autosync.
**
** pullonly Only to pull autosyncs
**
** on,open=off Autosync for most commands, but not for "open"
**
** off,commit=pullonly Do not autosync, except do a pull before each
** "commit", presumably to avoid undesirable
** forks.
**
** The syntax is a comma-separated list of VALUE and COMMAND=VALUE entries.
** A plain VALUE entry is the default that is used if no COMMAND matches.
** Otherwise, the VALUE of the matching command is used.
*/
/*
** SETTING: autosync-tries width=16 default=1
** If autosync is enabled setting this to a value greater
** than zero will cause autosync to try no more than this
** number of attempts if there is a sync failure.
*/
|
| ︙ | ︙ | |||
4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 |
**
** See also: [[configuration]]
*/
void setting_cmd(void){
int i;
int globalFlag = find_option("global","g",0)!=0;
int exactFlag = find_option("exact",0,0)!=0;
int unsetFlag = g.argv[1][0]=='u';
int nSetting;
const Setting *aSetting = setting_info(&nSetting);
find_repository_option();
verify_all_options();
db_open_config(1, 0);
if( !globalFlag ){
| > > > | 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 |
**
** See also: [[configuration]]
*/
void setting_cmd(void){
int i;
int globalFlag = find_option("global","g",0)!=0;
int exactFlag = find_option("exact",0,0)!=0;
/* Undocumented "--test-for-subsystem SUBSYS" option used to test
** the db_get_for_subsystem() interface: */
const char *zSubsys = find_option("test-for-subsystem",0,1);
int unsetFlag = g.argv[1][0]=='u';
int nSetting;
const Setting *aSetting = setting_info(&nSetting);
find_repository_option();
verify_all_options();
db_open_config(1, 0);
if( !globalFlag ){
|
| ︙ | ︙ | |||
4623 4624 4625 4626 4627 4628 4629 |
}else{
while( pSetting->name ){
if( exactFlag ){
if( fossil_strcmp(pSetting->name,zName)!=0 ) break;
}else{
if( fossil_strncmp(pSetting->name,zName,n)!=0 ) break;
}
| > > > > > > > > > | > | 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 |
}else{
while( pSetting->name ){
if( exactFlag ){
if( fossil_strcmp(pSetting->name,zName)!=0 ) break;
}else{
if( fossil_strncmp(pSetting->name,zName,n)!=0 ) break;
}
if( zSubsys ){
char *zValue = db_get_for_subsystem(pSetting->name, zSubsys);
fossil_print("%s (subsystem %s) ->", pSetting->name, zSubsys);
if( zValue ){
fossil_print(" [%s]", zValue);
fossil_free(zValue);
}
fossil_print("\n");
}else{
print_setting(pSetting);
}
pSetting++;
}
}
}else{
usage("?PROPERTY? ?VALUE? ?-global?");
}
}
|
| ︙ | ︙ |
Changes to src/json_branch.c.
| ︙ | ︙ | |||
304 305 306 307 308 309 310 |
if( zNewRid ){
*zNewRid = brid;
}
/* Commit */
db_end_transaction(0);
| < < < < | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
if( zNewRid ){
*zNewRid = brid;
}
/* Commit */
db_end_transaction(0);
return 0;
}
/*
** Impl of /json/branch/create.
*/
|
| ︙ | ︙ |
Changes to src/merge.c.
| ︙ | ︙ | |||
405 406 407 408 409 410 411 |
if( vid==0 ){
fossil_fatal("nothing is checked out");
}
if( forceFlag==0 && leaf_is_closed(vid) ){
fossil_fatal("cannot merge into a closed leaf. Use --force to override");
}
if( !dryRunFlag ){
| | | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
if( vid==0 ){
fossil_fatal("nothing is checked out");
}
if( forceFlag==0 && leaf_is_closed(vid) ){
fossil_fatal("cannot merge into a closed leaf. Use --force to override");
}
if( !dryRunFlag ){
if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1, "merge") ){
fossil_fatal("merge abandoned due to sync failure");
}
}
/* Find mid, the artifactID of the version to be merged into the current
** check-out */
if( g.argc==3 ){
|
| ︙ | ︙ |
Changes to src/sync.c.
| ︙ | ︙ | |||
110 111 112 113 114 115 116 | ** is attempted if the autosync setting is off, and only auto-pull is ** attempted if autosync is set to "pullonly". The check-in lock is ** not acquired unless autosync is set to "on". ** ** If dont-push setting is true, that is the same as having autosync ** set to pullonly. */ | | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
** is attempted if the autosync setting is off, and only auto-pull is
** attempted if autosync is set to "pullonly". The check-in lock is
** not acquired unless autosync is set to "on".
**
** If dont-push setting is true, that is the same as having autosync
** set to pullonly.
*/
static int autosync(int flags, const char *zSubsys){
const char *zAutosync;
int rc;
int configSync = 0; /* configuration changes transferred */
if( g.fNoSync ){
return 0;
}
zAutosync = db_get_for_subsystem("autosync", zSubsys);
if( zAutosync==0 ) zAutosync = "on"; /* defend against misconfig */
if( is_false(zAutosync) ) return 0;
if( db_get_boolean("dont-push",0)
|| sqlite3_strglob("*pull*", zAutosync)==0
){
flags &= ~SYNC_CKIN_LOCK;
if( flags & SYNC_PUSH ) return 0;
|
| ︙ | ︙ | |||
155 156 157 158 159 160 161 | ** 0.5 second sleep between attempts. The number of attempts is determined ** by the "autosync-tries" setting, which defaults to 1. ** ** Return zero on success and non-zero on a failure. If failure occurs ** and doPrompt flag is true, ask the user if they want to continue, and ** if they answer "yes" then return zero in spite of the failure. */ | | > | | 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 |
** 0.5 second sleep between attempts. The number of attempts is determined
** by the "autosync-tries" setting, which defaults to 1.
**
** Return zero on success and non-zero on a failure. If failure occurs
** and doPrompt flag is true, ask the user if they want to continue, and
** if they answer "yes" then return zero in spite of the failure.
*/
int autosync_loop(int flags, int doPrompt, const char *zSubsystem){
int n = 0;
int rc = 0;
int nTries = db_get_int("autosync-tries", 1);
if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
&& db_get_boolean("uv-sync",0)
){
flags |= SYNC_UNVERSIONED;
}
if( nTries<1 ) nTries = 1;
while( (n==0 || n<nTries) && (rc=autosync(flags, zSubsystem)) ){
if( rc ){
if( ++n<nTries ){
fossil_warning("Autosync failed, making another attempt.");
sqlite3_sleep(500);
}else{
fossil_warning("Autosync failed.");
}
|
| ︙ | ︙ |
Changes to src/update.c.
| ︙ | ︙ | |||
163 164 165 166 167 168 169 |
/* We should be done with options.. */
verify_all_options();
db_must_be_within_tree();
vid = db_lget_int("checkout", 0);
user_select();
if( !dryRunFlag && !internalUpdate && !bNosync ){
| | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
/* We should be done with options.. */
verify_all_options();
db_must_be_within_tree();
vid = db_lget_int("checkout", 0);
user_select();
if( !dryRunFlag && !internalUpdate && !bNosync ){
if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1, "update") ){
fossil_fatal("update abandoned due to sync failure");
}
}
/* Create any empty directories now, as well as after the update,
** so changes in settings are reflected now */
if( !dryRunFlag ) ensure_empty_dirs_created(0);
|
| ︙ | ︙ |