Fossil SCM

Issue a gentle warning, rather than a scary error message, if the autopush following a commit fails due to insufficient permissions.

drh 2019-04-17 19:01 trunk
Commit 3350be2c0744c89ab90a789a9bf383305aad2fdaf80696e82d7096e11ede77b6
2 files changed +3 -1 +21 -3
+3 -1
--- src/checkin.c
+++ src/checkin.c
@@ -2613,11 +2613,13 @@
26132613
blob_reset(&tagslist);
26142614
free(zManifestFile);
26152615
}
26162616
26172617
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);
26192621
}
26202622
if( count_nonbranch_children(vid)>1 ){
26212623
fossil_print("**** warning: a fork has occurred *****\n");
26222624
}
26232625
}
26242626
--- 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 @@
16541654
#define SYNC_UNVERSIONED 0x0040 /* Sync unversioned content */
16551655
#define SYNC_UV_REVERT 0x0080 /* Copy server unversioned to client */
16561656
#define SYNC_FROMPARENT 0x0100 /* Pull from the parent project */
16571657
#define SYNC_UV_TRACE 0x0200 /* Describe UV activities */
16581658
#define SYNC_UV_DRYRUN 0x0400 /* Do not actually exchange files */
1659
+#define SYNC_IFABLE 0x0800 /* Inability to sync is not fatal */
16591660
#endif
16601661
16611662
/*
16621663
** Floating-point absolute value
16631664
*/
@@ -1706,10 +1707,11 @@
17061707
int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */
17071708
int uvDoPush = 0; /* Generate uvfile messages to send to server */
17081709
int nUvGimmeSent = 0; /* Number of uvgimme cards sent on this cycle */
17091710
int nUvFileRcvd = 0; /* Number of uvfile cards received on this cycle */
17101711
sqlite3_int64 mtime; /* Modification time on a UV file */
1712
+ int autopushFailed = 0; /* Autopush following commit failed if true */
17111713
17121714
if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
17131715
if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0
17141716
&& configRcvMask==0 && configSendMask==0 ) return 0;
17151717
if( syncFlags & SYNC_FROMPARENT ){
@@ -2281,15 +2283,22 @@
22812283
** first message exchange because the project-code is unknown
22822284
** and so the login card on the request was invalid. The project-code
22832285
** is returned in the reply before the error card, so second and
22842286
** subsequent messages should be OK. Nevertheless, we need to ignore
22852287
** 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.
22862291
*/
22872292
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 ){
22912300
fossil_force_newline();
22922301
fossil_print("Error: %s\n", zMsg);
22932302
blob_appendf(&xfer.err, "server says: %s\n", zMsg);
22942303
nErr++;
22952304
break;
@@ -2396,12 +2405,21 @@
23962405
if( nErr && go==2 ){
23972406
db_multi_exec("DROP TABLE onremote");
23982407
manifest_crosslink_end(MC_PERMIT_HOOKS);
23992408
content_enable_dephantomize(1);
24002409
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--;
24012419
}
24022420
if( (syncFlags & SYNC_CLONE)==0 && g.rcvid && fossil_any_has_fork(g.rcvid) ){
24032421
fossil_warning("***** WARNING: a fork has occurred *****\n"
24042422
"use \"fossil leaves -multiple\" for more details.");
24052423
}
24062424
return nErr;
24072425
}
24082426
--- 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

Keyboard Shortcuts

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