| | @@ -1494,18 +1494,30 @@ |
| 1494 | 1494 | #endif /* LOCAL_INTERFACE */ |
| 1495 | 1495 | |
| 1496 | 1496 | /* |
| 1497 | 1497 | ** Finish up a sequence of manifest_crosslink calls. |
| 1498 | 1498 | */ |
| 1499 | | -void manifest_crosslink_end(void){ |
| 1499 | +int manifest_crosslink_end(int flags){ |
| 1500 | 1500 | Stmt q, u; |
| 1501 | 1501 | int i; |
| 1502 | + int rc = TH_OK; |
| 1503 | + int permitHooks = (flags & MC_PERMIT_HOOKS); |
| 1504 | + const char *zScript = 0; |
| 1502 | 1505 | assert( manifest_crosslink_busy==1 ); |
| 1506 | + if( permitHooks ){ |
| 1507 | + rc = xfer_run_common_script(); |
| 1508 | + if( rc==TH_OK ){ |
| 1509 | + zScript = xfer_ticket_code(); |
| 1510 | + } |
| 1511 | + } |
| 1503 | 1512 | db_prepare(&q, "SELECT uuid FROM pending_tkt"); |
| 1504 | 1513 | while( db_step(&q)==SQLITE_ROW ){ |
| 1505 | 1514 | const char *zUuid = db_column_text(&q, 0); |
| 1506 | 1515 | ticket_rebuild_entry(zUuid); |
| 1516 | + if( permitHooks && rc==TH_OK ){ |
| 1517 | + rc = xfer_run_script(zScript, zUuid); |
| 1518 | + } |
| 1507 | 1519 | } |
| 1508 | 1520 | db_finalize(&q); |
| 1509 | 1521 | db_multi_exec("DROP TABLE pending_tkt"); |
| 1510 | 1522 | |
| 1511 | 1523 | /* If multiple check-ins happen close together in time, adjust their |
| | @@ -1536,10 +1548,11 @@ |
| 1536 | 1548 | "DROP TABLE time_fudge;" |
| 1537 | 1549 | ); |
| 1538 | 1550 | |
| 1539 | 1551 | db_end_transaction(0); |
| 1540 | 1552 | manifest_crosslink_busy = 0; |
| 1553 | + return ( rc!=TH_ERROR ); |
| 1541 | 1554 | } |
| 1542 | 1555 | |
| 1543 | 1556 | /* |
| 1544 | 1557 | ** Make an entry in the event table for a ticket change artifact. |
| 1545 | 1558 | */ |
| | @@ -1657,14 +1670,15 @@ |
| 1657 | 1670 | ** Processing for other control artifacts was added later. The name |
| 1658 | 1671 | ** of the routine, "manifest_crosslink", and the name of this source |
| 1659 | 1672 | ** file, is a legacy of its original use. |
| 1660 | 1673 | */ |
| 1661 | 1674 | int manifest_crosslink(int rid, Blob *pContent, int flags){ |
| 1662 | | - int i, result = TH_OK; |
| 1675 | + int i, rc = TH_OK; |
| 1663 | 1676 | Manifest *p; |
| 1664 | 1677 | Stmt q; |
| 1665 | 1678 | int parentid = 0; |
| 1679 | + int permitHooks = (flags & MC_PERMIT_HOOKS); |
| 1666 | 1680 | const char *zScript = 0; |
| 1667 | 1681 | const char *zUuid = 0; |
| 1668 | 1682 | |
| 1669 | 1683 | if( (p = manifest_cache_find(rid))!=0 ){ |
| 1670 | 1684 | blob_reset(pContent); |
| | @@ -1685,11 +1699,13 @@ |
| 1685 | 1699 | fossil_error(1, "cannot fetch baseline manifest"); |
| 1686 | 1700 | return 0; |
| 1687 | 1701 | } |
| 1688 | 1702 | db_begin_transaction(); |
| 1689 | 1703 | if( p->type==CFTYPE_MANIFEST ){ |
| 1690 | | - zScript = xfer_commit_code(); |
| 1704 | + if( permitHooks ){ |
| 1705 | + zScript = xfer_commit_code(); |
| 1706 | + } |
| 1691 | 1707 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1692 | 1708 | if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){ |
| 1693 | 1709 | char *zCom; |
| 1694 | 1710 | for(i=0; i<p->nParent; i++){ |
| 1695 | 1711 | int pid = uuid_to_rid(p->azParent[i], 1); |
| | @@ -1883,12 +1899,10 @@ |
| 1883 | 1899 | } |
| 1884 | 1900 | } |
| 1885 | 1901 | if( p->type==CFTYPE_TICKET ){ |
| 1886 | 1902 | char *zTag; |
| 1887 | 1903 | |
| 1888 | | - zScript = xfer_ticket_code(); |
| 1889 | | - zUuid = p->zTicketUuid; |
| 1890 | 1904 | assert( manifest_crosslink_busy==1 ); |
| 1891 | 1905 | zTag = mprintf("tkt-%s", p->zTicketUuid); |
| 1892 | 1906 | tag_insert(zTag, 1, 0, rid, p->rDate, rid); |
| 1893 | 1907 | free(zTag); |
| 1894 | 1908 | db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)", |
| | @@ -1968,11 +1982,13 @@ |
| 1968 | 1982 | zTagUuid); |
| 1969 | 1983 | branchMove = 0; |
| 1970 | 1984 | if( db_exists("SELECT 1 FROM event, blob" |
| 1971 | 1985 | " WHERE event.type='ci' AND event.objid=blob.rid" |
| 1972 | 1986 | " AND blob.uuid='%s'", zTagUuid) ){ |
| 1973 | | - zScript = xfer_commit_code(); |
| 1987 | + if( permitHooks ){ |
| 1988 | + zScript = xfer_commit_code(); |
| 1989 | + } |
| 1974 | 1990 | zUuid = zTagUuid; |
| 1975 | 1991 | } |
| 1976 | 1992 | } |
| 1977 | 1993 | zName = p->aTag[i].zName; |
| 1978 | 1994 | zValue = p->aTag[i].zValue; |
| | @@ -2042,23 +2058,23 @@ |
| 2042 | 2058 | p->rDate, rid, p->zUser, blob_str(&comment)+1 |
| 2043 | 2059 | ); |
| 2044 | 2060 | blob_reset(&comment); |
| 2045 | 2061 | } |
| 2046 | 2062 | db_end_transaction(0); |
| 2047 | | - if( zScript && (flags & MC_PERMIT_HOOKS) ){ |
| 2048 | | - result = xfer_run_common_script(); |
| 2049 | | - if( result==TH_OK ){ |
| 2050 | | - result = xfer_run_script(zScript, zUuid); |
| 2063 | + if( permitHooks ){ |
| 2064 | + rc = xfer_run_common_script(); |
| 2065 | + if( rc==TH_OK ){ |
| 2066 | + rc = xfer_run_script(zScript, zUuid); |
| 2051 | 2067 | } |
| 2052 | 2068 | } |
| 2053 | 2069 | if( p->type==CFTYPE_MANIFEST ){ |
| 2054 | 2070 | manifest_cache_insert(p); |
| 2055 | 2071 | }else{ |
| 2056 | 2072 | manifest_destroy(p); |
| 2057 | 2073 | } |
| 2058 | 2074 | assert( blob_is_reset(pContent) ); |
| 2059 | | - return ( result!=TH_ERROR ); |
| 2075 | + return ( rc!=TH_ERROR ); |
| 2060 | 2076 | } |
| 2061 | 2077 | |
| 2062 | 2078 | /* |
| 2063 | 2079 | ** COMMAND: test-crosslink |
| 2064 | 2080 | ** |
| 2065 | 2081 | |