Fossil SCM
Restore running of the common script before starting an xfer. If the commmon script result in a "break" or "continue", skip the following hook script but don't produce an error.
Commit
d79eaeb101ecbf5040423b3a8b1c8eeab4fd0a68
Parent
9964af59cea793e…
2 files changed
+5
-5
+11
-1
+5
-5
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -1657,11 +1657,11 @@ | ||
| 1657 | 1657 | ** Processing for other control artifacts was added later. The name |
| 1658 | 1658 | ** of the routine, "manifest_crosslink", and the name of this source |
| 1659 | 1659 | ** file, is a legacy of its original use. |
| 1660 | 1660 | */ |
| 1661 | 1661 | int manifest_crosslink(int rid, Blob *pContent, int flags){ |
| 1662 | - int i, result = 1; | |
| 1662 | + int i, result = TH_OK; | |
| 1663 | 1663 | Manifest *p; |
| 1664 | 1664 | Stmt q; |
| 1665 | 1665 | int parentid = 0; |
| 1666 | 1666 | const char *zScript = 0; |
| 1667 | 1667 | const char *zUuid = 0; |
| @@ -2037,22 +2037,22 @@ | ||
| 2037 | 2037 | ); |
| 2038 | 2038 | blob_reset(&comment); |
| 2039 | 2039 | } |
| 2040 | 2040 | db_end_transaction(0); |
| 2041 | 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | - result = (xfer_run_common_script()==TH_OK); | |
| 2043 | - if( result ){ | |
| 2044 | - result = (xfer_run_script(zScript, zUuid)==TH_OK); | |
| 2042 | + result = xfer_run_common_script(); | |
| 2043 | + if( result==TH_OK){ | |
| 2044 | + result = xfer_run_script(zScript, zUuid); | |
| 2045 | 2045 | } |
| 2046 | 2046 | } |
| 2047 | 2047 | if( p->type==CFTYPE_MANIFEST ){ |
| 2048 | 2048 | manifest_cache_insert(p); |
| 2049 | 2049 | }else{ |
| 2050 | 2050 | manifest_destroy(p); |
| 2051 | 2051 | } |
| 2052 | 2052 | assert( blob_is_reset(pContent) ); |
| 2053 | - return result; | |
| 2053 | + return (result!=TH_ERROR); | |
| 2054 | 2054 | } |
| 2055 | 2055 | |
| 2056 | 2056 | /* |
| 2057 | 2057 | ** COMMAND: test-crosslink |
| 2058 | 2058 | ** |
| 2059 | 2059 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1657,11 +1657,11 @@ | |
| 1657 | ** Processing for other control artifacts was added later. The name |
| 1658 | ** of the routine, "manifest_crosslink", and the name of this source |
| 1659 | ** file, is a legacy of its original use. |
| 1660 | */ |
| 1661 | int manifest_crosslink(int rid, Blob *pContent, int flags){ |
| 1662 | int i, result = 1; |
| 1663 | Manifest *p; |
| 1664 | Stmt q; |
| 1665 | int parentid = 0; |
| 1666 | const char *zScript = 0; |
| 1667 | const char *zUuid = 0; |
| @@ -2037,22 +2037,22 @@ | |
| 2037 | ); |
| 2038 | blob_reset(&comment); |
| 2039 | } |
| 2040 | db_end_transaction(0); |
| 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | result = (xfer_run_common_script()==TH_OK); |
| 2043 | if( result ){ |
| 2044 | result = (xfer_run_script(zScript, zUuid)==TH_OK); |
| 2045 | } |
| 2046 | } |
| 2047 | if( p->type==CFTYPE_MANIFEST ){ |
| 2048 | manifest_cache_insert(p); |
| 2049 | }else{ |
| 2050 | manifest_destroy(p); |
| 2051 | } |
| 2052 | assert( blob_is_reset(pContent) ); |
| 2053 | return result; |
| 2054 | } |
| 2055 | |
| 2056 | /* |
| 2057 | ** COMMAND: test-crosslink |
| 2058 | ** |
| 2059 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1657,11 +1657,11 @@ | |
| 1657 | ** Processing for other control artifacts was added later. The name |
| 1658 | ** of the routine, "manifest_crosslink", and the name of this source |
| 1659 | ** file, is a legacy of its original use. |
| 1660 | */ |
| 1661 | int manifest_crosslink(int rid, Blob *pContent, int flags){ |
| 1662 | int i, result = TH_OK; |
| 1663 | Manifest *p; |
| 1664 | Stmt q; |
| 1665 | int parentid = 0; |
| 1666 | const char *zScript = 0; |
| 1667 | const char *zUuid = 0; |
| @@ -2037,22 +2037,22 @@ | |
| 2037 | ); |
| 2038 | blob_reset(&comment); |
| 2039 | } |
| 2040 | db_end_transaction(0); |
| 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | result = xfer_run_common_script(); |
| 2043 | if( result==TH_OK){ |
| 2044 | result = xfer_run_script(zScript, zUuid); |
| 2045 | } |
| 2046 | } |
| 2047 | if( p->type==CFTYPE_MANIFEST ){ |
| 2048 | manifest_cache_insert(p); |
| 2049 | }else{ |
| 2050 | manifest_destroy(p); |
| 2051 | } |
| 2052 | assert( blob_is_reset(pContent) ); |
| 2053 | return (result!=TH_ERROR); |
| 2054 | } |
| 2055 | |
| 2056 | /* |
| 2057 | ** COMMAND: test-crosslink |
| 2058 | ** |
| 2059 |
+11
-1
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -915,10 +915,11 @@ | ||
| 915 | 915 | int isClone = 0; |
| 916 | 916 | int nGimme = 0; |
| 917 | 917 | int size; |
| 918 | 918 | int recvConfig = 0; |
| 919 | 919 | char *zNow; |
| 920 | + int result; | |
| 920 | 921 | |
| 921 | 922 | if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ |
| 922 | 923 | fossil_redirect_home(); |
| 923 | 924 | } |
| 924 | 925 | g.zLogin = "anonymous"; |
| @@ -944,10 +945,16 @@ | ||
| 944 | 945 | db_begin_transaction(); |
| 945 | 946 | db_multi_exec( |
| 946 | 947 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 947 | 948 | ); |
| 948 | 949 | manifest_crosslink_begin(); |
| 950 | + result = xfer_run_common_script(); | |
| 951 | + if( result==TH_ERROR ){ | |
| 952 | + cgi_reset_content(); | |
| 953 | + @ error common\sscript\sfailed:\s%F(g.zErrMsg) | |
| 954 | + nErr++; | |
| 955 | + } | |
| 949 | 956 | while( blob_line(xfer.pIn, &xfer.line) ){ |
| 950 | 957 | if( blob_buffer(&xfer.line)[0]=='#' ) continue; |
| 951 | 958 | if( blob_size(&xfer.line)==0 ) continue; |
| 952 | 959 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 953 | 960 | |
| @@ -1266,11 +1273,14 @@ | ||
| 1266 | 1273 | } |
| 1267 | 1274 | blobarray_reset(xfer.aToken, xfer.nToken); |
| 1268 | 1275 | blob_reset(&xfer.line); |
| 1269 | 1276 | } |
| 1270 | 1277 | if( isPush ){ |
| 1271 | - if( xfer_run_script(xfer_push_code(), 0)!=TH_OK ){ | |
| 1278 | + if (result!=TH_ERROR){ | |
| 1279 | + result = xfer_run_script(xfer_push_code(), 0); | |
| 1280 | + } | |
| 1281 | + if( result==TH_ERROR ){ | |
| 1272 | 1282 | cgi_reset_content(); |
| 1273 | 1283 | @ error push\sscript\sfailed:\s%F(g.zErrMsg) |
| 1274 | 1284 | nErr++; |
| 1275 | 1285 | } |
| 1276 | 1286 | request_phantoms(&xfer, 500); |
| 1277 | 1287 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -915,10 +915,11 @@ | |
| 915 | int isClone = 0; |
| 916 | int nGimme = 0; |
| 917 | int size; |
| 918 | int recvConfig = 0; |
| 919 | char *zNow; |
| 920 | |
| 921 | if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ |
| 922 | fossil_redirect_home(); |
| 923 | } |
| 924 | g.zLogin = "anonymous"; |
| @@ -944,10 +945,16 @@ | |
| 944 | db_begin_transaction(); |
| 945 | db_multi_exec( |
| 946 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 947 | ); |
| 948 | manifest_crosslink_begin(); |
| 949 | while( blob_line(xfer.pIn, &xfer.line) ){ |
| 950 | if( blob_buffer(&xfer.line)[0]=='#' ) continue; |
| 951 | if( blob_size(&xfer.line)==0 ) continue; |
| 952 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 953 | |
| @@ -1266,11 +1273,14 @@ | |
| 1266 | } |
| 1267 | blobarray_reset(xfer.aToken, xfer.nToken); |
| 1268 | blob_reset(&xfer.line); |
| 1269 | } |
| 1270 | if( isPush ){ |
| 1271 | if( xfer_run_script(xfer_push_code(), 0)!=TH_OK ){ |
| 1272 | cgi_reset_content(); |
| 1273 | @ error push\sscript\sfailed:\s%F(g.zErrMsg) |
| 1274 | nErr++; |
| 1275 | } |
| 1276 | request_phantoms(&xfer, 500); |
| 1277 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -915,10 +915,11 @@ | |
| 915 | int isClone = 0; |
| 916 | int nGimme = 0; |
| 917 | int size; |
| 918 | int recvConfig = 0; |
| 919 | char *zNow; |
| 920 | int result; |
| 921 | |
| 922 | if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ |
| 923 | fossil_redirect_home(); |
| 924 | } |
| 925 | g.zLogin = "anonymous"; |
| @@ -944,10 +945,16 @@ | |
| 945 | db_begin_transaction(); |
| 946 | db_multi_exec( |
| 947 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 948 | ); |
| 949 | manifest_crosslink_begin(); |
| 950 | result = xfer_run_common_script(); |
| 951 | if( result==TH_ERROR ){ |
| 952 | cgi_reset_content(); |
| 953 | @ error common\sscript\sfailed:\s%F(g.zErrMsg) |
| 954 | nErr++; |
| 955 | } |
| 956 | while( blob_line(xfer.pIn, &xfer.line) ){ |
| 957 | if( blob_buffer(&xfer.line)[0]=='#' ) continue; |
| 958 | if( blob_size(&xfer.line)==0 ) continue; |
| 959 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 960 | |
| @@ -1266,11 +1273,14 @@ | |
| 1273 | } |
| 1274 | blobarray_reset(xfer.aToken, xfer.nToken); |
| 1275 | blob_reset(&xfer.line); |
| 1276 | } |
| 1277 | if( isPush ){ |
| 1278 | if (result!=TH_ERROR){ |
| 1279 | result = xfer_run_script(xfer_push_code(), 0); |
| 1280 | } |
| 1281 | if( result==TH_ERROR ){ |
| 1282 | cgi_reset_content(); |
| 1283 | @ error push\sscript\sfailed:\s%F(g.zErrMsg) |
| 1284 | nErr++; |
| 1285 | } |
| 1286 | request_phantoms(&xfer, 500); |
| 1287 |