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.

jan.nijtmans 2013-10-15 11:41 tkt-change-hook
Commit d79eaeb101ecbf5040423b3a8b1c8eeab4fd0a68
2 files changed +5 -5 +11 -1
+5 -5
--- src/manifest.c
+++ src/manifest.c
@@ -1657,11 +1657,11 @@
16571657
** Processing for other control artifacts was added later. The name
16581658
** of the routine, "manifest_crosslink", and the name of this source
16591659
** file, is a legacy of its original use.
16601660
*/
16611661
int manifest_crosslink(int rid, Blob *pContent, int flags){
1662
- int i, result = 1;
1662
+ int i, result = TH_OK;
16631663
Manifest *p;
16641664
Stmt q;
16651665
int parentid = 0;
16661666
const char *zScript = 0;
16671667
const char *zUuid = 0;
@@ -2037,22 +2037,22 @@
20372037
);
20382038
blob_reset(&comment);
20392039
}
20402040
db_end_transaction(0);
20412041
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);
20452045
}
20462046
}
20472047
if( p->type==CFTYPE_MANIFEST ){
20482048
manifest_cache_insert(p);
20492049
}else{
20502050
manifest_destroy(p);
20512051
}
20522052
assert( blob_is_reset(pContent) );
2053
- return result;
2053
+ return (result!=TH_ERROR);
20542054
}
20552055
20562056
/*
20572057
** COMMAND: test-crosslink
20582058
**
20592059
--- 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 @@
915915
int isClone = 0;
916916
int nGimme = 0;
917917
int size;
918918
int recvConfig = 0;
919919
char *zNow;
920
+ int result;
920921
921922
if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
922923
fossil_redirect_home();
923924
}
924925
g.zLogin = "anonymous";
@@ -944,10 +945,16 @@
944945
db_begin_transaction();
945946
db_multi_exec(
946947
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
947948
);
948949
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
+ }
949956
while( blob_line(xfer.pIn, &xfer.line) ){
950957
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
951958
if( blob_size(&xfer.line)==0 ) continue;
952959
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
953960
@@ -1266,11 +1273,14 @@
12661273
}
12671274
blobarray_reset(xfer.aToken, xfer.nToken);
12681275
blob_reset(&xfer.line);
12691276
}
12701277
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 ){
12721282
cgi_reset_content();
12731283
@ error push\sscript\sfailed:\s%F(g.zErrMsg)
12741284
nErr++;
12751285
}
12761286
request_phantoms(&xfer, 500);
12771287
--- 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

Keyboard Shortcuts

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