Index: src/manifest.c ================================================================== --- src/manifest.c +++ src/manifest.c @@ -1494,18 +1494,30 @@ #endif /* LOCAL_INTERFACE */ /* ** Finish up a sequence of manifest_crosslink calls. */ -void manifest_crosslink_end(void){ +int manifest_crosslink_end(int flags){ Stmt q, u; int i; + int rc = TH_OK; + int permitHooks = (flags & MC_PERMIT_HOOKS); + const char *zScript = 0; assert( manifest_crosslink_busy==1 ); + if( permitHooks ){ + rc = xfer_run_common_script(); + if( rc==TH_OK ){ + zScript = xfer_ticket_code(); + } + } db_prepare(&q, "SELECT uuid FROM pending_tkt"); while( db_step(&q)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q, 0); ticket_rebuild_entry(zUuid); + if( permitHooks && rc==TH_OK ){ + rc = xfer_run_script(zScript, zUuid); + } } db_finalize(&q); db_multi_exec("DROP TABLE pending_tkt"); /* If multiple check-ins happen close together in time, adjust their @@ -1536,10 +1548,11 @@ "DROP TABLE time_fudge;" ); db_end_transaction(0); manifest_crosslink_busy = 0; + return ( rc!=TH_ERROR ); } /* ** Make an entry in the event table for a ticket change artifact. */ @@ -1657,14 +1670,15 @@ ** Processing for other control artifacts was added later. The name ** of the routine, "manifest_crosslink", and the name of this source ** file, is a legacy of its original use. */ int manifest_crosslink(int rid, Blob *pContent, int flags){ - int i, result = TH_OK; + int i, rc = TH_OK; Manifest *p; Stmt q; int parentid = 0; + int permitHooks = (flags & MC_PERMIT_HOOKS); const char *zScript = 0; const char *zUuid = 0; if( (p = manifest_cache_find(rid))!=0 ){ blob_reset(pContent); @@ -1685,11 +1699,13 @@ fossil_error(1, "cannot fetch baseline manifest"); return 0; } db_begin_transaction(); if( p->type==CFTYPE_MANIFEST ){ - zScript = xfer_commit_code(); + if( permitHooks ){ + zScript = xfer_commit_code(); + } zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){ char *zCom; for(i=0; inParent; i++){ int pid = uuid_to_rid(p->azParent[i], 1); @@ -1883,12 +1899,10 @@ } } if( p->type==CFTYPE_TICKET ){ char *zTag; - zScript = xfer_ticket_code(); - zUuid = p->zTicketUuid; assert( manifest_crosslink_busy==1 ); zTag = mprintf("tkt-%s", p->zTicketUuid); tag_insert(zTag, 1, 0, rid, p->rDate, rid); free(zTag); db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)", @@ -1968,11 +1982,13 @@ zTagUuid); branchMove = 0; if( db_exists("SELECT 1 FROM event, blob" " WHERE event.type='ci' AND event.objid=blob.rid" " AND blob.uuid='%s'", zTagUuid) ){ - zScript = xfer_commit_code(); + if( permitHooks ){ + zScript = xfer_commit_code(); + } zUuid = zTagUuid; } } zName = p->aTag[i].zName; zValue = p->aTag[i].zValue; @@ -2042,23 +2058,23 @@ p->rDate, rid, p->zUser, blob_str(&comment)+1 ); blob_reset(&comment); } db_end_transaction(0); - if( zScript && (flags & MC_PERMIT_HOOKS) ){ - result = xfer_run_common_script(); - if( result==TH_OK ){ - result = xfer_run_script(zScript, zUuid); + if( permitHooks ){ + rc = xfer_run_common_script(); + if( rc==TH_OK ){ + rc = xfer_run_script(zScript, zUuid); } } if( p->type==CFTYPE_MANIFEST ){ manifest_cache_insert(p); }else{ manifest_destroy(p); } assert( blob_is_reset(pContent) ); - return ( result!=TH_ERROR ); + return ( rc!=TH_ERROR ); } /* ** COMMAND: test-crosslink ** Index: src/rebuild.c ================================================================== --- src/rebuild.c +++ src/rebuild.c @@ -412,11 +412,11 @@ db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); rebuild_step_done(rid); } } db_finalize(&s); - manifest_crosslink_end(); + manifest_crosslink_end(MC_NONE); rebuild_tag_trunk(); if( ttyOutput && !g.fQuiet && totalSize>0 ){ processCnt += incrSize; percent_complete((processCnt*1000)/totalSize); } Index: src/tkt.c ================================================================== --- src/tkt.c +++ src/tkt.c @@ -535,13 +535,17 @@ }else{ db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid); db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid); } manifest_crosslink_begin(); - result = (manifest_crosslink(rid, pTicket, MC_PERMIT_HOOKS)==0); + result = (manifest_crosslink(rid, pTicket, MC_NONE)==0); assert( blob_is_reset(pTicket) ); - manifest_crosslink_end(); + if( !result ){ + result = manifest_crosslink_end(MC_PERMIT_HOOKS); + }else{ + manifest_crosslink_end(MC_NONE); + } return result; } /* ** Subscript command: submit_ticket Index: src/xfer.c ================================================================== --- src/xfer.c +++ src/xfer.c @@ -852,25 +852,25 @@ /* ** Run the specified TH1 script, if any, and returns 1 on error. */ int xfer_run_script(const char *zScript, const char *zUuid){ - int result; + int rc; if( !zScript ) return TH_OK; Th_FossilInit(TH_INIT_DEFAULT); if( zUuid ){ - result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1); - if( result!=TH_OK ){ + rc = Th_SetVar(g.interp, "uuid", -1, zUuid, -1); + if( rc!=TH_OK ){ fossil_error(1, "%s", Th_GetResult(g.interp, 0)); - return result; + return rc; } } - result = Th_Eval(g.interp, 0, zScript, -1); - if( result!=TH_OK ){ + rc = Th_Eval(g.interp, 0, zScript, -1); + if( rc!=TH_OK ){ fossil_error(1, "%s", Th_GetResult(g.interp, 0)); } - return result; + return rc; } /* ** Runs the pre-transfer TH1 script, if any, and returns its return code. ** This script may be run multiple times. If the script performs actions @@ -914,11 +914,11 @@ int isClone = 0; int nGimme = 0; int size; int recvConfig = 0; char *zNow; - int result; + int rc; if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ fossil_redirect_home(); } g.zLogin = "anonymous"; @@ -944,12 +944,12 @@ db_begin_transaction(); db_multi_exec( "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" ); manifest_crosslink_begin(); - result = xfer_run_common_script(); - if( result==TH_ERROR ){ + rc = xfer_run_common_script(); + if( rc==TH_ERROR ){ cgi_reset_content(); @ error common\sscript\sfailed:\s%F(g.zErrMsg) nErr++; } while( blob_line(xfer.pIn, &xfer.line) ){ @@ -1272,13 +1272,13 @@ } blobarray_reset(xfer.aToken, xfer.nToken); blob_reset(&xfer.line); } if( isPush ){ - if( result==TH_OK ){ - result = xfer_run_script(xfer_push_code(), 0); - if( result==TH_ERROR ){ + if( rc==TH_OK ){ + rc = xfer_run_script(xfer_push_code(), 0); + if( rc==TH_ERROR ){ cgi_reset_content(); @ error push\sscript\sfailed:\s%F(g.zErrMsg) nErr++; } } @@ -1301,11 +1301,11 @@ } if( recvConfig ){ configure_finalize_receive(); } db_multi_exec("DROP TABLE onremote"); - manifest_crosslink_end(); + manifest_crosslink_end(MC_PERMIT_HOOKS); /* Send the server timestamp last, in case prior processing happened ** to use up a significant fraction of our time window. */ zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')"); @@ -1928,10 +1928,10 @@ "%s finished with %lld bytes sent, %lld bytes received\n", zOpType, nSent, nRcvd); transport_close(GLOBAL_URL()); transport_global_shutdown(GLOBAL_URL()); db_multi_exec("DROP TABLE onremote"); - manifest_crosslink_end(); + manifest_crosslink_end(MC_PERMIT_HOOKS); content_enable_dephantomize(1); db_end_transaction(0); return nErr; }