Fossil SCM
On a merge or update, prompt to continue of autosync fails, just like is done for commit.
Commit
d685096f99a977909bcb8931a55d5cba2e02819c
Parent
1e2d76ecb204347…
5 files changed
+1
-1
+3
-7
+2
-2
+14
-2
+2
-2
+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_loop(SYNC_PUSH, db_get_int("autosync-tries", 1)); | |
| 181 | + if( !isPrivate ) autosync_loop(SYNC_PUSH, db_get_int("autosync-tries",1),0); | |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | #if INTERFACE |
| 185 | 185 | /* |
| 186 | 186 | ** Allows bits in the mBplqFlags parameter to branch_prepare_list_query(). |
| 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_loop(SYNC_PUSH, db_get_int("autosync-tries", 1)); |
| 182 | } |
| 183 | |
| 184 | #if INTERFACE |
| 185 | /* |
| 186 | ** Allows bits in the mBplqFlags parameter to branch_prepare_list_query(). |
| 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),0); |
| 182 | } |
| 183 | |
| 184 | #if INTERFACE |
| 185 | /* |
| 186 | ** Allows bits in the mBplqFlags parameter to branch_prepare_list_query(). |
| 187 |
+3
-7
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1814,16 +1814,12 @@ | ||
| 1814 | 1814 | |
| 1815 | 1815 | /* |
| 1816 | 1816 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1817 | 1817 | */ |
| 1818 | 1818 | if( !g.markPrivate ){ |
| 1819 | - if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1)) ){ | |
| 1820 | - prompt_user("continue in spite of sync failure (y/N)? ", &ans); | |
| 1821 | - cReply = blob_str(&ans)[0]; | |
| 1822 | - if( cReply!='y' && cReply!='Y' ){ | |
| 1823 | - fossil_exit(1); | |
| 1824 | - } | |
| 1819 | + if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1), 1) ){ | |
| 1820 | + fossil_exit(1); | |
| 1825 | 1821 | } |
| 1826 | 1822 | } |
| 1827 | 1823 | |
| 1828 | 1824 | /* Require confirmation to continue with the check-in if there is |
| 1829 | 1825 | ** clock skew |
| @@ -2236,11 +2232,11 @@ | ||
| 2236 | 2232 | exit(1); |
| 2237 | 2233 | } |
| 2238 | 2234 | db_end_transaction(0); |
| 2239 | 2235 | |
| 2240 | 2236 | if( !g.markPrivate ){ |
| 2241 | - autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1)); | |
| 2237 | + autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1), 0); | |
| 2242 | 2238 | } |
| 2243 | 2239 | if( count_nonbranch_children(vid)>1 ){ |
| 2244 | 2240 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 2245 | 2241 | } |
| 2246 | 2242 | } |
| 2247 | 2243 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1814,16 +1814,12 @@ | |
| 1814 | |
| 1815 | /* |
| 1816 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1817 | */ |
| 1818 | if( !g.markPrivate ){ |
| 1819 | if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1)) ){ |
| 1820 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 1821 | cReply = blob_str(&ans)[0]; |
| 1822 | if( cReply!='y' && cReply!='Y' ){ |
| 1823 | fossil_exit(1); |
| 1824 | } |
| 1825 | } |
| 1826 | } |
| 1827 | |
| 1828 | /* Require confirmation to continue with the check-in if there is |
| 1829 | ** clock skew |
| @@ -2236,11 +2232,11 @@ | |
| 2236 | exit(1); |
| 2237 | } |
| 2238 | db_end_transaction(0); |
| 2239 | |
| 2240 | if( !g.markPrivate ){ |
| 2241 | autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1)); |
| 2242 | } |
| 2243 | if( count_nonbranch_children(vid)>1 ){ |
| 2244 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 2245 | } |
| 2246 | } |
| 2247 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1814,16 +1814,12 @@ | |
| 1814 | |
| 1815 | /* |
| 1816 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1817 | */ |
| 1818 | if( !g.markPrivate ){ |
| 1819 | if( autosync_loop(SYNC_PULL, db_get_int("autosync-tries", 1), 1) ){ |
| 1820 | fossil_exit(1); |
| 1821 | } |
| 1822 | } |
| 1823 | |
| 1824 | /* Require confirmation to continue with the check-in if there is |
| 1825 | ** clock skew |
| @@ -2236,11 +2232,11 @@ | |
| 2232 | exit(1); |
| 2233 | } |
| 2234 | db_end_transaction(0); |
| 2235 | |
| 2236 | if( !g.markPrivate ){ |
| 2237 | autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1), 0); |
| 2238 | } |
| 2239 | if( count_nonbranch_children(vid)>1 ){ |
| 2240 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 2241 | } |
| 2242 | } |
| 2243 |
+2
-2
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -265,12 +265,12 @@ | ||
| 265 | 265 | if( vid==0 ){ |
| 266 | 266 | fossil_fatal("nothing is checked out"); |
| 267 | 267 | } |
| 268 | 268 | if( !dryRunFlag ){ |
| 269 | 269 | if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, |
| 270 | - db_get_int("autosync-tries", 1)) ){ | |
| 271 | - fossil_fatal("Cannot proceed with merge"); | |
| 270 | + db_get_int("autosync-tries", 1), 1) ){ | |
| 271 | + fossil_fatal("merge abandoned due to sync failure"); | |
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /* Find mid, the artifactID of the version to be merged into the current |
| 276 | 276 | ** check-out */ |
| 277 | 277 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -265,12 +265,12 @@ | |
| 265 | if( vid==0 ){ |
| 266 | fossil_fatal("nothing is checked out"); |
| 267 | } |
| 268 | if( !dryRunFlag ){ |
| 269 | if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, |
| 270 | db_get_int("autosync-tries", 1)) ){ |
| 271 | fossil_fatal("Cannot proceed with merge"); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /* Find mid, the artifactID of the version to be merged into the current |
| 276 | ** check-out */ |
| 277 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -265,12 +265,12 @@ | |
| 265 | if( vid==0 ){ |
| 266 | fossil_fatal("nothing is checked out"); |
| 267 | } |
| 268 | if( !dryRunFlag ){ |
| 269 | if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, |
| 270 | db_get_int("autosync-tries", 1), 1) ){ |
| 271 | fossil_fatal("merge abandoned due to sync failure"); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /* Find mid, the artifactID of the version to be merged into the current |
| 276 | ** check-out */ |
| 277 |
+14
-2
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -77,13 +77,17 @@ | ||
| 77 | 77 | return rc; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /* |
| 81 | 81 | ** This routine will try a number of times to perform autosync with a |
| 82 | -** 0.5 second sleep between attempts; returning the last autosync status. | |
| 82 | +** 0.5 second sleep between attempts. | |
| 83 | +** | |
| 84 | +** Return zero on success and non-zero on a failure. If failure occurs | |
| 85 | +** and doPrompt flag is true, ask the user if they want to continue, and | |
| 86 | +** if they answer "yes" then return zero in spite of the failure. | |
| 83 | 87 | */ |
| 84 | -int autosync_loop(int flags, int nTries){ | |
| 88 | +int autosync_loop(int flags, int nTries, int doPrompt){ | |
| 85 | 89 | int n = 0; |
| 86 | 90 | int rc = 0; |
| 87 | 91 | while( (n==0 || n<nTries) && (rc=autosync(flags)) ){ |
| 88 | 92 | if( rc ){ |
| 89 | 93 | if( ++n<nTries ){ |
| @@ -91,10 +95,18 @@ | ||
| 91 | 95 | sqlite3_sleep(500); |
| 92 | 96 | }else{ |
| 93 | 97 | fossil_warning("Autosync failed."); |
| 94 | 98 | } |
| 95 | 99 | } |
| 100 | + } | |
| 101 | + if( rc && doPrompt ){ | |
| 102 | + Blob ans; | |
| 103 | + char cReply; | |
| 104 | + prompt_user("continue in spite of sync failure (y/N)? ", &ans); | |
| 105 | + cReply = blob_str(&ans)[0]; | |
| 106 | + if( cReply=='y' || cReply=='Y' ) rc = 0; | |
| 107 | + blob_reset(&ans); | |
| 96 | 108 | } |
| 97 | 109 | return rc; |
| 98 | 110 | } |
| 99 | 111 | |
| 100 | 112 | /* |
| 101 | 113 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -77,13 +77,17 @@ | |
| 77 | return rc; |
| 78 | } |
| 79 | |
| 80 | /* |
| 81 | ** This routine will try a number of times to perform autosync with a |
| 82 | ** 0.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 ){ |
| 89 | if( ++n<nTries ){ |
| @@ -91,10 +95,18 @@ | |
| 91 | sqlite3_sleep(500); |
| 92 | }else{ |
| 93 | fossil_warning("Autosync failed."); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | return rc; |
| 98 | } |
| 99 | |
| 100 | /* |
| 101 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -77,13 +77,17 @@ | |
| 77 | return rc; |
| 78 | } |
| 79 | |
| 80 | /* |
| 81 | ** This routine will try a number of times to perform autosync with a |
| 82 | ** 0.5 second sleep between attempts. |
| 83 | ** |
| 84 | ** Return zero on success and non-zero on a failure. If failure occurs |
| 85 | ** and doPrompt flag is true, ask the user if they want to continue, and |
| 86 | ** if they answer "yes" then return zero in spite of the failure. |
| 87 | */ |
| 88 | int autosync_loop(int flags, int nTries, int doPrompt){ |
| 89 | int n = 0; |
| 90 | int rc = 0; |
| 91 | while( (n==0 || n<nTries) && (rc=autosync(flags)) ){ |
| 92 | if( rc ){ |
| 93 | if( ++n<nTries ){ |
| @@ -91,10 +95,18 @@ | |
| 95 | sqlite3_sleep(500); |
| 96 | }else{ |
| 97 | fossil_warning("Autosync failed."); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | if( rc && doPrompt ){ |
| 102 | Blob ans; |
| 103 | char cReply; |
| 104 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 105 | cReply = blob_str(&ans)[0]; |
| 106 | if( cReply=='y' || cReply=='Y' ) rc = 0; |
| 107 | blob_reset(&ans); |
| 108 | } |
| 109 | return rc; |
| 110 | } |
| 111 | |
| 112 | /* |
| 113 |
+2
-2
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -153,12 +153,12 @@ | ||
| 153 | 153 | db_must_be_within_tree(); |
| 154 | 154 | vid = db_lget_int("checkout", 0); |
| 155 | 155 | user_select(); |
| 156 | 156 | if( !dryRunFlag && !internalUpdate ){ |
| 157 | 157 | if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, |
| 158 | - db_get_int("autosync-tries", 1)) ){ | |
| 159 | - fossil_fatal("Cannot proceed with update"); | |
| 158 | + db_get_int("autosync-tries", 1), 1) ){ | |
| 159 | + fossil_fatal("update abandoned due to sync failure"); | |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /* Create any empty directories now, as well as after the update, |
| 164 | 164 | ** so changes in settings are reflected now */ |
| 165 | 165 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -153,12 +153,12 @@ | |
| 153 | db_must_be_within_tree(); |
| 154 | vid = db_lget_int("checkout", 0); |
| 155 | user_select(); |
| 156 | if( !dryRunFlag && !internalUpdate ){ |
| 157 | if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, |
| 158 | db_get_int("autosync-tries", 1)) ){ |
| 159 | fossil_fatal("Cannot proceed with update"); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /* Create any empty directories now, as well as after the update, |
| 164 | ** so changes in settings are reflected now */ |
| 165 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -153,12 +153,12 @@ | |
| 153 | db_must_be_within_tree(); |
| 154 | vid = db_lget_int("checkout", 0); |
| 155 | user_select(); |
| 156 | if( !dryRunFlag && !internalUpdate ){ |
| 157 | if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag, |
| 158 | db_get_int("autosync-tries", 1), 1) ){ |
| 159 | fossil_fatal("update abandoned due to sync failure"); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /* Create any empty directories now, as well as after the update, |
| 164 | ** so changes in settings are reflected now */ |
| 165 |