Fossil SCM

Introduce the autosync-tries setting to control how many attempts autosync will try if there is a failure. Defaults to 1 which is the current behavior. Disabling autosync is still managed with the autosync setting.

andybradford 2014-05-30 03:09 autosync-tries
Commit 7653ab63420e4ab4ca6372a53de9314a18e1b946
3 files changed +2 -2 +6 +3 -5
+2 -2
--- src/checkin.c
+++ src/checkin.c
@@ -1556,11 +1556,11 @@
15561556
15571557
/*
15581558
** Autosync if autosync is enabled and this is not a private check-in.
15591559
*/
15601560
if( !g.markPrivate ){
1561
- if( autosync_loop(SYNC_PULL) ){
1561
+ if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1)) ){
15621562
prompt_user("continue in spite of sync failure (y/N)? ", &ans);
15631563
cReply = blob_str(&ans)[0];
15641564
if( cReply!='y' && cReply!='Y' ){
15651565
fossil_exit(1);
15661566
}
@@ -1941,11 +1941,11 @@
19411941
exit(1);
19421942
}
19431943
db_end_transaction(0);
19441944
19451945
if( !g.markPrivate ){
1946
- autosync_loop(SYNC_PUSH|SYNC_PULL);
1946
+ autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1));
19471947
}
19481948
if( count_nonbranch_children(vid)>1 ){
19491949
fossil_print("**** warning: a fork has occurred *****\n");
19501950
}
19511951
}
19521952
--- src/checkin.c
+++ src/checkin.c
@@ -1556,11 +1556,11 @@
1556
1557 /*
1558 ** Autosync if autosync is enabled and this is not a private check-in.
1559 */
1560 if( !g.markPrivate ){
1561 if( autosync_loop(SYNC_PULL) ){
1562 prompt_user("continue in spite of sync failure (y/N)? ", &ans);
1563 cReply = blob_str(&ans)[0];
1564 if( cReply!='y' && cReply!='Y' ){
1565 fossil_exit(1);
1566 }
@@ -1941,11 +1941,11 @@
1941 exit(1);
1942 }
1943 db_end_transaction(0);
1944
1945 if( !g.markPrivate ){
1946 autosync_loop(SYNC_PUSH|SYNC_PULL);
1947 }
1948 if( count_nonbranch_children(vid)>1 ){
1949 fossil_print("**** warning: a fork has occurred *****\n");
1950 }
1951 }
1952
--- src/checkin.c
+++ src/checkin.c
@@ -1556,11 +1556,11 @@
1556
1557 /*
1558 ** Autosync if autosync is enabled and this is not a private check-in.
1559 */
1560 if( !g.markPrivate ){
1561 if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1)) ){
1562 prompt_user("continue in spite of sync failure (y/N)? ", &ans);
1563 cReply = blob_str(&ans)[0];
1564 if( cReply!='y' && cReply!='Y' ){
1565 fossil_exit(1);
1566 }
@@ -1941,11 +1941,11 @@
1941 exit(1);
1942 }
1943 db_end_transaction(0);
1944
1945 if( !g.markPrivate ){
1946 autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1));
1947 }
1948 if( count_nonbranch_children(vid)>1 ){
1949 fossil_print("**** warning: a fork has occurred *****\n");
1950 }
1951 }
1952
+6
--- src/db.c
+++ src/db.c
@@ -2123,10 +2123,11 @@
21232123
{ "allow-symlinks", 0, 0, 1, 0, "off" },
21242124
{ "auto-captcha", "autocaptcha", 0, 0, 0, "on" },
21252125
{ "auto-hyperlink", 0, 0, 0, 0, "on", },
21262126
{ "auto-shun", 0, 0, 0, 0, "on" },
21272127
{ "autosync", 0, 0, 0, 0, "on" },
2128
+ { "autosync-tries", 0, 0, 0, 0, "" },
21282129
{ "binary-glob", 0, 40, 1, 0, "" },
21292130
{ "clearsign", 0, 0, 0, 0, "off" },
21302131
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \
21312132
defined(__APPLE__)
21322133
{ "case-sensitive", 0, 0, 0, 0, "off" },
@@ -2215,10 +2216,15 @@
22152216
** autosync If enabled, automatically pull prior to commit
22162217
** or update and automatically push after commit or
22172218
** tag or branch creation. If the value is "pullonly"
22182219
** then only pull operations occur automatically.
22192220
** Default: on
2221
+**
2222
+** autosync-tries If autosync is enabled setting this to a value greater
2223
+** than zero will cause autosync to try no more than this
2224
+** number of attempts if there is a sync failure.
2225
+** Default: 1
22202226
**
22212227
** binary-glob The VALUE is a comma or newline-separated list of
22222228
** (versionable) GLOB patterns that should be treated as binary files
22232229
** for committing and merging purposes. Example: *.jpg
22242230
**
22252231
--- src/db.c
+++ src/db.c
@@ -2123,10 +2123,11 @@
2123 { "allow-symlinks", 0, 0, 1, 0, "off" },
2124 { "auto-captcha", "autocaptcha", 0, 0, 0, "on" },
2125 { "auto-hyperlink", 0, 0, 0, 0, "on", },
2126 { "auto-shun", 0, 0, 0, 0, "on" },
2127 { "autosync", 0, 0, 0, 0, "on" },
 
