@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.

When voiding "Accept" reviews, also void "Reject" reviews

Summary: Ref T10967. This change is similar to D17566, but for rejects.

Test Plan:
- Create a revision as A, with reviewer B.
- Reject as B.
- Request review as A.
- Before patch: stuck in "rejected".
- After patch: transitions back to "needs review".

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10967

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

+56 -16
+2 -5
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 339 339 } 340 340 } 341 341 342 - if ($downgrade_accepts) { 342 + if ($downgrade_accepts || $downgrade_rejects) { 343 343 $void_type = DifferentialRevisionVoidTransaction::TRANSACTIONTYPE; 344 344 $results[] = id(new DifferentialTransaction()) 345 345 ->setTransactionType($void_type) ··· 659 659 $reviewer_status = $reviewer->getReviewerStatus(); 660 660 switch ($reviewer_status) { 661 661 case DifferentialReviewerStatus::STATUS_REJECTED: 662 - $action_phid = $reviewer->getLastActionDiffPHID(); 663 662 $active_phid = $active_diff->getPHID(); 664 - $is_current = ($action_phid == $active_phid); 665 - 666 - if ($is_current) { 663 + if ($reviewer->isRejected($active_phid)) { 667 664 $has_rejecting_reviewer = true; 668 665 } 669 666 break;
+34 -7
src/applications/differential/storage/DifferentialReviewer.php
··· 54 54 return ($this->getReviewerStatus() == $status_resigned); 55 55 } 56 56 57 + public function isRejected($diff_phid) { 58 + $status_rejected = DifferentialReviewerStatus::STATUS_REJECTED; 59 + 60 + if ($this->getReviewerStatus() != $status_rejected) { 61 + return false; 62 + } 63 + 64 + if ($this->getVoidedPHID()) { 65 + return false; 66 + } 67 + 68 + if ($this->isCurrentAction($diff_phid)) { 69 + return true; 70 + } 71 + 72 + return false; 73 + } 74 + 75 + 57 76 public function isAccepted($diff_phid) { 58 77 $status_accepted = DifferentialReviewerStatus::STATUS_ACCEPTED; 59 78 ··· 68 87 return false; 69 88 } 70 89 90 + if ($this->isCurrentAction($diff_phid)) { 91 + return true; 92 + } 93 + 94 + $sticky_key = 'differential.sticky-accept'; 95 + $is_sticky = PhabricatorEnv::getEnvConfig($sticky_key); 96 + 97 + if ($is_sticky) { 98 + return true; 99 + } 100 + 101 + return false; 102 + } 103 + 104 + private function isCurrentAction($diff_phid) { 71 105 if (!$diff_phid) { 72 106 return true; 73 107 } ··· 79 113 } 80 114 81 115 if ($action_phid == $diff_phid) { 82 - return true; 83 - } 84 - 85 - $sticky_key = 'differential.sticky-accept'; 86 - $is_sticky = PhabricatorEnv::getEnvConfig($sticky_key); 87 - 88 - if ($is_sticky) { 89 116 return true; 90 117 } 91 118
+9
src/applications/differential/xaction/DifferentialRevisionReviewTransaction.php
··· 100 100 $active_phid = $this->getActiveDiffPHID($revision); 101 101 102 102 $status_accepted = DifferentialReviewerStatus::STATUS_ACCEPTED; 103 + $status_rejected = DifferentialReviewerStatus::STATUS_REJECTED; 104 + 103 105 $is_accepted = ($require_status == $status_accepted); 106 + $is_rejected = ($require_status == $status_rejected); 104 107 105 108 // Otherwise, check that all reviews they have authority over are in 106 109 // the desired set of states. ··· 117 120 // Here, we're primarily testing if we can remove a void on the review. 118 121 if ($is_accepted) { 119 122 if (!$reviewer->isAccepted($active_phid)) { 123 + return false; 124 + } 125 + } 126 + 127 + if ($is_rejected) { 128 + if (!$reviewer->isRejected($active_phid)) { 120 129 return false; 121 130 } 122 131 }
+11 -4
src/applications/differential/xaction/DifferentialRevisionVoidTransaction.php
··· 25 25 'SELECT reviewerPHID FROM %T 26 26 WHERE revisionPHID = %s 27 27 AND voidedPHID IS NULL 28 - AND reviewerStatus = %s', 28 + AND reviewerStatus IN (%Ls)', 29 29 $table_name, 30 30 $object->getPHID(), 31 - DifferentialReviewerStatus::STATUS_ACCEPTED); 31 + $this->getVoidableStatuses()); 32 32 33 33 return ipull($rows, 'reviewerPHID'); 34 34 } ··· 47 47 'UPDATE %T SET voidedPHID = %s 48 48 WHERE revisionPHID = %s 49 49 AND voidedPHID IS NULL 50 - AND reviewerStatus = %s', 50 + AND reviewerStatus IN (%Ls)', 51 51 $table_name, 52 52 $this->getActingAsPHID(), 53 53 $object->getPHID(), 54 - DifferentialReviewerStatus::STATUS_ACCEPTED); 54 + $this->getVoidableStatuses()); 55 55 } 56 56 57 57 public function shouldHide() { 58 58 // This is an internal transaction, so don't show it in feeds or 59 59 // transaction logs. 60 60 return true; 61 + } 62 + 63 + private function getVoidableStatuses() { 64 + return array( 65 + DifferentialReviewerStatus::STATUS_ACCEPTED, 66 + DifferentialReviewerStatus::STATUS_REJECTED, 67 + ); 61 68 } 62 69 63 70 }