Fossil SCM
Issue a gentle warning, rather than a scary error message, if the autopush following a commit fails due to insufficient permissions.
Commit
3350be2c0744c89ab90a789a9bf383305aad2fdaf80696e82d7096e11ede77b6
Parent
e0026b6e461331c…
2 files changed
+3
-1
+21
-3
+3
-1
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -2613,11 +2613,13 @@ | ||
| 2613 | 2613 | blob_reset(&tagslist); |
| 2614 | 2614 | free(zManifestFile); |
| 2615 | 2615 | } |
| 2616 | 2616 | |
| 2617 | 2617 | if( !g.markPrivate ){ |
| 2618 | - autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1), 0); | |
| 2618 | + int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE; | |
| 2619 | + int nTries = db_get_int("autosync-tries",1); | |
| 2620 | + autosync_loop(syncFlags, nTries, 0); | |
| 2619 | 2621 | } |
| 2620 | 2622 | if( count_nonbranch_children(vid)>1 ){ |
| 2621 | 2623 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 2622 | 2624 | } |
| 2623 | 2625 | } |
| 2624 | 2626 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -2613,11 +2613,13 @@ | |
| 2613 | blob_reset(&tagslist); |
| 2614 | free(zManifestFile); |
| 2615 | } |
| 2616 | |
| 2617 | if( !g.markPrivate ){ |
| 2618 | autosync_loop(SYNC_PUSH|SYNC_PULL, db_get_int("autosync-tries", 1), 0); |
| 2619 | } |
| 2620 | if( count_nonbranch_children(vid)>1 ){ |
| 2621 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 2622 | } |
| 2623 | } |
| 2624 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -2613,11 +2613,13 @@ | |
| 2613 | blob_reset(&tagslist); |
| 2614 | free(zManifestFile); |
| 2615 | } |
| 2616 | |
| 2617 | if( !g.markPrivate ){ |
| 2618 | int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE; |
| 2619 | int nTries = db_get_int("autosync-tries",1); |
| 2620 | autosync_loop(syncFlags, nTries, 0); |
| 2621 | } |
| 2622 | if( count_nonbranch_children(vid)>1 ){ |
| 2623 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 2624 | } |
| 2625 | } |
| 2626 |
+21
-3
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1654,10 +1654,11 @@ | ||
| 1654 | 1654 | #define SYNC_UNVERSIONED 0x0040 /* Sync unversioned content */ |
| 1655 | 1655 | #define SYNC_UV_REVERT 0x0080 /* Copy server unversioned to client */ |
| 1656 | 1656 | #define SYNC_FROMPARENT 0x0100 /* Pull from the parent project */ |
| 1657 | 1657 | #define SYNC_UV_TRACE 0x0200 /* Describe UV activities */ |
| 1658 | 1658 | #define SYNC_UV_DRYRUN 0x0400 /* Do not actually exchange files */ |
| 1659 | +#define SYNC_IFABLE 0x0800 /* Inability to sync is not fatal */ | |
| 1659 | 1660 | #endif |
| 1660 | 1661 | |
| 1661 | 1662 | /* |
| 1662 | 1663 | ** Floating-point absolute value |
| 1663 | 1664 | */ |
| @@ -1706,10 +1707,11 @@ | ||
| 1706 | 1707 | int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */ |
| 1707 | 1708 | int uvDoPush = 0; /* Generate uvfile messages to send to server */ |
| 1708 | 1709 | int nUvGimmeSent = 0; /* Number of uvgimme cards sent on this cycle */ |
| 1709 | 1710 | int nUvFileRcvd = 0; /* Number of uvfile cards received on this cycle */ |
| 1710 | 1711 | sqlite3_int64 mtime; /* Modification time on a UV file */ |
| 1712 | + int autopushFailed = 0; /* Autopush following commit failed if true */ | |
| 1711 | 1713 | |
| 1712 | 1714 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1713 | 1715 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0 |
| 1714 | 1716 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1715 | 1717 | if( syncFlags & SYNC_FROMPARENT ){ |
| @@ -2281,15 +2283,22 @@ | ||
| 2281 | 2283 | ** first message exchange because the project-code is unknown |
| 2282 | 2284 | ** and so the login card on the request was invalid. The project-code |
| 2283 | 2285 | ** is returned in the reply before the error card, so second and |
| 2284 | 2286 | ** subsequent messages should be OK. Nevertheless, we need to ignore |
| 2285 | 2287 | ** the error card on the first message of a clone. |
| 2288 | + ** | |
| 2289 | + ** Also ignore "not authorized to write" errors if this is an | |
| 2290 | + ** autopush following a commit. | |
| 2286 | 2291 | */ |
| 2287 | 2292 | if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){ |
| 2288 | - if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){ | |
| 2289 | - char *zMsg = blob_terminate(&xfer.aToken[1]); | |
| 2290 | - defossilize(zMsg); | |
| 2293 | + char *zMsg = blob_terminate(&xfer.aToken[1]); | |
| 2294 | + defossilize(zMsg); | |
| 2295 | + if( (syncFlags && SYNC_IFABLE)!=0 | |
| 2296 | + && sqlite3_strlike("%not authorized to write%",zMsg,0)==0 ){ | |
| 2297 | + autopushFailed = 1; | |
| 2298 | + nErr++; | |
| 2299 | + }else if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){ | |
| 2291 | 2300 | fossil_force_newline(); |
| 2292 | 2301 | fossil_print("Error: %s\n", zMsg); |
| 2293 | 2302 | blob_appendf(&xfer.err, "server says: %s\n", zMsg); |
| 2294 | 2303 | nErr++; |
| 2295 | 2304 | break; |
| @@ -2396,12 +2405,21 @@ | ||
| 2396 | 2405 | if( nErr && go==2 ){ |
| 2397 | 2406 | db_multi_exec("DROP TABLE onremote"); |
| 2398 | 2407 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2399 | 2408 | content_enable_dephantomize(1); |
| 2400 | 2409 | db_end_transaction(0); |
| 2410 | + } | |
| 2411 | + if( nErr && autopushFailed ){ | |
| 2412 | + fossil_warning( | |
| 2413 | + "Warning: The check-in was successful and is saved locally but you\n" | |
| 2414 | + " are not authorized to push the changes back to the server\n" | |
| 2415 | + " at %s", | |
| 2416 | + g.url.canonical | |
| 2417 | + ); | |
| 2418 | + nErr--; | |
| 2401 | 2419 | } |
| 2402 | 2420 | if( (syncFlags & SYNC_CLONE)==0 && g.rcvid && fossil_any_has_fork(g.rcvid) ){ |
| 2403 | 2421 | fossil_warning("***** WARNING: a fork has occurred *****\n" |
| 2404 | 2422 | "use \"fossil leaves -multiple\" for more details."); |
| 2405 | 2423 | } |
| 2406 | 2424 | return nErr; |
| 2407 | 2425 | } |
| 2408 | 2426 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1654,10 +1654,11 @@ | |
| 1654 | #define SYNC_UNVERSIONED 0x0040 /* Sync unversioned content */ |
| 1655 | #define SYNC_UV_REVERT 0x0080 /* Copy server unversioned to client */ |
| 1656 | #define SYNC_FROMPARENT 0x0100 /* Pull from the parent project */ |
| 1657 | #define SYNC_UV_TRACE 0x0200 /* Describe UV activities */ |
| 1658 | #define SYNC_UV_DRYRUN 0x0400 /* Do not actually exchange files */ |
| 1659 | #endif |
| 1660 | |
| 1661 | /* |
| 1662 | ** Floating-point absolute value |
| 1663 | */ |
| @@ -1706,10 +1707,11 @@ | |
| 1706 | int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */ |
| 1707 | int uvDoPush = 0; /* Generate uvfile messages to send to server */ |
| 1708 | int nUvGimmeSent = 0; /* Number of uvgimme cards sent on this cycle */ |
| 1709 | int nUvFileRcvd = 0; /* Number of uvfile cards received on this cycle */ |
| 1710 | sqlite3_int64 mtime; /* Modification time on a UV file */ |
| 1711 | |
| 1712 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1713 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0 |
| 1714 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1715 | if( syncFlags & SYNC_FROMPARENT ){ |
| @@ -2281,15 +2283,22 @@ | |
| 2281 | ** first message exchange because the project-code is unknown |
| 2282 | ** and so the login card on the request was invalid. The project-code |
| 2283 | ** is returned in the reply before the error card, so second and |
| 2284 | ** subsequent messages should be OK. Nevertheless, we need to ignore |
| 2285 | ** the error card on the first message of a clone. |
| 2286 | */ |
| 2287 | if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){ |
| 2288 | if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){ |
| 2289 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 2290 | defossilize(zMsg); |
| 2291 | fossil_force_newline(); |
| 2292 | fossil_print("Error: %s\n", zMsg); |
| 2293 | blob_appendf(&xfer.err, "server says: %s\n", zMsg); |
| 2294 | nErr++; |
| 2295 | break; |
| @@ -2396,12 +2405,21 @@ | |
| 2396 | if( nErr && go==2 ){ |
| 2397 | db_multi_exec("DROP TABLE onremote"); |
| 2398 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2399 | content_enable_dephantomize(1); |
| 2400 | db_end_transaction(0); |
| 2401 | } |
| 2402 | if( (syncFlags & SYNC_CLONE)==0 && g.rcvid && fossil_any_has_fork(g.rcvid) ){ |
| 2403 | fossil_warning("***** WARNING: a fork has occurred *****\n" |
| 2404 | "use \"fossil leaves -multiple\" for more details."); |
| 2405 | } |
| 2406 | return nErr; |
| 2407 | } |
| 2408 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1654,10 +1654,11 @@ | |
| 1654 | #define SYNC_UNVERSIONED 0x0040 /* Sync unversioned content */ |
| 1655 | #define SYNC_UV_REVERT 0x0080 /* Copy server unversioned to client */ |
| 1656 | #define SYNC_FROMPARENT 0x0100 /* Pull from the parent project */ |
| 1657 | #define SYNC_UV_TRACE 0x0200 /* Describe UV activities */ |
| 1658 | #define SYNC_UV_DRYRUN 0x0400 /* Do not actually exchange files */ |
| 1659 | #define SYNC_IFABLE 0x0800 /* Inability to sync is not fatal */ |
| 1660 | #endif |
| 1661 | |
| 1662 | /* |
| 1663 | ** Floating-point absolute value |
| 1664 | */ |
| @@ -1706,10 +1707,11 @@ | |
| 1707 | int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */ |
| 1708 | int uvDoPush = 0; /* Generate uvfile messages to send to server */ |
| 1709 | int nUvGimmeSent = 0; /* Number of uvgimme cards sent on this cycle */ |
| 1710 | int nUvFileRcvd = 0; /* Number of uvfile cards received on this cycle */ |
| 1711 | sqlite3_int64 mtime; /* Modification time on a UV file */ |
| 1712 | int autopushFailed = 0; /* Autopush following commit failed if true */ |
| 1713 | |
| 1714 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1715 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0 |
| 1716 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1717 | if( syncFlags & SYNC_FROMPARENT ){ |
| @@ -2281,15 +2283,22 @@ | |
| 2283 | ** first message exchange because the project-code is unknown |
| 2284 | ** and so the login card on the request was invalid. The project-code |
| 2285 | ** is returned in the reply before the error card, so second and |
| 2286 | ** subsequent messages should be OK. Nevertheless, we need to ignore |
| 2287 | ** the error card on the first message of a clone. |
| 2288 | ** |
| 2289 | ** Also ignore "not authorized to write" errors if this is an |
| 2290 | ** autopush following a commit. |
| 2291 | */ |
| 2292 | if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){ |
| 2293 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 2294 | defossilize(zMsg); |
| 2295 | if( (syncFlags && SYNC_IFABLE)!=0 |
| 2296 | && sqlite3_strlike("%not authorized to write%",zMsg,0)==0 ){ |
| 2297 | autopushFailed = 1; |
| 2298 | nErr++; |
| 2299 | }else if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){ |
| 2300 | fossil_force_newline(); |
| 2301 | fossil_print("Error: %s\n", zMsg); |
| 2302 | blob_appendf(&xfer.err, "server says: %s\n", zMsg); |
| 2303 | nErr++; |
| 2304 | break; |
| @@ -2396,12 +2405,21 @@ | |
| 2405 | if( nErr && go==2 ){ |
| 2406 | db_multi_exec("DROP TABLE onremote"); |
| 2407 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2408 | content_enable_dephantomize(1); |
| 2409 | db_end_transaction(0); |
| 2410 | } |
| 2411 | if( nErr && autopushFailed ){ |
| 2412 | fossil_warning( |
| 2413 | "Warning: The check-in was successful and is saved locally but you\n" |
| 2414 | " are not authorized to push the changes back to the server\n" |
| 2415 | " at %s", |
| 2416 | g.url.canonical |
| 2417 | ); |
| 2418 | nErr--; |
| 2419 | } |
| 2420 | if( (syncFlags & SYNC_CLONE)==0 && g.rcvid && fossil_any_has_fork(g.rcvid) ){ |
| 2421 | fossil_warning("***** WARNING: a fork has occurred *****\n" |
| 2422 | "use \"fossil leaves -multiple\" for more details."); |
| 2423 | } |
| 2424 | return nErr; |
| 2425 | } |
| 2426 |