Fossil SCM
Simplify the autosync_loop() interface by omitting the second parameter, which was always the value of the "autosync-tries" setting. Have the autosync_loop() function look up the autosync-tries setting for itself.
Commit
9445f8a8a2b5177bab3ed4ec2e75a24aaa5b3ec151772a0d77f3a87beb95a4dd
Parent
82510672b8f61c5…
6 files changed
+1
-1
+3
-4
+1
-1
+1
-2
+4
-2
+1
-2
+1
-1
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -221,11 +221,11 @@ | ||
| 221 | 221 | |
| 222 | 222 | /* Commit */ |
| 223 | 223 | db_end_transaction(0); |
| 224 | 224 | |
| 225 | 225 | /* Do an autosync push, if requested */ |
| 226 | - if( !isPrivate ) autosync_loop(SYNC_PUSH, db_get_int("autosync-tries",1),0); | |
| 226 | + if( !isPrivate ) autosync_loop(SYNC_PUSH, 0); | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /* |
| 230 | 230 | ** Create a TEMP table named "tmp_brlist" with 7 columns: |
| 231 | 231 | ** |
| 232 | 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, db_get_int("autosync-tries",1),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); |
| 227 | } |
| 228 | |
| 229 | /* |
| 230 | ** Create a TEMP table named "tmp_brlist" with 7 columns: |
| 231 | ** |
| 232 |
+3
-4
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -2346,11 +2346,11 @@ | ||
| 2346 | 2346 | if( !g.markPrivate ){ |
| 2347 | 2347 | int syncFlags = SYNC_PULL; |
| 2348 | 2348 | if( vid!=0 && !allowFork && !forceFlag ){ |
| 2349 | 2349 | syncFlags |= SYNC_CKIN_LOCK; |
| 2350 | 2350 | } |
| 2351 | - if( autosync_loop(syncFlags, db_get_int("autosync-tries", 1), 1) ){ | |
| 2351 | + if( autosync_loop(syncFlags, 1) ){ | |
| 2352 | 2352 | fossil_exit(1); |
| 2353 | 2353 | } |
| 2354 | 2354 | } |
| 2355 | 2355 | |
| 2356 | 2356 | /* So that older versions of Fossil (that do not understand delta- |
| @@ -2552,11 +2552,11 @@ | ||
| 2552 | 2552 | if( !g.markPrivate && vid!=0 && !allowFork && !forceFlag ){ |
| 2553 | 2553 | /* Do another auto-pull, renewing the check-in lock. Then set |
| 2554 | 2554 | ** bRecheck so that we loop back above to verify that the check-in |
| 2555 | 2555 | ** is still not against a closed branch and still won't fork. */ |
| 2556 | 2556 | int syncFlags = SYNC_PULL|SYNC_CKIN_LOCK; |
| 2557 | - if( autosync_loop(syncFlags, db_get_int("autosync-tries", 1), 1) ){ | |
| 2557 | + if( autosync_loop(syncFlags, 1) ){ | |
| 2558 | 2558 | fossil_fatal("Auto-pull failed. Commit aborted."); |
| 2559 | 2559 | } |
| 2560 | 2560 | bRecheck = 1; |
| 2561 | 2561 | } |
| 2562 | 2562 | }else{ |
| @@ -2865,14 +2865,13 @@ | ||
| 2865 | 2865 | free(zManifestFile); |
| 2866 | 2866 | } |
| 2867 | 2867 | |
| 2868 | 2868 | if( !g.markPrivate ){ |
| 2869 | 2869 | int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE; |
| 2870 | - int nTries = db_get_int("autosync-tries",1); | |
| 2871 | - autosync_loop(syncFlags, nTries, 0); | |
| 2870 | + autosync_loop(syncFlags, 0); | |
| 2872 | 2871 | } |
| 2873 | 2872 | if( count_nonbranch_children(vid)>1 ){ |
| 2874 | 2873 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 2875 | 2874 | }else{ |
| 2876 | 2875 | leaf_ambiguity_warning(nvid,nvid); |
| 2877 | 2876 | } |
| 2878 | 2877 | } |
| 2879 | 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, db_get_int("autosync-tries", 1), 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, db_get_int("autosync-tries", 1), 1) ){ |
| 2558 | fossil_fatal("Auto-pull failed. Commit aborted."); |
| 2559 | } |
| 2560 | bRecheck = 1; |
| 2561 | } |
| 2562 | }else{ |
| @@ -2865,14 +2865,13 @@ | |
| 2865 | free(zManifestFile); |
| 2866 | } |
| 2867 | |
| 2868 | if( !g.markPrivate ){ |
| 2869 | int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE; |
| 2870 | int nTries = db_get_int("autosync-tries",1); |
| 2871 | autosync_loop(syncFlags, nTries, 0); |
| 2872 | } |
| 2873 | if( count_nonbranch_children(vid)>1 ){ |
| 2874 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 2875 | }else{ |
| 2876 | leaf_ambiguity_warning(nvid,nvid); |
| 2877 | } |
| 2878 | } |
| 2879 |
| --- 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,14 +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 |
M
src/db.c
+1
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -3766,11 +3766,11 @@ | ||
| 3766 | 3766 | g.zOpenRevision = g.argv[3]; |
| 3767 | 3767 | }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){ |
| 3768 | 3768 | g.zOpenRevision = db_get("main-branch", 0); |
| 3769 | 3769 | } |
| 3770 | 3770 | if( !bNosync |
| 3771 | - && autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1), 1) | |
| 3771 | + && autosync_loop(SYNC_PULL, 1) | |
| 3772 | 3772 | && !bForce |
| 3773 | 3773 | ){ |
| 3774 | 3774 | fossil_fatal("unable to auto-sync the repository"); |
| 3775 | 3775 | } |
| 3776 | 3776 | } |
| 3777 | 3777 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -3766,11 +3766,11 @@ | |
| 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 | } |
| 3777 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -3766,11 +3766,11 @@ | |
| 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, 1) |
| 3772 | && !bForce |
| 3773 | ){ |
| 3774 | fossil_fatal("unable to auto-sync the repository"); |
| 3775 | } |
| 3776 | } |
| 3777 |
+1
-2
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -407,12 +407,11 @@ | ||
| 407 | 407 | } |
| 408 | 408 | if( forceFlag==0 && leaf_is_closed(vid) ){ |
| 409 | 409 | fossil_fatal("cannot merge into a closed leaf. Use --force to override"); |
| 410 | 410 | } |
| 411 | 411 | if( !dryRunFlag ){ |
| 412 | - if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, | |
| 413 | - db_get_int("autosync-tries", 1), 1) ){ | |
| 412 | + if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1) ){ | |
| 414 | 413 | fossil_fatal("merge abandoned due to sync failure"); |
| 415 | 414 | } |
| 416 | 415 | } |
| 417 | 416 | |
| 418 | 417 | /* Find mid, the artifactID of the version to be merged into the current |
| 419 | 418 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -407,12 +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, |
| 413 | db_get_int("autosync-tries", 1), 1) ){ |
| 414 | fossil_fatal("merge abandoned due to sync failure"); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | /* Find mid, the artifactID of the version to be merged into the current |
| 419 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -407,12 +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 |
+4
-2
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -150,19 +150,21 @@ | ||
| 150 | 150 | return rc; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /* |
| 154 | 154 | ** This routine will try a number of times to perform autosync with a |
| 155 | -** 0.5 second sleep between attempts. | |
| 155 | +** 0.5 second sleep between attempts. The number of attempts is determined | |
| 156 | +** by the "autosync-tries" setting, which defaults to 1. | |
| 156 | 157 | ** |
| 157 | 158 | ** Return zero on success and non-zero on a failure. If failure occurs |
| 158 | 159 | ** and doPrompt flag is true, ask the user if they want to continue, and |
| 159 | 160 | ** if they answer "yes" then return zero in spite of the failure. |
| 160 | 161 | */ |
| 161 | -int autosync_loop(int flags, int nTries, int doPrompt){ | |
| 162 | +int autosync_loop(int flags, int doPrompt){ | |
| 162 | 163 | int n = 0; |
| 163 | 164 | int rc = 0; |
| 165 | + int nTries = db_get_int("autosync-tries", 1); | |
| 164 | 166 | if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) |
| 165 | 167 | && db_get_boolean("uv-sync",0) |
| 166 | 168 | ){ |
| 167 | 169 | flags |= SYNC_UNVERSIONED; |
| 168 | 170 | } |
| 169 | 171 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -150,19 +150,21 @@ | |
| 150 | return rc; |
| 151 | } |
| 152 | |
| 153 | /* |
| 154 | ** This routine will try a number of times to perform autosync with a |
| 155 | ** 0.5 second sleep between attempts. |
| 156 | ** |
| 157 | ** Return zero on success and non-zero on a failure. If failure occurs |
| 158 | ** and doPrompt flag is true, ask the user if they want to continue, and |
| 159 | ** if they answer "yes" then return zero in spite of the failure. |
| 160 | */ |
| 161 | int autosync_loop(int flags, int nTries, int doPrompt){ |
| 162 | int n = 0; |
| 163 | int rc = 0; |
| 164 | if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) |
| 165 | && db_get_boolean("uv-sync",0) |
| 166 | ){ |
| 167 | flags |= SYNC_UNVERSIONED; |
| 168 | } |
| 169 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -150,19 +150,21 @@ | |
| 150 | return rc; |
| 151 | } |
| 152 | |
| 153 | /* |
| 154 | ** This routine will try a number of times to perform autosync with a |
| 155 | ** 0.5 second sleep between attempts. The number of attempts is determined |
| 156 | ** by the "autosync-tries" setting, which defaults to 1. |
| 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 |
+1
-2
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -165,12 +165,11 @@ | ||
| 165 | 165 | |
| 166 | 166 | db_must_be_within_tree(); |
| 167 | 167 | vid = db_lget_int("checkout", 0); |
| 168 | 168 | user_select(); |
| 169 | 169 | if( !dryRunFlag && !internalUpdate && !bNosync ){ |
| 170 | - if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, | |
| 171 | - db_get_int("autosync-tries", 1), 1) ){ | |
| 170 | + if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1) ){ | |
| 172 | 171 | fossil_fatal("update abandoned due to sync failure"); |
| 173 | 172 | } |
| 174 | 173 | } |
| 175 | 174 | |
| 176 | 175 | /* Create any empty directories now, as well as after the update, |
| 177 | 176 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -165,12 +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, |
| 171 | db_get_int("autosync-tries", 1), 1) ){ |
| 172 | fossil_fatal("update abandoned due to sync failure"); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | /* Create any empty directories now, as well as after the update, |
| 177 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -165,12 +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 |