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.
Commit
7653ab63420e4ab4ca6372a53de9314a18e1b946
Parent
fbc335d39f0af8f…
3 files changed
+2
-2
+6
+3
-5
+2
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1556,11 +1556,11 @@ | ||
| 1556 | 1556 | |
| 1557 | 1557 | /* |
| 1558 | 1558 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1559 | 1559 | */ |
| 1560 | 1560 | if( !g.markPrivate ){ |
| 1561 | - if( autosync_loop(SYNC_PULL) ){ | |
| 1561 | + if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1)) ){ | |
| 1562 | 1562 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 1563 | 1563 | cReply = blob_str(&ans)[0]; |
| 1564 | 1564 | if( cReply!='y' && cReply!='Y' ){ |
| 1565 | 1565 | fossil_exit(1); |
| 1566 | 1566 | } |
| @@ -1941,11 +1941,11 @@ | ||
| 1941 | 1941 | exit(1); |
| 1942 | 1942 | } |
| 1943 | 1943 | db_end_transaction(0); |
| 1944 | 1944 | |
| 1945 | 1945 | if( !g.markPrivate ){ |
| 1946 | - autosync_loop(SYNC_PUSH|SYNC_PULL); | |
| 1946 | + autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1)); | |
| 1947 | 1947 | } |
| 1948 | 1948 | if( count_nonbranch_children(vid)>1 ){ |
| 1949 | 1949 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 1950 | 1950 | } |
| 1951 | 1951 | } |
| 1952 | 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) ){ |
| 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 |
M
src/db.c
+6
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2123,10 +2123,11 @@ | ||
| 2123 | 2123 | { "allow-symlinks", 0, 0, 1, 0, "off" }, |
| 2124 | 2124 | { "auto-captcha", "autocaptcha", 0, 0, 0, "on" }, |
| 2125 | 2125 | { "auto-hyperlink", 0, 0, 0, 0, "on", }, |
| 2126 | 2126 | { "auto-shun", 0, 0, 0, 0, "on" }, |
| 2127 | 2127 | { "autosync", 0, 0, 0, 0, "on" }, |
| 2128 | + { "autosync-tries", 0, 0, 0, 0, "" }, | |
| 2128 | 2129 | { "binary-glob", 0, 40, 1, 0, "" }, |
| 2129 | 2130 | { "clearsign", 0, 0, 0, 0, "off" }, |
| 2130 | 2131 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \ |
| 2131 | 2132 | defined(__APPLE__) |
| 2132 | 2133 | { "case-sensitive", 0, 0, 0, 0, "off" }, |
| @@ -2215,10 +2216,15 @@ | ||
| 2215 | 2216 | ** autosync If enabled, automatically pull prior to commit |
| 2216 | 2217 | ** or update and automatically push after commit or |
| 2217 | 2218 | ** tag or branch creation. If the value is "pullonly" |
| 2218 | 2219 | ** then only pull operations occur automatically. |
| 2219 | 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 | |
| 2220 | 2226 | ** |
| 2221 | 2227 | ** binary-glob The VALUE is a comma or newline-separated list of |
| 2222 | 2228 | ** (versionable) GLOB patterns that should be treated as binary files |
| 2223 | 2229 | ** for committing and merging purposes. Example: *.jpg |
| 2224 | 2230 | ** |
| 2225 | 2231 |
| --- 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 @@ | ||
| 19 | 19 | */ |
| 20 | 20 | #include "config.h" |
| 21 | 21 | #include "sync.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | |
| 24 | -#define AUTOSYNC_TRIES 3 | |
| 25 | - | |
| 26 | 24 | /* |
| 27 | 25 | ** If the repository is configured for autosyncing, then do an |
| 28 | 26 | ** autosync. This will be a pull if the argument is true or a push |
| 29 | 27 | ** if the argument is false. |
| 30 | 28 | ** |
| @@ -81,16 +79,16 @@ | ||
| 81 | 79 | |
| 82 | 80 | /* |
| 83 | 81 | ** This routine will try a number of times to perform autosync with a |
| 84 | 82 | ** .5 second sleep between attempts; returning the last autosync status. |
| 85 | 83 | */ |
| 86 | -int autosync_loop(int flags){ | |
| 84 | +int autosync_loop(int flags, int nTries){ | |
| 87 | 85 | int n = 0; |
| 88 | 86 | int rc = 0; |
| 89 | - while (n++ < AUTOSYNC_TRIES && (rc = autosync(flags))){ | |
| 87 | + while( (n==0 || n < nTries) && (rc = autosync(flags) )){ | |
| 90 | 88 | if( rc ) fossil_warning("Autosync failed%s", |
| 91 | - n < AUTOSYNC_TRIES ? ", making another attempt." : "."); | |
| 89 | + ++n < nTries ? ", making another attempt." : "."); | |
| 92 | 90 | sqlite3_sleep(500); |
| 93 | 91 | } |
| 94 | 92 | return rc; |
| 95 | 93 | } |
| 96 | 94 | |
| 97 | 95 |
| --- 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 |