2128 { "binary-glob", 0, 40, 1, 0, "" },
2129 { "clearsign", 0, 0, 0, 0, "off" },
2130 #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \
2131 defined(__APPLE__)
2132 { "case-sensitive", 0, 0, 0, 0, "off" },
@@ -2215,10 +2216,15 @@
2215 ** autosync If enabled, automatically pull prior to commit
2216 ** or update and automatically push after commit or
2217 ** tag or branch creation. If the value is "pullonly"
2218 ** then only pull operations occur automatically.
2219 ** Default: on
 
 
 
 
 
2220 **
2221 ** binary-glob The VALUE is a comma or newline-separated list of
2222 ** (versionable) GLOB patterns that should be treated as binary files
2223 ** for committing and merging purposes. Example: *.jpg
2224 **
2225
--- src/db.c
+++ src/db.c
@@ -2123,10 +2123,11 @@
2123 { "allow-symlinks", 0, 0, 1, 0, "off" },
2124 { "auto-captcha", "autocaptcha", 0, 0, 0, "on" },
2125 { "auto-hyperlink", 0, 0, 0, 0, "on", },
2126 { "auto-shun", 0, 0, 0, 0, "on" },
2127 { "autosync", 0, 0, 0, 0, "on" },
2128 { "autosync-tries", 0, 0, 0, 0, "" },
2129 { "binary-glob", 0, 40, 1, 0, "" },
2130 { "clearsign", 0, 0, 0, 0, "off" },
2131 #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \
2132 defined(__APPLE__)
2133 { "case-sensitive", 0, 0, 0, 0, "off" },
@@ -2215,10 +2216,15 @@
2216 ** autosync If enabled, automatically pull prior to commit
2217 ** or update and automatically push after commit or
2218 ** tag or branch creation. If the value is "pullonly"
2219 ** then only pull operations occur automatically.
2220 ** Default: on
2221 **
2222 ** autosync-tries If autosync is enabled setting this to a value greater
2223 ** than zero will cause autosync to try no more than this
2224 ** number of attempts if there is a sync failure.
2225 ** Default: 1
2226 **
2227 ** binary-glob The VALUE is a comma or newline-separated list of
2228 ** (versionable) GLOB patterns that should be treated as binary files
2229 ** for committing and merging purposes. Example: *.jpg
2230 **
2231
+3 -5
--- src/sync.c
+++ src/sync.c
@@ -19,12 +19,10 @@
1919
*/
2020
#include "config.h"
2121
#include "sync.h"
2222
#include <assert.h>
2323
24
-#define AUTOSYNC_TRIES 3
25
-
2624
/*
2725
** If the repository is configured for autosyncing, then do an
2826
** autosync. This will be a pull if the argument is true or a push
2927
** if the argument is false.
3028
**
@@ -81,16 +79,16 @@
8179
8280
/*
8381
** This routine will try a number of times to perform autosync with a
8482
** .5 second sleep between attempts; returning the last autosync status.
8583
*/
86
-int autosync_loop(int flags){
84
+int autosync_loop(int flags, int nTries){
8785
int n = 0;
8886
int rc = 0;
89
- while (n++ < AUTOSYNC_TRIES && (rc = autosync(flags))){
87
+ while( (n==0 || n < nTries) && (rc = autosync(flags) )){
9088
if( rc ) fossil_warning("Autosync failed%s",
91
- n < AUTOSYNC_TRIES ? ", making another attempt." : ".");
89
+ ++n < nTries ? ", making another attempt." : ".");
9290
sqlite3_sleep(500);
9391
}
9492
return rc;
9593
}
9694
9795
--- src/sync.c
+++ src/sync.c
@@ -19,12 +19,10 @@
19 */
20 #include "config.h"
21 #include "sync.h"
22 #include <assert.h>
23
24 #define AUTOSYNC_TRIES 3
25
26 /*
27 ** If the repository is configured for autosyncing, then do an
28 ** autosync. This will be a pull if the argument is true or a push
29 ** if the argument is false.
30 **
@@ -81,16 +79,16 @@
81
82 /*
83 ** This routine will try a number of times to perform autosync with a
84 ** .5 second sleep between attempts; returning the last autosync status.
85 */
86 int autosync_loop(int flags){
87 int n = 0;
88 int rc = 0;
89 while (n++ < AUTOSYNC_TRIES && (rc = autosync(flags))){
90 if( rc ) fossil_warning("Autosync failed%s",
91 n < AUTOSYNC_TRIES ? ", making another attempt." : ".");
92 sqlite3_sleep(500);
93 }
94 return rc;
95 }
96
97
--- src/sync.c
+++ src/sync.c
@@ -19,12 +19,10 @@
19 */
20 #include "config.h"
21 #include "sync.h"
22 #include <assert.h>
23
 
 
24 /*
25 ** If the repository is configured for autosyncing, then do an
26 ** autosync. This will be a pull if the argument is true or a push
27 ** if the argument is false.
28 **
@@ -81,16 +79,16 @@
79
80 /*
81 ** This routine will try a number of times to perform autosync with a
82 ** .5 second sleep between attempts; returning the last autosync status.
83 */
84 int autosync_loop(int flags, int nTries){
85 int n = 0;
86 int rc = 0;
87 while( (n==0 || n < nTries) && (rc = autosync(flags) )){
88 if( rc ) fossil_warning("Autosync failed%s",
89 ++n < nTries ? ", making another attempt." : ".");
90 sqlite3_sleep(500);
91 }
92 return rc;
93 }
94
95

Keyboard Shortcuts

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