Fossil SCM
Add setting to control the number of autosync will be tried before returning an error. Default is historical behavior of one autosync in each direction.
Commit
76bc297e96211b50d7b7e518ba45663c80889f1f
Parent
a9819ba2671226a…
6 files changed
+1
-1
+2
-2
+6
+6
+15
-1
+2
-1
+1
-1
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -176,11 +176,11 @@ | ||
| 176 | 176 | |
| 177 | 177 | /* Commit */ |
| 178 | 178 | db_end_transaction(0); |
| 179 | 179 | |
| 180 | 180 | /* Do an autosync push, if requested */ |
| 181 | - if( !isPrivate ) autosync(SYNC_PUSH); | |
| 181 | + if( !isPrivate ) autosync_loop(SYNC_PUSH,db_get_int("autosync-tries", 1)); | |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /* |
| 185 | 185 | ** Prepare a query that will list branches. |
| 186 | 186 | ** |
| 187 | 187 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -176,11 +176,11 @@ | |
| 176 | |
| 177 | /* Commit */ |
| 178 | db_end_transaction(0); |
| 179 | |
| 180 | /* Do an autosync push, if requested */ |
| 181 | if( !isPrivate ) autosync(SYNC_PUSH); |
| 182 | } |
| 183 | |
| 184 | /* |
| 185 | ** Prepare a query that will list branches. |
| 186 | ** |
| 187 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -176,11 +176,11 @@ | |
| 176 | |
| 177 | /* Commit */ |
| 178 | db_end_transaction(0); |
| 179 | |
| 180 | /* Do an autosync push, if requested */ |
| 181 | if( !isPrivate ) autosync_loop(SYNC_PUSH,db_get_int("autosync-tries", 1)); |
| 182 | } |
| 183 | |
| 184 | /* |
| 185 | ** Prepare a query that will list branches. |
| 186 | ** |
| 187 |
+2
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1567,11 +1567,11 @@ | ||
| 1567 | 1567 | |
| 1568 | 1568 | /* |
| 1569 | 1569 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1570 | 1570 | */ |
| 1571 | 1571 | if( !g.markPrivate ){ |
| 1572 | - if( autosync(SYNC_PULL) ){ | |
| 1572 | + if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1)) ){ | |
| 1573 | 1573 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 1574 | 1574 | cReply = blob_str(&ans)[0]; |
| 1575 | 1575 | if( cReply!='y' && cReply!='Y' ){ |
| 1576 | 1576 | fossil_exit(1); |
| 1577 | 1577 | } |
| @@ -1952,11 +1952,11 @@ | ||
| 1952 | 1952 | exit(1); |
| 1953 | 1953 | } |
| 1954 | 1954 | db_end_transaction(0); |
| 1955 | 1955 | |
| 1956 | 1956 | if( !g.markPrivate ){ |
| 1957 | - autosync(SYNC_PUSH|SYNC_PULL); | |
| 1957 | + autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1)); | |
| 1958 | 1958 | } |
| 1959 | 1959 | if( count_nonbranch_children(vid)>1 ){ |
| 1960 | 1960 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 1961 | 1961 | } |
| 1962 | 1962 | } |
| 1963 | 1963 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1567,11 +1567,11 @@ | |
| 1567 | |
| 1568 | /* |
| 1569 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1570 | */ |
| 1571 | if( !g.markPrivate ){ |
| 1572 | if( autosync(SYNC_PULL) ){ |
| 1573 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 1574 | cReply = blob_str(&ans)[0]; |
| 1575 | if( cReply!='y' && cReply!='Y' ){ |
| 1576 | fossil_exit(1); |
| 1577 | } |
| @@ -1952,11 +1952,11 @@ | |
| 1952 | exit(1); |
| 1953 | } |
| 1954 | db_end_transaction(0); |
| 1955 | |
| 1956 | if( !g.markPrivate ){ |
| 1957 | autosync(SYNC_PUSH|SYNC_PULL); |
| 1958 | } |
| 1959 | if( count_nonbranch_children(vid)>1 ){ |
| 1960 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 1961 | } |
| 1962 | } |
| 1963 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1567,11 +1567,11 @@ | |
| 1567 | |
| 1568 | /* |
| 1569 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1570 | */ |
| 1571 | if( !g.markPrivate ){ |
| 1572 | if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1)) ){ |
| 1573 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 1574 | cReply = blob_str(&ans)[0]; |
| 1575 | if( cReply!='y' && cReply!='Y' ){ |
| 1576 | fossil_exit(1); |
| 1577 | } |
| @@ -1952,11 +1952,11 @@ | |
| 1952 | exit(1); |
| 1953 | } |
| 1954 | db_end_transaction(0); |
| 1955 | |
| 1956 | if( !g.markPrivate ){ |
| 1957 | autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1)); |
| 1958 | } |
| 1959 | if( count_nonbranch_children(vid)>1 ){ |
| 1960 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 1961 | } |
| 1962 | } |
| 1963 |
M
src/db.c
+6
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2129,10 +2129,11 @@ | ||
| 2129 | 2129 | { "allow-symlinks", 0, 0, 1, 0, "off" }, |
| 2130 | 2130 | { "auto-captcha", "autocaptcha", 0, 0, 0, "on" }, |
| 2131 | 2131 | { "auto-hyperlink", 0, 0, 0, 0, "on", }, |
| 2132 | 2132 | { "auto-shun", 0, 0, 0, 0, "on" }, |
| 2133 | 2133 | { "autosync", 0, 0, 0, 0, "on" }, |
| 2134 | + { "autosync-tries", 0, 0, 0, 0, "" }, | |
| 2134 | 2135 | { "binary-glob", 0, 40, 1, 0, "" }, |
| 2135 | 2136 | { "clearsign", 0, 0, 0, 0, "off" }, |
| 2136 | 2137 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \ |
| 2137 | 2138 | defined(__APPLE__) |
| 2138 | 2139 | { "case-sensitive", 0, 0, 0, 0, "off" }, |
| @@ -2221,10 +2222,15 @@ | ||
| 2221 | 2222 | ** autosync If enabled, automatically pull prior to commit |
| 2222 | 2223 | ** or update and automatically push after commit or |
| 2223 | 2224 | ** tag or branch creation. If the value is "pullonly" |
| 2224 | 2225 | ** then only pull operations occur automatically. |
| 2225 | 2226 | ** Default: on |
| 2227 | +** | |
| 2228 | +** autosync-tries If autosync is enabled setting this to a value greater | |
| 2229 | +** than zero will cause autosync to try no more than this | |
| 2230 | +** number of attempts if there is a sync failure. | |
| 2231 | +** Default: 1 | |
| 2226 | 2232 | ** |
| 2227 | 2233 | ** binary-glob The VALUE is a comma or newline-separated list of |
| 2228 | 2234 | ** (versionable) GLOB patterns that should be treated as binary files |
| 2229 | 2235 | ** for committing and merging purposes. Example: *.jpg |
| 2230 | 2236 | ** |
| 2231 | 2237 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2129,10 +2129,11 @@ | |
| 2129 | { "allow-symlinks", 0, 0, 1, 0, "off" }, |
| 2130 | { "auto-captcha", "autocaptcha", 0, 0, 0, "on" }, |
| 2131 | { "auto-hyperlink", 0, 0, 0, 0, "on", }, |
| 2132 | { "auto-shun", 0, 0, 0, 0, "on" }, |
| 2133 | { "autosync", 0, 0, 0, 0, "on" }, |
| 2134 | { "binary-glob", 0, 40, 1, 0, "" }, |
| 2135 | { "clearsign", 0, 0, 0, 0, "off" }, |
| 2136 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \ |
| 2137 | defined(__APPLE__) |
| 2138 | { "case-sensitive", 0, 0, 0, 0, "off" }, |
| @@ -2221,10 +2222,15 @@ | |
| 2221 | ** autosync If enabled, automatically pull prior to commit |
| 2222 | ** or update and automatically push after commit or |
| 2223 | ** tag or branch creation. If the value is "pullonly" |
| 2224 | ** then only pull operations occur automatically. |
| 2225 | ** Default: on |
| 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 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2129,10 +2129,11 @@ | |
| 2129 | { "allow-symlinks", 0, 0, 1, 0, "off" }, |
| 2130 | { "auto-captcha", "autocaptcha", 0, 0, 0, "on" }, |
| 2131 | { "auto-hyperlink", 0, 0, 0, 0, "on", }, |
| 2132 | { "auto-shun", 0, 0, 0, 0, "on" }, |
| 2133 | { "autosync", 0, 0, 0, 0, "on" }, |
| 2134 | { "autosync-tries", 0, 0, 0, 0, "" }, |
| 2135 | { "binary-glob", 0, 40, 1, 0, "" }, |
| 2136 | { "clearsign", 0, 0, 0, 0, "off" }, |
| 2137 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \ |
| 2138 | defined(__APPLE__) |
| 2139 | { "case-sensitive", 0, 0, 0, 0, "off" }, |
| @@ -2221,10 +2222,15 @@ | |
| 2222 | ** autosync If enabled, automatically pull prior to commit |
| 2223 | ** or update and automatically push after commit or |
| 2224 | ** tag or branch creation. If the value is "pullonly" |
| 2225 | ** then only pull operations occur automatically. |
| 2226 | ** Default: on |
| 2227 | ** |
| 2228 | ** autosync-tries If autosync is enabled setting this to a value greater |
| 2229 | ** than zero will cause autosync to try no more than this |
| 2230 | ** number of attempts if there is a sync failure. |
| 2231 | ** Default: 1 |
| 2232 | ** |
| 2233 | ** binary-glob The VALUE is a comma or newline-separated list of |
| 2234 | ** (versionable) GLOB patterns that should be treated as binary files |
| 2235 | ** for committing and merging purposes. Example: *.jpg |
| 2236 | ** |
| 2237 |
M
src/db.c
+6
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2129,10 +2129,11 @@ | ||
| 2129 | 2129 | { "allow-symlinks", 0, 0, 1, 0, "off" }, |
| 2130 | 2130 | { "auto-captcha", "autocaptcha", 0, 0, 0, "on" }, |
| 2131 | 2131 | { "auto-hyperlink", 0, 0, 0, 0, "on", }, |
| 2132 | 2132 | { "auto-shun", 0, 0, 0, 0, "on" }, |
| 2133 | 2133 | { "autosync", 0, 0, 0, 0, "on" }, |
| 2134 | + { "autosync-tries", 0, 0, 0, 0, "" }, | |
| 2134 | 2135 | { "binary-glob", 0, 40, 1, 0, "" }, |
| 2135 | 2136 | { "clearsign", 0, 0, 0, 0, "off" }, |
| 2136 | 2137 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \ |
| 2137 | 2138 | defined(__APPLE__) |
| 2138 | 2139 | { "case-sensitive", 0, 0, 0, 0, "off" }, |
| @@ -2221,10 +2222,15 @@ | ||
| 2221 | 2222 | ** autosync If enabled, automatically pull prior to commit |
| 2222 | 2223 | ** or update and automatically push after commit or |
| 2223 | 2224 | ** tag or branch creation. If the value is "pullonly" |
| 2224 | 2225 | ** then only pull operations occur automatically. |
| 2225 | 2226 | ** Default: on |
| 2227 | +** | |
| 2228 | +** autosync-tries If autosync is enabled setting this to a value greater | |
| 2229 | +** than zero will cause autosync to try no more than this | |
| 2230 | +** number of attempts if there is a sync failure. | |
| 2231 | +** Default: 1 | |
| 2226 | 2232 | ** |
| 2227 | 2233 | ** binary-glob The VALUE is a comma or newline-separated list of |
| 2228 | 2234 | ** (versionable) GLOB patterns that should be treated as binary files |
| 2229 | 2235 | ** for committing and merging purposes. Example: *.jpg |
| 2230 | 2236 | ** |
| 2231 | 2237 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2129,10 +2129,11 @@ | |
| 2129 | { "allow-symlinks", 0, 0, 1, 0, "off" }, |
| 2130 | { "auto-captcha", "autocaptcha", 0, 0, 0, "on" }, |
| 2131 | { "auto-hyperlink", 0, 0, 0, 0, "on", }, |
| 2132 | { "auto-shun", 0, 0, 0, 0, "on" }, |
| 2133 | { "autosync", 0, 0, 0, 0, "on" }, |
| 2134 | { "binary-glob", 0, 40, 1, 0, "" }, |
| 2135 | { "clearsign", 0, 0, 0, 0, "off" }, |
| 2136 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \ |
| 2137 | defined(__APPLE__) |
| 2138 | { "case-sensitive", 0, 0, 0, 0, "off" }, |
| @@ -2221,10 +2222,15 @@ | |
| 2221 | ** autosync If enabled, automatically pull prior to commit |
| 2222 | ** or update and automatically push after commit or |
| 2223 | ** tag or branch creation. If the value is "pullonly" |
| 2224 | ** then only pull operations occur automatically. |
| 2225 | ** Default: on |
| 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 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2129,10 +2129,11 @@ | |
| 2129 | { "allow-symlinks", 0, 0, 1, 0, "off" }, |
| 2130 | { "auto-captcha", "autocaptcha", 0, 0, 0, "on" }, |
| 2131 | { "auto-hyperlink", 0, 0, 0, 0, "on", }, |
| 2132 | { "auto-shun", 0, 0, 0, 0, "on" }, |
| 2133 | { "autosync", 0, 0, 0, 0, "on" }, |
| 2134 | { "autosync-tries", 0, 0, 0, 0, "" }, |
| 2135 | { "binary-glob", 0, 40, 1, 0, "" }, |
| 2136 | { "clearsign", 0, 0, 0, 0, "off" }, |
| 2137 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \ |
| 2138 | defined(__APPLE__) |
| 2139 | { "case-sensitive", 0, 0, 0, 0, "off" }, |
| @@ -2221,10 +2222,15 @@ | |
| 2222 | ** autosync If enabled, automatically pull prior to commit |
| 2223 | ** or update and automatically push after commit or |
| 2224 | ** tag or branch creation. If the value is "pullonly" |
| 2225 | ** then only pull operations occur automatically. |
| 2226 | ** Default: on |
| 2227 | ** |
| 2228 | ** autosync-tries If autosync is enabled setting this to a value greater |
| 2229 | ** than zero will cause autosync to try no more than this |
| 2230 | ** number of attempts if there is a sync failure. |
| 2231 | ** Default: 1 |
| 2232 | ** |
| 2233 | ** binary-glob The VALUE is a comma or newline-separated list of |
| 2234 | ** (versionable) GLOB patterns that should be treated as binary files |
| 2235 | ** for committing and merging purposes. Example: *.jpg |
| 2236 | ** |
| 2237 |
+15
-1
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -72,11 +72,25 @@ | ||
| 72 | 72 | #endif |
| 73 | 73 | if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE; |
| 74 | 74 | fossil_print("Autosync: %s\n", g.url.canonical); |
| 75 | 75 | url_enable_proxy("via proxy: "); |
| 76 | 76 | rc = client_sync(flags, configSync, 0); |
| 77 | - if( rc ) fossil_warning("Autosync failed"); | |
| 77 | + return rc; | |
| 78 | +} | |
| 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 | + } | |
| 78 | 92 | return rc; |
| 79 | 93 | } |
| 80 | 94 | |
| 81 | 95 | /* |
| 82 | 96 | ** This routine processes the command-line argument for push, pull, |
| 83 | 97 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -72,11 +72,25 @@ | |
| 72 | #endif |
| 73 | if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE; |
| 74 | fossil_print("Autosync: %s\n", g.url.canonical); |
| 75 | url_enable_proxy("via proxy: "); |
| 76 | rc = client_sync(flags, configSync, 0); |
| 77 | if( rc ) fossil_warning("Autosync failed"); |
| 78 | return rc; |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | ** This routine processes the command-line argument for push, pull, |
| 83 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -72,11 +72,25 @@ | |
| 72 | #endif |
| 73 | if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE; |
| 74 | fossil_print("Autosync: %s\n", g.url.canonical); |
| 75 | url_enable_proxy("via proxy: "); |
| 76 | rc = client_sync(flags, configSync, 0); |
| 77 | return rc; |
| 78 | } |
| 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 | /* |
| 96 | ** This routine processes the command-line argument for push, pull, |
| 97 |
+2
-1
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -130,11 +130,12 @@ | ||
| 130 | 130 | capture_case_sensitive_option(); |
| 131 | 131 | db_must_be_within_tree(); |
| 132 | 132 | vid = db_lget_int("checkout", 0); |
| 133 | 133 | user_select(); |
| 134 | 134 | if( !dryRunFlag && !internalUpdate ){ |
| 135 | - if( autosync(SYNC_PULL + SYNC_VERBOSE*verboseFlag) ){ | |
| 135 | + if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, | |
| 136 | + db_get_int("autosync-tries", 1)) ){ | |
| 136 | 137 | fossil_fatal("Cannot proceed with update"); |
| 137 | 138 | } |
| 138 | 139 | } |
| 139 | 140 | |
| 140 | 141 | /* Create any empty directories now, as well as after the update, |
| 141 | 142 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -130,11 +130,12 @@ | |
| 130 | capture_case_sensitive_option(); |
| 131 | db_must_be_within_tree(); |
| 132 | vid = db_lget_int("checkout", 0); |
| 133 | user_select(); |
| 134 | if( !dryRunFlag && !internalUpdate ){ |
| 135 | if( autosync(SYNC_PULL + SYNC_VERBOSE*verboseFlag) ){ |
| 136 | fossil_fatal("Cannot proceed with update"); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /* Create any empty directories now, as well as after the update, |
| 141 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -130,11 +130,12 @@ | |
| 130 | capture_case_sensitive_option(); |
| 131 | db_must_be_within_tree(); |
| 132 | vid = db_lget_int("checkout", 0); |
| 133 | user_select(); |
| 134 | if( !dryRunFlag && !internalUpdate ){ |
| 135 | if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, |
| 136 | db_get_int("autosync-tries", 1)) ){ |
| 137 | fossil_fatal("Cannot proceed with update"); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /* Create any empty directories now, as well as after the update, |
| 142 |