Fossil SCM
Implicitly set "fossil open --nosync" when the autosync setting is off, either globally or on the just-opened repo. This is on a branch because I don't know whether the dance involving global versus repo settings is overly complicated or *just complicated enough*. The current formulation seems both necessary and sufficient in my local testing here, but I'm hoping there's a shorter formulation that does the same thing.
Commit
9f42fc44c6719f099d8f422a384e99ff7202364e1a9dabab5ba41f1d3590e2bc
Parent
82510672b8f61c5…
1 file changed
+7
-1
M
src/db.c
+7
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -3624,11 +3624,12 @@ | ||
| 3624 | 3624 | ** -f|--force Continue with the open even if the working directory is |
| 3625 | 3625 | ** not empty. |
| 3626 | 3626 | ** --force-missing Force opening a repository with missing content |
| 3627 | 3627 | ** -k|--keep Only modify the manifest and manifest.uuid files |
| 3628 | 3628 | ** --nested Allow opening a repository inside an opened checkout |
| 3629 | -** --nosync Do not auto-sync the repository prior to opening | |
| 3629 | +** --nosync If autosync is on or set to pullonly, skip that step | |
| 3630 | +** prior to opening the repository | |
| 3630 | 3631 | ** --repodir DIR If REPOSITORY is a URI that will be cloned, store |
| 3631 | 3632 | ** the clone in DIR rather than in "." |
| 3632 | 3633 | ** --setmtime Set timestamps of all files to match their SCM-side |
| 3633 | 3634 | ** times (the timestamp of the last checkin which modified |
| 3634 | 3635 | ** them). |
| @@ -3653,10 +3654,11 @@ | ||
| 3653 | 3654 | char *zPwd; /* Initial working directory */ |
| 3654 | 3655 | int isUri = 0; /* True if REPOSITORY is a URI */ |
| 3655 | 3656 | int nLocal; /* Number of preexisting files in cwd */ |
| 3656 | 3657 | int bNosync = 0; /* --nosync. Omit auto-sync */ |
| 3657 | 3658 | int bVerbose = 0; /* --verbose option for clone */ |
| 3659 | + const char *zGAutosync; /* global (pre-open) autosync setting */ | |
| 3658 | 3660 | |
| 3659 | 3661 | url_proxy_options(); |
| 3660 | 3662 | emptyFlag = find_option("empty",0,0)!=0; |
| 3661 | 3663 | keepFlag = find_option("keep","k",0)!=0; |
| 3662 | 3664 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| @@ -3756,20 +3758,24 @@ | ||
| 3756 | 3758 | fossil_fatal("the --repodir option only makes sense if the REPOSITORY " |
| 3757 | 3759 | "argument is a URI that begins with http:, https:, ssh:, " |
| 3758 | 3760 | "or file:"); |
| 3759 | 3761 | } |
| 3760 | 3762 | |
| 3763 | + db_open_config(0, 0); | |
| 3764 | + zGAutosync = db_get("autosync", 0); | |
| 3761 | 3765 | db_open_repository(zRepo); |
| 3762 | 3766 | |
| 3763 | 3767 | /* Figure out which revision to open. */ |
| 3764 | 3768 | if( !emptyFlag ){ |
| 3769 | + const char *zAutosync = db_get("autosync", zGAutosync); | |
| 3765 | 3770 | if( g.argc==4 ){ |
| 3766 | 3771 | g.zOpenRevision = g.argv[3]; |
| 3767 | 3772 | }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){ |
| 3768 | 3773 | g.zOpenRevision = db_get("main-branch", 0); |
| 3769 | 3774 | } |
| 3770 | 3775 | if( !bNosync |
| 3776 | + && (!zAutosync || !is_false(zAutosync)) | |
| 3771 | 3777 | && autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1), 1) |
| 3772 | 3778 | && !bForce |
| 3773 | 3779 | ){ |
| 3774 | 3780 | fossil_fatal("unable to auto-sync the repository"); |
| 3775 | 3781 | } |
| 3776 | 3782 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -3624,11 +3624,12 @@ | |
| 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). |
| @@ -3653,10 +3654,11 @@ | |
| 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 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| @@ -3756,20 +3758,24 @@ | |
| 3756 | fossil_fatal("the --repodir option only makes sense if the REPOSITORY " |
| 3757 | "argument is a URI that begins with http:, https:, ssh:, " |
| 3758 | "or file:"); |
| 3759 | } |
| 3760 | |
| 3761 | db_open_repository(zRepo); |
| 3762 | |
| 3763 | /* Figure out which revision to open. */ |
| 3764 | if( !emptyFlag ){ |
| 3765 | if( g.argc==4 ){ |
| 3766 | g.zOpenRevision = g.argv[3]; |
| 3767 | }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){ |
| 3768 | g.zOpenRevision = db_get("main-branch", 0); |
| 3769 | } |
| 3770 | if( !bNosync |
| 3771 | && autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1), 1) |
| 3772 | && !bForce |
| 3773 | ){ |
| 3774 | fossil_fatal("unable to auto-sync the repository"); |
| 3775 | } |
| 3776 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -3624,11 +3624,12 @@ | |
| 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 If autosync is on or set to pullonly, skip that step |
| 3630 | ** prior to opening the repository |
| 3631 | ** --repodir DIR If REPOSITORY is a URI that will be cloned, store |
| 3632 | ** the clone in DIR rather than in "." |
| 3633 | ** --setmtime Set timestamps of all files to match their SCM-side |
| 3634 | ** times (the timestamp of the last checkin which modified |
| 3635 | ** them). |
| @@ -3653,10 +3654,11 @@ | |
| 3654 | char *zPwd; /* Initial working directory */ |
| 3655 | int isUri = 0; /* True if REPOSITORY is a URI */ |
| 3656 | int nLocal; /* Number of preexisting files in cwd */ |
| 3657 | int bNosync = 0; /* --nosync. Omit auto-sync */ |
| 3658 | int bVerbose = 0; /* --verbose option for clone */ |
| 3659 | const char *zGAutosync; /* global (pre-open) autosync setting */ |
| 3660 | |
| 3661 | url_proxy_options(); |
| 3662 | emptyFlag = find_option("empty",0,0)!=0; |
| 3663 | keepFlag = find_option("keep","k",0)!=0; |
| 3664 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| @@ -3756,20 +3758,24 @@ | |
| 3758 | fossil_fatal("the --repodir option only makes sense if the REPOSITORY " |
| 3759 | "argument is a URI that begins with http:, https:, ssh:, " |
| 3760 | "or file:"); |
| 3761 | } |
| 3762 | |
| 3763 | db_open_config(0, 0); |
| 3764 | zGAutosync = db_get("autosync", 0); |
| 3765 | db_open_repository(zRepo); |
| 3766 | |
| 3767 | /* Figure out which revision to open. */ |
| 3768 | if( !emptyFlag ){ |
| 3769 | const char *zAutosync = db_get("autosync", zGAutosync); |
| 3770 | if( g.argc==4 ){ |
| 3771 | g.zOpenRevision = g.argv[3]; |
| 3772 | }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){ |
| 3773 | g.zOpenRevision = db_get("main-branch", 0); |
| 3774 | } |
| 3775 | if( !bNosync |
| 3776 | && (!zAutosync || !is_false(zAutosync)) |
| 3777 | && autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1), 1) |
| 3778 | && !bForce |
| 3779 | ){ |
| 3780 | fossil_fatal("unable to auto-sync the repository"); |
| 3781 | } |
| 3782 |