Fossil SCM

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.

drh 2022-04-15 13:51 trunk
Commit 346e45702cabbfeb000ba94c179343bdd8a059fe5c6ff658208ddcd9fbbe6fd3
+1 -1
--- src/branch.c
+++ src/branch.c
@@ -221,11 +221,11 @@
221221
222222
/* Commit */
223223
db_end_transaction(0);
224224
225225
/* Do an autosync push, if requested */
226
- if( !isPrivate ) autosync_loop(SYNC_PUSH, 0);
226
+ if( !isPrivate ) autosync_loop(SYNC_PUSH, 0, "branch");
227227
}
228228
229229
/*
230230
** Create a TEMP table named "tmp_brlist" with 7 columns:
231231
**
232232
--- src/branch.c
+++ src/branch.c
@@ -221,11 +221,11 @@
221
222 /* Commit */
223 db_end_transaction(0);
224
225 /* Do an autosync push, if requested */
226 if( !isPrivate ) autosync_loop(SYNC_PUSH, 0);
227 }
228
229 /*
230 ** Create a TEMP table named "tmp_brlist" with 7 columns:
231 **
232
--- src/branch.c
+++ src/branch.c
@@ -221,11 +221,11 @@
221
222 /* Commit */
223 db_end_transaction(0);
224
225 /* Do an autosync push, if requested */
226 if( !isPrivate ) autosync_loop(SYNC_PUSH, 0, "branch");
227 }
228
229 /*
230 ** Create a TEMP table named "tmp_brlist" with 7 columns:
231 **
232
+3 -3
--- src/checkin.c
+++ src/checkin.c
@@ -2346,11 +2346,11 @@
23462346
if( !g.markPrivate ){
23472347
int syncFlags = SYNC_PULL;
23482348
if( vid!=0 && !allowFork && !forceFlag ){
23492349
syncFlags |= SYNC_CKIN_LOCK;
23502350
}
2351
- if( autosync_loop(syncFlags, 1) ){
2351
+ if( autosync_loop(syncFlags, 1, "commit") ){
23522352
fossil_exit(1);
23532353
}
23542354
}
23552355
23562356
/* So that older versions of Fossil (that do not understand delta-
@@ -2552,11 +2552,11 @@
25522552
if( !g.markPrivate && vid!=0 && !allowFork && !forceFlag ){
25532553
/* Do another auto-pull, renewing the check-in lock. Then set
25542554
** bRecheck so that we loop back above to verify that the check-in
25552555
** is still not against a closed branch and still won't fork. */
25562556
int syncFlags = SYNC_PULL|SYNC_CKIN_LOCK;
2557
- if( autosync_loop(syncFlags, 1) ){
2557
+ if( autosync_loop(syncFlags, 1, "commit") ){
25582558
fossil_fatal("Auto-pull failed. Commit aborted.");
25592559
}
25602560
bRecheck = 1;
25612561
}
25622562
}else{
@@ -2865,13 +2865,13 @@
28652865
free(zManifestFile);
28662866
}
28672867
28682868
if( !g.markPrivate ){
28692869
int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE;
2870
- autosync_loop(syncFlags, 0);
2870
+ autosync_loop(syncFlags, 0, "commit");
28712871
}
28722872
if( count_nonbranch_children(vid)>1 ){
28732873
fossil_print("**** warning: a fork has occurred *****\n");
28742874
}else{
28752875
leaf_ambiguity_warning(nvid,nvid);
28762876
}
28772877
}
28782878
--- src/checkin.c
+++ src/checkin.c
@@ -2346,11 +2346,11 @@
2346 if( !g.markPrivate ){
2347 int syncFlags = SYNC_PULL;
2348 if( vid!=0 && !allowFork && !forceFlag ){
2349 syncFlags |= SYNC_CKIN_LOCK;
2350 }
2351 if( autosync_loop(syncFlags, 1) ){
2352 fossil_exit(1);
2353 }
2354 }
2355
2356 /* So that older versions of Fossil (that do not understand delta-
@@ -2552,11 +2552,11 @@
2552 if( !g.markPrivate && vid!=0 && !allowFork && !forceFlag ){
2553 /* Do another auto-pull, renewing the check-in lock. Then set
2554 ** bRecheck so that we loop back above to verify that the check-in
2555 ** is still not against a closed branch and still won't fork. */
2556 int syncFlags = SYNC_PULL|SYNC_CKIN_LOCK;
2557 if( autosync_loop(syncFlags, 1) ){
2558 fossil_fatal("Auto-pull failed. Commit aborted.");
2559 }
2560 bRecheck = 1;
2561 }
2562 }else{
@@ -2865,13 +2865,13 @@
2865 free(zManifestFile);
2866 }
2867
2868 if( !g.markPrivate ){
2869 int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE;
2870 autosync_loop(syncFlags, 0);
2871 }
2872 if( count_nonbranch_children(vid)>1 ){
2873 fossil_print("**** warning: a fork has occurred *****\n");
2874 }else{
2875 leaf_ambiguity_warning(nvid,nvid);
2876 }
2877 }
2878
--- src/checkin.c
+++ src/checkin.c
@@ -2346,11 +2346,11 @@
2346 if( !g.markPrivate ){
2347 int syncFlags = SYNC_PULL;
2348 if( vid!=0 && !allowFork && !forceFlag ){
2349 syncFlags |= SYNC_CKIN_LOCK;
2350 }
2351 if( autosync_loop(syncFlags, 1, "commit") ){
2352 fossil_exit(1);
2353 }
2354 }
2355
2356 /* So that older versions of Fossil (that do not understand delta-
@@ -2552,11 +2552,11 @@
2552 if( !g.markPrivate && vid!=0 && !allowFork && !forceFlag ){
2553 /* Do another auto-pull, renewing the check-in lock. Then set
2554 ** bRecheck so that we loop back above to verify that the check-in
2555 ** is still not against a closed branch and still won't fork. */
2556 int syncFlags = SYNC_PULL|SYNC_CKIN_LOCK;
2557 if( autosync_loop(syncFlags, 1, "commit") ){
2558 fossil_fatal("Auto-pull failed. Commit aborted.");
2559 }
2560 bRecheck = 1;
2561 }
2562 }else{
@@ -2865,13 +2865,13 @@
2865 free(zManifestFile);
2866 }
2867
2868 if( !g.markPrivate ){
2869 int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE;
2870 autosync_loop(syncFlags, 0, "commit");
2871 }
2872 if( count_nonbranch_children(vid)>1 ){
2873 fossil_print("**** warning: a fork has occurred *****\n");
2874 }else{
2875 leaf_ambiguity_warning(nvid,nvid);
2876 }
2877 }
2878
+88 -20
--- src/db.c
+++ src/db.c
@@ -3478,11 +3478,58 @@
34783478
va_end(ap);
34793479
db_unset(zName/*works-like:"x"*/, iGlobal);
34803480
fossil_free(zName);
34813481
}
34823482
3483
-
3483
+/*
3484
+** Get a setting that is taylored to subsystem. The return value is
3485
+** NULL if the setting does not exist, or a string obtained from mprintf()
3486
+** if the setting is available.
3487
+**
3488
+** The actual setting can be a comma-separated list of value of the form:
3489
+**
3490
+** * VALUE
3491
+** * SUBSYSTEM=VALUE
3492
+**
3493
+** A VALUE without the SUBSYSTEM= prefix is the default. This routine
3494
+** returns the VALUE that with the matching SUBSYSTEM, or the default
3495
+** VALUE if there is no match.
3496
+*/
3497
+char *db_get_for_subsystem(const char *zName, const char *zSubsys){
3498
+ int nSubsys;
3499
+ char *zToFree = 0;
3500
+ char *zCopy;
3501
+ char *zNext;
3502
+ char *zResult = 0;
3503
+ const char *zSetting = db_get(zName, 0);
3504
+ if( zSetting==0 ) return 0;
3505
+ zCopy = zToFree = fossil_strdup(zSetting);
3506
+ if( zSubsys==0 ) zSubsys = "";
3507
+ nSubsys = (int)strlen(zSubsys);
3508
+ while( zCopy ){
3509
+ zNext = strchr(zCopy, ',');
3510
+ if( zNext ){
3511
+ zNext[0] = 0;
3512
+ do{ zNext++; }while( fossil_isspace(zNext[0]) );
3513
+ if( zNext[0]==0 ) zNext = 0;
3514
+ }
3515
+ if( strchr(zCopy,'=')==0 ){
3516
+ if( zResult==0 ) zResult = zCopy;
3517
+ }else
3518
+ if( nSubsys
3519
+ && strncmp(zCopy, zSubsys, nSubsys)==0
3520
+ && zCopy[nSubsys]=='='
3521
+ ){
3522
+ zResult = &zCopy[nSubsys+1];
3523
+ break;
3524
+ }
3525
+ zCopy = zNext;
3526
+ }
3527
+ if( zResult ) zResult = fossil_strdup(zResult);
3528
+ fossil_free(zToFree);
3529
+ return zResult;
3530
+}
34843531
34853532
#if INTERFACE
34863533
/* Manifest generation flags */
34873534
#define MFESTFLG_RAW 0x01
34883535
#define MFESTFLG_UUID 0x02
@@ -3624,16 +3671,19 @@
36243671
** -f|--force Continue with the open even if the working directory is
36253672
** not empty.
36263673
** --force-missing Force opening a repository with missing content
36273674
** -k|--keep Only modify the manifest and manifest.uuid files
36283675
** --nested Allow opening a repository inside an opened checkout
3629
-** --nosync Do not auto-sync the repository prior to opening
3676
+** --nosync Do not auto-sync the repository prior to opening even
3677
+** if the autosync setting is on.
36303678
** --repodir DIR If REPOSITORY is a URI that will be cloned, store
36313679
** the clone in DIR rather than in "."
36323680
** --setmtime Set timestamps of all files to match their SCM-side
36333681
** times (the timestamp of the last checkin which modified
36343682
** them).
3683
+** --sync Auto-sync prior to opening even if the autosync setting
3684
+** is off.
36353685
** --verbose If passed a URI then this flag is passed on to the clone
36363686
** operation, otherwise it has no effect.
36373687
** --workdir DIR Use DIR as the working directory instead of ".". The DIR
36383688
** directory is created if it does not exist.
36393689
**
@@ -3651,11 +3701,10 @@
36513701
const char *zRepo = 0; /* Name of the repository file */
36523702
const char *zRepoDir = 0; /* --repodir value */
36533703
char *zPwd; /* Initial working directory */
36543704
int isUri = 0; /* True if REPOSITORY is a URI */
36553705
int nLocal; /* Number of preexisting files in cwd */
3656
- int bNosync = 0; /* --nosync. Omit auto-sync */
36573706
int bVerbose = 0; /* --verbose option for clone */
36583707
36593708
url_proxy_options();
36603709
emptyFlag = find_option("empty",0,0)!=0;
36613710
keepFlag = find_option("keep","k",0)!=0;
@@ -3662,15 +3711,14 @@
36623711
forceMissingFlag = find_option("force-missing",0,0)!=0;
36633712
allowNested = find_option("nested",0,0)!=0;
36643713
setmtimeFlag = find_option("setmtime",0,0)!=0;
36653714
zWorkDir = find_option("workdir",0,1);
36663715
zRepoDir = find_option("repodir",0,1);
3667
- bForce = find_option("force","f",0)!=0;
3668
- bNosync = find_option("nosync",0,0)!=0;
3716
+ bForce = find_option("force","f",0)!=0;
3717
+ if( find_option("nosync",0,0) ) g.fNoSync = 1;
36693718
bVerbose = find_option("verbose",0,0)!=0;
36703719
zPwd = file_getcwd(0,0);
3671
-
36723720
36733721
/* We should be done with options.. */
36743722
verify_all_options();
36753723
36763724
if( g.argc!=3 && g.argc!=4 ){
@@ -3766,14 +3814,11 @@
37663814
if( g.argc==4 ){
37673815
g.zOpenRevision = g.argv[3];
37683816
}else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
37693817
g.zOpenRevision = db_get("main-branch", 0);
37703818
}
3771
- if( !bNosync
3772
- && autosync_loop(SYNC_PULL, 1)
3773
- && !bForce
3774
- ){
3819
+ if( autosync_loop(SYNC_PULL, !bForce, "open") && !bForce ){
37753820
fossil_fatal("unable to auto-sync the repository");
37763821
}
37773822
}
37783823
37793824
@@ -3973,20 +4018,30 @@
39734018
** If enabled, automatically pull the shunning list
39744019
** from a server to which the client autosyncs.
39754020
*/
39764021
/*
39774022
** SETTING: autosync width=16 default=on
3978
-** This setting can be a boolean value (0, 1, on, off, true, false)
3979
-** or "pullonly" or "all".
4023
+** This setting determines when autosync occurs. The setting is a
4024
+** string that provides a lot of flexibility for determining when and
4025
+** when not to autosync. Examples:
4026
+**
4027
+** on Always autosync for command where autosync
4028
+** makes sense ("commit", "merge", "open", "update")
4029
+**
4030
+** off Never autosync.
4031
+**
4032
+** pullonly Only to pull autosyncs
4033
+**
4034
+** on,open=off Autosync for most commands, but not for "open"
4035
+**
4036
+** off,commit=pullonly Do not autosync, except do a pull before each
4037
+** "commit", presumably to avoid undesirable
4038
+** forks.
39804039
**
3981
-** If not false, automatically pull prior to commit
3982
-** or update and automatically push after commit or
3983
-** tag or branch creation. Except, if the value is
3984
-** "pullonly" then only pull operations occur automatically.
3985
-** Normally, only the default remote is used, but if the
3986
-** value is "all" then push/pull operations occur on all
3987
-** remotes.
4040
+** The syntax is a comma-separated list of VALUE and COMMAND=VALUE entries.
4041
+** A plain VALUE entry is the default that is used if no COMMAND matches.
4042
+** Otherwise, the VALUE of the matching command is used.
39884043
*/
39894044
/*
39904045
** SETTING: autosync-tries width=16 default=1
39914046
** If autosync is enabled setting this to a value greater
39924047
** than zero will cause autosync to try no more than this
@@ -4561,10 +4616,13 @@
45614616
*/
45624617
void setting_cmd(void){
45634618
int i;
45644619
int globalFlag = find_option("global","g",0)!=0;
45654620
int exactFlag = find_option("exact",0,0)!=0;
4621
+ /* Undocumented "--test-for-subsystem SUBSYS" option used to test
4622
+ ** the db_get_for_subsystem() interface: */
4623
+ const char *zSubsys = find_option("test-for-subsystem",0,1);
45664624
int unsetFlag = g.argv[1][0]=='u';
45674625
int nSetting;
45684626
const Setting *aSetting = setting_info(&nSetting);
45694627
find_repository_option();
45704628
verify_all_options();
@@ -4625,11 +4683,21 @@
46254683
if( exactFlag ){
46264684
if( fossil_strcmp(pSetting->name,zName)!=0 ) break;
46274685
}else{
46284686
if( fossil_strncmp(pSetting->name,zName,n)!=0 ) break;
46294687
}
4630
- print_setting(pSetting);
4688
+ if( zSubsys ){
4689
+ char *zValue = db_get_for_subsystem(pSetting->name, zSubsys);
4690
+ fossil_print("%s (subsystem %s) ->", pSetting->name, zSubsys);
4691
+ if( zValue ){
4692
+ fossil_print(" [%s]", zValue);
4693
+ fossil_free(zValue);
4694
+ }
4695
+ fossil_print("\n");
4696
+ }else{
4697
+ print_setting(pSetting);
4698
+ }
46314699
pSetting++;
46324700
}
46334701
}
46344702
}else{
46354703
usage("?PROPERTY? ?VALUE? ?-global?");
46364704
--- src/db.c
+++ src/db.c
@@ -3478,11 +3478,58 @@
3478 va_end(ap);
3479 db_unset(zName/*works-like:"x"*/, iGlobal);
3480 fossil_free(zName);
3481 }
3482
3483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3484
3485 #if INTERFACE
3486 /* Manifest generation flags */
3487 #define MFESTFLG_RAW 0x01
3488 #define MFESTFLG_UUID 0x02
@@ -3624,16 +3671,19 @@
3624 ** -f|--force Continue with the open even if the working directory is
3625 ** not empty.
3626 ** --force-missing Force opening a repository with missing content
3627 ** -k|--keep Only modify the manifest and manifest.uuid files
3628 ** --nested Allow opening a repository inside an opened checkout
3629 ** --nosync Do not auto-sync the repository prior to opening
 
