@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support "Review Changes" and "Block Changes" settings for Owners package "Auto Review"

Summary:
Ref T10939. Fixes T8887. This enables and implements the "review" and "blocking review" options for packages.

This is a bit copy-pastey from `DifferentialReviewersHeraldAction`, which doesn't feel awesome. I think the right fix is Glorious Infrasturcture, though -- I filed T10967 to track that.

Test Plan:
- Set package autoreveiw to "Review".
- Updated, got a reveiwer.
- Set autoreview to "blocking".
- Updated, got a blocking reviewer.

{F1311720}

{F1311721}

{F1311722}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8887, T10939

Differential Revision: https://secure.phabricator.com/D15916

+101 -9
+87 -2
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 1536 1536 1537 1537 $xactions = array(); 1538 1538 if ($auto_subscribe) { 1539 - 1540 1539 $xactions[] = $object->getApplicationTransactionTemplate() 1541 1540 ->setAuthorPHID($owners_phid) 1542 1541 ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) ··· 1546 1545 )); 1547 1546 } 1548 1547 1549 - // TODO: Implement autoreview and autoblock, but these are more invovled. 1548 + $specs = array( 1549 + array($auto_review, false), 1550 + array($auto_block, true), 1551 + ); 1552 + 1553 + foreach ($specs as $spec) { 1554 + list($reviewers, $blocking) = $spec; 1555 + if (!$reviewers) { 1556 + continue; 1557 + } 1558 + 1559 + $phids = mpull($reviewers, 'getPHID'); 1560 + $xaction = $this->newAutoReviewTransaction($object, $phids, $blocking); 1561 + if ($xaction) { 1562 + $xactions[] = $xaction; 1563 + } 1564 + } 1550 1565 1551 1566 return $xactions; 1567 + } 1568 + 1569 + private function newAutoReviewTransaction( 1570 + PhabricatorLiskDAO $object, 1571 + array $phids, 1572 + $is_blocking) { 1573 + 1574 + // TODO: This is substantially similar to DifferentialReviewersHeraldAction 1575 + // and both are needlessly complex. This logic should live in the normal 1576 + // transaction application pipeline. See T10967. 1577 + 1578 + $reviewers = $object->getReviewerStatus(); 1579 + $reviewers = mpull($reviewers, null, 'getReviewerPHID'); 1580 + 1581 + if ($is_blocking) { 1582 + $new_status = DifferentialReviewerStatus::STATUS_BLOCKING; 1583 + } else { 1584 + $new_status = DifferentialReviewerStatus::STATUS_ADDED; 1585 + } 1586 + 1587 + $new_strength = DifferentialReviewerStatus::getStatusStrength( 1588 + $new_status); 1589 + 1590 + $current = array(); 1591 + foreach ($phids as $phid) { 1592 + if (!isset($reviewers[$phid])) { 1593 + continue; 1594 + } 1595 + 1596 + // If we're applying a stronger status (usually, upgrading a reviewer 1597 + // into a blocking reviewer), skip this check so we apply the change. 1598 + $old_strength = DifferentialReviewerStatus::getStatusStrength( 1599 + $reviewers[$phid]->getStatus()); 1600 + if ($old_strength <= $new_strength) { 1601 + continue; 1602 + } 1603 + 1604 + $current[] = $phid; 1605 + } 1606 + 1607 + $phids = array_diff($phids, $current); 1608 + 1609 + if (!$phids) { 1610 + return null; 1611 + } 1612 + 1613 + $phids = array_fuse($phids); 1614 + 1615 + $value = array(); 1616 + foreach ($phids as $phid) { 1617 + $value[$phid] = array( 1618 + 'data' => array( 1619 + 'status' => $new_status, 1620 + ), 1621 + ); 1622 + } 1623 + 1624 + $edgetype_reviewer = DifferentialRevisionHasReviewerEdgeType::EDGECONST; 1625 + 1626 + $owners_phid = id(new PhabricatorOwnersApplication()) 1627 + ->getPHID(); 1628 + 1629 + return $object->getApplicationTransactionTemplate() 1630 + ->setAuthorPHID($owners_phid) 1631 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 1632 + ->setMetadataValue('edge:type', $edgetype_reviewer) 1633 + ->setNewValue( 1634 + array( 1635 + '+' => $value, 1636 + )); 1552 1637 } 1553 1638 1554 1639 protected function buildHeraldAdapter(
+6 -7
src/applications/owners/storage/PhabricatorOwnersPackage.php
··· 71 71 self::AUTOREVIEW_SUBSCRIBE => array( 72 72 'name' => pht('Subscribe to Changes'), 73 73 ), 74 - // TODO: Implement these. 75 - // self::AUTOREVIEW_REVIEW => array( 76 - // 'name' => pht('Review Changes'), 77 - // ), 78 - // self::AUTOREVIEW_BLOCK => array( 79 - // 'name' => pht('Review Changes (Blocking)'), 80 - // ), 74 + self::AUTOREVIEW_REVIEW => array( 75 + 'name' => pht('Review Changes'), 76 + ), 77 + self::AUTOREVIEW_BLOCK => array( 78 + 'name' => pht('Review Changes (Blocking)'), 79 + ), 81 80 ); 82 81 } 83 82
+8
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 1577 1577 $type = $xaction->getTransactionType(); 1578 1578 if (isset($types[$type])) { 1579 1579 foreach ($types[$type] as $other_key) { 1580 + $other_xaction = $result[$other_key]; 1581 + 1582 + // Don't merge transactions with different authors. For example, 1583 + // don't merge Herald transactions and owners transactions. 1584 + if ($other_xaction->getAuthorPHID() != $xaction->getAuthorPHID()) { 1585 + continue; 1586 + } 1587 + 1580 1588 $merged = $this->mergeTransactions($result[$other_key], $xaction); 1581 1589 if ($merged) { 1582 1590 $result[$other_key] = $merged;