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.

drh 2022-04-15 12:33 trunk
Commit 9445f8a8a2b5177bab3ed4ec2e75a24aaa5b3ec151772a0d77f3a87beb95a4dd
+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, db_get_int("autosync-tries",1),0);
226
+ if( !isPrivate ) autosync_loop(SYNC_PUSH, 0);
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, 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 @@
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, db_get_int("autosync-tries", 1), 1) ){
2351
+ if( autosync_loop(syncFlags, 1) ){
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, db_get_int("autosync-tries", 1), 1) ){
2557
+ if( autosync_loop(syncFlags, 1) ){
25582558
fossil_fatal("Auto-pull failed. Commit aborted.");
25592559
}
25602560
bRecheck = 1;
25612561
}
25622562
}else{
@@ -2865,14 +2865,13 @@
28652865
free(zManifestFile);
28662866
}
28672867
28682868
if( !g.markPrivate ){
28692869
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);
28722871
}
28732872
if( count_nonbranch_children(vid)>1 ){
28742873
fossil_print("**** warning: a fork has occurred *****\n");
28752874
}else{
28762875
leaf_ambiguity_warning(nvid,nvid);
28772876
}
28782877
}
28792878
--- 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
+1 -1
--- src/db.c
+++ src/db.c
@@ -3766,11 +3766,11 @@
37663766
g.zOpenRevision = g.argv[3];
37673767
}else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
37683768
g.zOpenRevision = db_get("main-branch", 0);
37693769
}
37703770
if( !bNosync
3771
- && autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1), 1)
3771
+ && autosync_loop(SYNC_PULL, 1)
37723772
&& !bForce
37733773
){
37743774
fossil_fatal("unable to auto-sync the repository");
37753775
}
37763776
}
37773777
--- 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 @@
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,
413
- db_get_int("autosync-tries", 1), 1) ){
412
+ if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1) ){
414413
fossil_fatal("merge abandoned due to sync failure");
415414
}
416415
}
417416
418417
/* Find mid, the artifactID of the version to be merged into the current
419418
--- 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 @@
150150
return rc;
151151
}
152152
153153
/*
154154
** 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.
156157
**
157158
** Return zero on success and non-zero on a failure. If failure occurs
158159
** and doPrompt flag is true, ask the user if they want to continue, and
159160
** if they answer "yes" then return zero in spite of the failure.
160161
*/
161
-int autosync_loop(int flags, int nTries, int doPrompt){
162
+int autosync_loop(int flags, int doPrompt){
162163
int n = 0;
163164
int rc = 0;
165
+ int nTries = db_get_int("autosync-tries", 1);
164166
if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
165167
&& db_get_boolean("uv-sync",0)
166168
){
167169
flags |= SYNC_UNVERSIONED;
168170
}
169171
--- 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 @@
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,
171
- db_get_int("autosync-tries", 1), 1) ){
170
+ if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, 1) ){
172171
fossil_fatal("update abandoned due to sync failure");
173172
}
174173
}
175174
176175
/* Create any empty directories now, as well as after the update,
177176
--- 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

Keyboard Shortcuts

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