3630 ** --repodir DIR If REPOSITORY is a URI that will be cloned, store
3631 ** the clone in DIR rather than in "."
3632 ** --setmtime Set timestamps of all files to match their SCM-side
3633 ** times (the timestamp of the last checkin which modified
3634 ** them).
 
 
3635 ** --verbose If passed a URI then this flag is passed on to the clone
3636 ** operation, otherwise it has no effect.
3637 ** --workdir DIR Use DIR as the working directory instead of ".". The DIR
3638 ** directory is created if it does not exist.
3639 **
@@ -3651,11 +3701,10 @@
3651 const char *zRepo = 0; /* Name of the repository file */
3652 const char *zRepoDir = 0; /* --repodir value */
3653 char *zPwd; /* Initial working directory */
3654 int isUri = 0; /* True if REPOSITORY is a URI */
3655 int nLocal; /* Number of preexisting files in cwd */
3656 int bNosync = 0; /* --nosync. Omit auto-sync */
3657 int bVerbose = 0; /* --verbose option for clone */
3658
3659 url_proxy_options();
3660 emptyFlag = find_option("empty",0,0)!=0;
3661 keepFlag = find_option("keep","k",0)!=0;
@@ -3662,15 +3711,14 @@
3662 forceMissingFlag = find_option("force-missing",0,0)!=0;
3663 allowNested = find_option("nested",0,0)!=0;
3664 setmtimeFlag = find_option("setmtime",0,0)!=0;
3665 zWorkDir = find_option("workdir",0,1);
3666 zRepoDir = find_option("repodir",0,1);
3667 bForce = find_option("force","f",0)!=0;
3668 bNosync = find_option("nosync",0,0)!=0;
3669 bVerbose = find_option("verbose",0,0)!=0;
3670 zPwd = file_getcwd(0,0);
3671
3672
3673 /* We should be done with options.. */
3674 verify_all_options();
3675
3676 if( g.argc!=3 && g.argc!=4 ){
@@ -3766,14 +3814,11 @@
3766 if( g.argc==4 ){
3767 g.zOpenRevision = g.argv[3];
3768 }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
3769 g.zOpenRevision = db_get("main-branch", 0);
3770 }
3771 if( !bNosync
3772 && autosync_loop(SYNC_PULL, 1)
3773 && !bForce
3774 ){
3775 fossil_fatal("unable to auto-sync the repository");
3776 }
3777 }
3778
3779
@@ -3973,20 +4018,30 @@
3973 ** If enabled, automatically pull the shunning list
3974 ** from a server to which the client autosyncs.
3975 */
3976 /*
3977 ** SETTING: autosync width=16 default=on
3978 ** This setting can be a boolean value (0, 1, on, off, true, false)
3979 ** or "pullonly" or "all".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3980 **
3981 ** If not false, automatically pull prior to commit
3982 ** or update and automatically push after commit or
3983 ** tag or branch creation. Except, if the value is
3984 ** "pullonly" then only pull operations occur automatically.
3985 ** Normally, only the default remote is used, but if the
3986 ** value is "all" then push/pull operations occur on all
3987 ** remotes.
3988 */
3989 /*
3990 ** SETTING: autosync-tries width=16 default=1
3991 ** If autosync is enabled setting this to a value greater
3992 ** than zero will cause autosync to try no more than this
@@ -4561,10 +4616,13 @@
4561 */
4562 void setting_cmd(void){
4563 int i;
4564 int globalFlag = find_option("global","g",0)!=0;
4565 int exactFlag = find_option("exact",0,0)!=0;
 
 
 
4566 int unsetFlag = g.argv[1][0]=='u';
4567 int nSetting;
4568 const Setting *aSetting = setting_info(&nSetting);
4569 find_repository_option();
4570 verify_all_options();
@@ -4625,11 +4683,21 @@
4625 if( exactFlag ){
4626 if( fossil_strcmp(pSetting->name,zName)!=0 ) break;
4627 }else{
4628 if( fossil_strncmp(pSetting->name,zName,n)!=0 ) break;
4629 }
4630 print_setting(pSetting);
 
 
 
 
 
 
 
 
 
 
4631 pSetting++;
4632 }
4633 }
4634 }else{
4635 usage("?PROPERTY? ?VALUE? ?-global?");
4636
--- src/db.c
+++ src/db.c
@@ -3478,11 +3478,58 @@
3478 va_end(ap);
3479 db_unset(zName/*works-like:"x"*/, iGlobal);
3480 fossil_free(zName);
3481 }
3482
3483 /*
3484 ** Get a setting that is taylored to subsystem. The return value is
3485 ** NULL if the setting does not exist, or a string obtained from mprintf()
3486 ** if the setting is available.
3487 **
3488 ** The actual setting can be a comma-separated list of value of the form:
3489 **
3490 ** * VALUE
3491 ** * SUBSYSTEM=VALUE
3492 **
3493 ** A VALUE without the SUBSYSTEM= prefix is the default. This routine
3494 ** returns the VALUE that with the matching SUBSYSTEM, or the default
3495 ** VALUE if there is no match.
3496 */
3497 char *db_get_for_subsystem(const char *zName, const char *zSubsys){
3498 int nSubsys;
3499 char *zToFree = 0;
3500 char *zCopy;
3501 char *zNext;
3502 char *zResult = 0;
3503 const char *zSetting = db_get(zName, 0);
3504 if( zSetting==0 ) return 0;
3505 zCopy = zToFree = fossil_strdup(zSetting);
3506 if( zSubsys==0 ) zSubsys = "";
3507 nSubsys = (int)strlen(zSubsys);
3508 while( zCopy ){
3509 zNext = strchr(zCopy, ',');
3510 if( zNext ){
3511 zNext[0] = 0;
3512 do{ zNext++; }while( fossil_isspace(zNext[0]) );
3513 if( zNext[0]==0 ) zNext = 0;
3514 }
3515 if( strchr(zCopy,'=')==0 ){
3516 if( zResult==0 ) zResult = zCopy;
3517 }else
3518 if( nSubsys
3519 && strncmp(zCopy, zSubsys, nSubsys)==0
3520 && zCopy[nSubsys]=='='
3521 ){
3522 zResult = &zCopy[nSubsys+1];
3523 break;
3524 }
3525 zCopy = zNext;
3526 }
3527 if( zResult ) zResult = fossil_strdup(zResult);
3528 fossil_free(zToFree);
3529 return zResult;
3530 }
3531
3532 #if INTERFACE
3533 /* Manifest generation flags */
3534 #define MFESTFLG_RAW 0x01
3535 #define MFESTFLG_UUID 0x02
@@ -3624,16 +3671,19 @@
3671 ** -f|--force Continue with the open even if the working directory is
3672 ** not empty.
3673 ** --force-missing Force opening a repository with missing content
3674 ** -k|--keep Only modify the manifest and manifest.uuid files
3675 ** --nested Allow opening a repository inside an opened checkout
3676 ** --nosync Do not auto-sync the repository prior to opening even
3677 ** if the autosync setting is on.
3678 ** --repodir DIR If REPOSITORY is a URI that will be cloned, store
3679 ** the clone in DIR rather than in "."
3680 ** --setmtime Set timestamps of all files to match their SCM-side
3681 ** times (the timestamp of the last checkin which modified
3682 ** them).
3683 ** --sync Auto-sync prior to opening even if the autosync setting
3684 ** is off.
3685 ** --verbose If passed a URI then this flag is passed on to the clone
3686 ** operation, otherwise it has no effect.
3687 ** --workdir DIR Use DIR as the working directory instead of ".". The DIR
3688 ** directory is created if it does not exist.
3689 **
@@ -3651,11 +3701,10 @@
3701 const char *zRepo = 0; /* Name of the repository file */
3702 const char *zRepoDir = 0; /* --repodir value */
3703 char *zPwd; /* Initial working directory */
3704 int isUri = 0; /* True if REPOSITORY is a URI */
3705 int nLocal; /* Number of preexisting files in cwd */
 
