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.

andybradford 2014-06-13 03:56 trunk merge
Commit 76bc297e96211b50d7b7e518ba45663c80889f1f
+1 -1
--- src/branch.c
+++ src/branch.c
@@ -176,11 +176,11 @@
176176
177177
/* Commit */
178178
db_end_transaction(0);
179179
180180
/* 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));
182182
}
183183
184184
/*
185185
** Prepare a query that will list branches.
186186
**
187187
--- 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 @@
15671567
15681568
/*
15691569
** Autosync if autosync is enabled and this is not a private check-in.
15701570
*/
15711571
if( !g.markPrivate ){
1572
- if( autosync(SYNC_PULL) ){
1572
+ if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1)) ){
15731573
prompt_user("continue in spite of sync failure (y/N)? ", &ans);
15741574
cReply = blob_str(&ans)[0];
15751575
if( cReply!='y' && cReply!='Y' ){
15761576
fossil_exit(1);
15771577
}
@@ -1952,11 +1952,11 @@
19521952
exit(1);
19531953
}
19541954
db_end_transaction(0);
19551955
19561956
if( !g.markPrivate ){
1957
- autosync(SYNC_PUSH|SYNC_PULL);
1957
+ autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1));
19581958
}
19591959
if( count_nonbranch_children(vid)>1 ){
19601960
fossil_print("**** warning: a fork has occurred *****\n");
19611961
}
19621962
}
19631963
--- 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
+6
--- src/db.c
+++ src/db.c
@@ -2129,10 +2129,11 @@
21292129
{ "allow-symlinks", 0, 0, 1, 0, "off" },
21302130
{ "auto-captcha", "autocaptcha", 0, 0, 0, "on" },
21312131
{ "auto-hyperlink", 0, 0, 0, 0, "on", },
21322132
{ "auto-shun", 0, 0, 0, 0, "on" },
21332133
{ "autosync", 0, 0, 0, 0, "on" },
2134
+ { "autosync-tries", 0, 0, 0, 0, "" },
21342135
{ "binary-glob", 0, 40, 1, 0, "" },
21352136
{ "clearsign", 0, 0, 0, 0, "off" },
21362137
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \
21372138
defined(__APPLE__)
21382139
{ "case-sensitive", 0, 0, 0, 0, "off" },
@@ -2221,10 +2222,15 @@
22212222
** autosync If enabled, automatically pull prior to commit
22222223
** or update and automatically push after commit or
22232224
** tag or branch creation. If the value is "pullonly"
22242225
** then only pull operations occur automatically.
22252226
** 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
22262232
**
22272233
** binary-glob The VALUE is a comma or newline-separated list of
22282234
** (versionable) GLOB patterns that should be treated as binary files
22292235
** for committing and merging purposes. Example: *.jpg
22302236
**
22312237
--- 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
+6
--- src/db.c
+++ src/db.c
@@ -2129,10 +2129,11 @@
21292129
{ "allow-symlinks", 0, 0, 1, 0, "off" },
21302130
{ "auto-captcha", "autocaptcha", 0, 0, 0, "on" },
21312131
{ "auto-hyperlink", 0, 0, 0, 0, "on", },
21322132
{ "auto-shun", 0, 0, 0, 0, "on" },
21332133
{ "autosync", 0, 0, 0, 0, "on" },
2134
+ { "autosync-tries", 0, 0, 0, 0, "" },
21342135
{ "binary-glob", 0, 40, 1, 0, "" },
21352136
{ "clearsign", 0, 0, 0, 0, "off" },
21362137
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__DARWIN__) || \
21372138
defined(__APPLE__)
21382139
{ "case-sensitive", 0, 0, 0, 0, "off" },
@@ -2221,10 +2222,15 @@
22212222
** autosync If enabled, automatically pull prior to commit
22222223
** or update and automatically push after commit or
22232224
** tag or branch creation. If the value is "pullonly"
22242225
** then only pull operations occur automatically.
22252226
** 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
22262232
**
22272233
** binary-glob The VALUE is a comma or newline-separated list of
22282234
** (versionable) GLOB patterns that should be treated as binary files
22292235
** for committing and merging purposes. Example: *.jpg
22302236
**
22312237
--- 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 @@
7272
#endif
7373
if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
7474
fossil_print("Autosync: %s\n", g.url.canonical);
7575
url_enable_proxy("via proxy: ");
7676
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
+ }
7892
return rc;
7993
}
8094
8195
/*
8296
** This routine processes the command-line argument for push, pull,
8397
--- 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 @@
130130
capture_case_sensitive_option();
131131
db_must_be_within_tree();
132132
vid = db_lget_int("checkout", 0);
133133
user_select();
134134
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)) ){
136137
fossil_fatal("Cannot proceed with update");
137138
}
138139
}
139140
140141
/* Create any empty directories now, as well as after the update,
141142
--- 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

Keyboard Shortcuts

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