3706 int bVerbose = 0; /* --verbose option for clone */
3707
3708 url_proxy_options();
3709 emptyFlag = find_option("empty",0,0)!=0;
3710 keepFlag = find_option("keep","k",0)!=0;
@@ -3662,15 +3711,14 @@
3711 forceMissingFlag = find_option("force-missing",0,0)!=0;
3712 allowNested = find_option("nested",0,0)!=0;
3713 setmtimeFlag = find_option("setmtime",0,0)!=0;
3714 zWorkDir = find_option("workdir",0,1);
3715 zRepoDir = find_option("repodir",0,1);
3716 bForce = find_option("force","f",0)!=0;
3717 if( find_option("nosync",0,0) ) g.fNoSync = 1;
3718 bVerbose = find_option("verbose",0,0)!=0;
3719 zPwd = file_getcwd(0,0);
 
3720
3721 /* We should be done with options.. */
3722 verify_all_options();
3723
3724 if( g.argc!=3 && g.argc!=4 ){
@@ -3766,14 +3814,11 @@
3814 if( g.argc==4 ){
3815 g.zOpenRevision = g.argv[3];
3816 }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
3817 g.zOpenRevision = db_get("main-branch", 0);
3818 }
3819 if( autosync_loop(SYNC_PULL, !bForce, "open") && !bForce ){
 
 
 
3820 fossil_fatal("unable to auto-sync the repository");
3821 }
3822 }
3823
3824
@@ -3973,20 +4018,30 @@
4018 ** If enabled, automatically pull the shunning list
4019 ** from a server to which the client autosyncs.
4020 */
4021 /*
4022 ** SETTING: autosync width=16 default=on
4023 ** This setting determines when autosync occurs. The setting is a
4024 ** string that provides a lot of flexibility for determining when and
4025 ** when not to autosync. Examples:
4026 **
4027 ** on Always autosync for command where autosync
4028 ** makes sense ("commit", "merge", "open", "update")
4029 **
4030 ** off Never autosync.
4031 **
4032 ** pullonly Only to pull autosyncs
4033 **
4034 ** on,open=off Autosync for most commands, but not for "open"
4035 **
4036 ** off,commit=pullonly Do not autosync, except do a pull before each
4037 ** "commit", presumably to avoid undesirable
4038 ** forks.
4039 **
4040 ** The syntax is a comma-separated list of VALUE and COMMAND=VALUE entries.
4041 ** A plain VALUE entry is the default that is used if no COMMAND matches.
4042 ** Otherwise, the VALUE of the matching command is used.
 
 
 
 
4043 */
4044 /*
4045 ** SETTING: autosync-tries width=16 default=1
4046 ** If autosync is enabled setting this to a value greater
4047 ** than zero will cause autosync to try no more than this
@@ -4561,10 +4616,13 @@
4616 */
4617 void setting_cmd(void){
4618 int i;
4619 int globalFlag = find_option("global","g",0)!=0;
4620 int exactFlag = find_option("exact",0,0)!=0;
4621 /* Undocumented "--test-for-subsystem SUBSYS" option used to test
4622 ** the db_get_for_subsystem() interface: */
4623 const char *zSubsys = find_option("test-for-subsystem",0,1);
4624 int unsetFlag = g.argv[1][0]=='u';
4625 int nSetting;
4626 const Setting *aSetting = setting_info(&nSetting);
4627 find_repository_option();
4628 verify_all_options();
@@ -4625,11 +4683,21 @@
4683 if( exactFlag ){
4684 if( fossil_strcmp(pSetting->name,zName)!=0 ) break;
4685 }else{
4686 if( fossil_strncmp(pSetting->name,zName,n)!=0 ) break;
4687 }
4688 if( zSubsys ){
4689 char *zValue = db_get_for_subsystem(pSetting->name, zSubsys);
4690 fossil_print("%s (subsystem %s) ->", pSetting->name, zSubsys);
4691 if( zValue ){
4692 fossil_print(" [%s]", zValue);
4693 fossil_free(zValue);
4694 }
4695 fossil_print("\n");
4696 }else{
4697 print_setting(pSetting);
4698 }
4699 pSetting++;
4700 }
4701 }
4702 }else{
4703 usage("?PROPERTY? ?VALUE? ?-global?");
4704
--- src/json_branch.c
+++ src/json_branch.c
@@ -306,14 +306,10 @@
306306
}
307307
308308
/* Commit */
309309
db_end_transaction(0);
310310
311
-#if 0 /* Do an autosync push, if requested */
312
- /* arugable for JSON mode? */
313
- if( !g.isHTTP && !isPrivate ) autosync(SYNC_PUSH);
314
-#endif
315311
return 0;
316312
}
317313
318314
319315
/*
320316
--- src/json_branch.c
+++ src/json_branch.c
@@ -306,14 +306,10 @@
306 }
307
308 /* Commit */
309 db_end_transaction(0);
310
311 #if 0 /* Do an autosync push, if requested */
312 /* arugable for JSON mode? */
313 if( !g.isHTTP && !isPrivate ) autosync(SYNC_PUSH);
314 #endif
315 return 0;
316 }
317
318
319 /*
320
--- src/json_branch.c
+++ src/json_branch.c
@@ -306,14 +306,10 @@
306 }
307
308 /* Commit */
309 db_end_transaction(0);
310
 
 
 
 
311 return 0;
312 }
313
314
315 /*
316
+1 -1
--- src/merge.c
+++ src/merge.c
@@ -407,11 +407,11 @@
407407
}
408408
if( forceFlag==0 && leaf_is_closed(vid) ){
409409
fossil_fatal("cannot merge into a closed leaf. Use --force to override");
410410
}
411411
if( !dryRunFlag ){
412
- if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1) ){
412
+ if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1, "merge") ){
413413
fossil_fatal("merge abandoned due to sync failure");
414414
}
415415
}
416416
417417
/* Find mid, the artifactID of the version to be merged into the current
418418
--- src/merge.c
+++ src/merge.c
@@ -407,11 +407,11 @@
407 }
408 if( forceFlag==0 && leaf_is_closed(vid) ){
409 fossil_fatal("cannot merge into a closed leaf. Use --force to override");
410 }
411 if( !dryRunFlag ){
412 if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1) ){
413 fossil_fatal("merge abandoned due to sync failure");
414 }
415 }
416
417 /* Find mid, the artifactID of the version to be merged into the current
418
--- src/merge.c
+++ src/merge.c
@@ -407,11 +407,11 @@
407 }
408 if( forceFlag==0 && leaf_is_closed(vid) ){
409 fossil_fatal("cannot merge into a closed leaf. Use --force to override");
410 }
411 if( !dryRunFlag ){
412 if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1, "merge") ){
413 fossil_fatal("merge abandoned due to sync failure");
414 }
415 }
416
417 /* Find mid, the artifactID of the version to be merged into the current
418
+5 -4
--- src/sync.c
+++ src/sync.c
@@ -112,18 +112,18 @@
112112
** not acquired unless autosync is set to "on".
113113
**
114114
** If dont-push setting is true, that is the same as having autosync
115115
** set to pullonly.
116116
*/
117
-int autosync(int flags){
117
+static int autosync(int flags, const char *zSubsys){
118118
const char *zAutosync;
119119
int rc;
120120
int configSync = 0; /* configuration changes transferred */
121121
if( g.fNoSync ){
122122
return 0;
123123
}
124
- zAutosync = db_get("autosync", 0);
124
+ zAutosync = db_get_for_subsystem("autosync", zSubsys);
125125
if( zAutosync==0 ) zAutosync = "on"; /* defend against misconfig */
126126
if( is_false(zAutosync) ) return 0;
127127
if( db_get_boolean("dont-push",0)
128128
|| sqlite3_strglob("*pull*", zAutosync)==0
129129
){
@@ -157,20 +157,21 @@
157157
**
158158
** Return zero on success and non-zero on a failure. If failure occurs
159159
** and doPrompt flag is true, ask the user if they want to continue, and
160160
** if they answer "yes" then return zero in spite of the failure.
161161
*/
162
-int autosync_loop(int flags, int doPrompt){
162
+int autosync_loop(int flags, int doPrompt, const char *zSubsystem){
163163
int n = 0;
164164
int rc = 0;
165165
int nTries = db_get_int("autosync-tries", 1);
166166
if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
167167
&& db_get_boolean("uv-sync",0)
168168
){
169169
flags |= SYNC_UNVERSIONED;
170170
}
171
- while( (n==0 || n<nTries) && (rc=autosync(flags)) ){
171
+ if( nTries<1 ) nTries = 1;
172
+ while( (n==0 || n<nTries) && (rc=autosync(flags, zSubsystem)) ){
172173
if( rc ){
173174
if( ++n<nTries ){
174175
fossil_warning("Autosync failed, making another attempt.");
175176
sqlite3_sleep(500);
176177
}else{
177178
--- src/sync.c
+++ src/sync.c
@@ -112,18 +112,18 @@
112 ** not acquired unless autosync is set to "on".
113 **
114 ** If dont-push setting is true, that is the same as having autosync
115 ** set to pullonly.
116 */
117 int autosync(int flags){
118 const char *zAutosync;
119 int rc;
120 int configSync = 0; /* configuration changes transferred */
121 if( g.fNoSync ){
122 return 0;
123 }
124 zAutosync = db_get("autosync", 0);
125 if( zAutosync==0 ) zAutosync = "on"; /* defend against misconfig */
126 if( is_false(zAutosync) ) return 0;
127 if( db_get_boolean("dont-push",0)
128 || sqlite3_strglob("*pull*", zAutosync)==0
129 ){
@@ -157,20 +157,21 @@
157 **
158 ** Return zero on success and non-zero on a failure. If failure occurs
159 ** and doPrompt flag is true, ask the user if they want to continue, and
160 ** if they answer "yes" then return zero in spite of the failure.
161 */
162 int autosync_loop(int flags, int doPrompt){
163 int n = 0;
164 int rc = 0;
165 int nTries = db_get_int("autosync-tries", 1);
166 if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
167 && db_get_boolean("uv-sync",0)
168 ){
169 flags |= SYNC_UNVERSIONED;
170 }
171 while( (n==0 || n<nTries) && (rc=autosync(flags)) ){
 
172 if( rc ){
173 if( ++n<nTries ){
174 fossil_warning("Autosync failed, making another attempt.");
175 sqlite3_sleep(500);
176 }else{
177
--- src/sync.c
+++ src/sync.c
@@ -112,18 +112,18 @@
112 ** not acquired unless autosync is set to "on".
113 **
114 ** If dont-push setting is true, that is the same as having autosync
115 ** set to pullonly.
116 */
117 static int autosync(int flags, const char *zSubsys){
118 const char *zAutosync;
119 int rc;
120 int configSync = 0; /* configuration changes transferred */
121 if( g.fNoSync ){
122 return 0;
123 }
124 zAutosync = db_get_for_subsystem("autosync", zSubsys);
125 if( zAutosync==0 ) zAutosync = "on"; /* defend against misconfig */
126 if( is_false(zAutosync) ) return 0;
127 if( db_get_boolean("dont-push",0)
128 || sqlite3_strglob("*pull*", zAutosync)==0
129 ){
@@ -157,20 +157,21 @@
157 **
158 ** Return zero on success and non-zero on a failure. If failure occurs
159 ** and doPrompt flag is true, ask the user if they want to continue, and
160 ** if they answer "yes" then return zero in spite of the failure.
161 */
162 int autosync_loop(int flags, int doPrompt, const char *zSubsystem){
163 int n = 0;
164 int rc = 0;
165 int nTries = db_get_int("autosync-tries", 1);
166 if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
167 && db_get_boolean("uv-sync",0)
168 ){
169 flags |= SYNC_UNVERSIONED;
170 }
171 if( nTries<1 ) nTries = 1;
172 while( (n==0 || n<nTries) && (rc=autosync(flags, zSubsystem)) ){
173 if( rc ){
174 if( ++n<nTries ){
175 fossil_warning("Autosync failed, making another attempt.");
176 sqlite3_sleep(500);
177 }else{
178
+1 -1
--- src/update.c
+++ src/update.c
@@ -165,11 +165,11 @@
165165
166166
db_must_be_within_tree();
167167
vid = db_lget_int("checkout", 0);
168168
user_select();
169169
if( !dryRunFlag && !internalUpdate && !bNosync ){
170
- if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1) ){
170
+ if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1, "update") ){
171171
fossil_fatal("update abandoned due to sync failure");
172172
}
173173
}
174174
175175
/* Create any empty directories now, as well as after the update,
176176
--- src/update.c
+++ src/update.c
@@ -165,11 +165,11 @@
165
166 db_must_be_within_tree();
167 vid = db_lget_int("checkout", 0);
168 user_select();
169 if( !dryRunFlag && !internalUpdate && !bNosync ){
170 if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1) ){
171 fossil_fatal("update abandoned due to sync failure");
172 }
173 }
174
175 /* Create any empty directories now, as well as after the update,
176
--- src/update.c
+++ src/update.c
@@ -165,11 +165,11 @@
165
166 db_must_be_within_tree();
167 vid = db_lget_int("checkout", 0);
168 user_select();
169 if( !dryRunFlag && !internalUpdate && !bNosync ){
170 if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1, "update") ){
171 fossil_fatal("update abandoned due to sync failure");
172 }
173 }
174
175 /* Create any empty directories now, as well as after the update,
176

Keyboard Shortcuts

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