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

Allow users to re-accept or re-reject a revision if they have authority over package/project reviewers not yet in the target state

Summary:
To set this up:

- alice accepts a revision.
- Something adds a package or project she has authority over as a reviewer.
- Because alice has already accepted, she can not re-accept, but she should be able to (in order to accept on behalf of the new project or package).

Test Plan:
- Created a revision.
- Accepted as user "dog".
- Added "dog project".
- Re-accepted.
- Could not three-accept.
- Removed "dog project.
- Rejected.
- Added "dog project".
- Re-rejected.
- Could not three-reject.

Reviewers: chad, eadler

Reviewed By: chad, eadler

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

+26 -10
+2 -2
src/applications/differential/xaction/DifferentialRevisionAcceptTransaction.php
··· 50 50 51 51 public function generateOldValue($object) { 52 52 $actor = $this->getActor(); 53 - return $this->isViewerAcceptingReviewer($object, $actor); 53 + return $this->isViewerFullyAccepted($object, $actor); 54 54 } 55 55 56 56 public function applyExternalEffects($object, $value) { ··· 79 79 } 80 80 } 81 81 82 - if ($this->isViewerAcceptingReviewer($object, $viewer)) { 82 + if ($this->isViewerFullyAccepted($object, $viewer)) { 83 83 throw new Exception( 84 84 pht( 85 85 'You can not accept this revision because you have already '.
+2 -2
src/applications/differential/xaction/DifferentialRevisionRejectTransaction.php
··· 46 46 47 47 public function generateOldValue($object) { 48 48 $actor = $this->getActor(); 49 - return $this->isViewerRejectingReviewer($object, $actor); 49 + return $this->isViewerFullyRejected($object, $actor); 50 50 } 51 51 52 52 public function applyExternalEffects($object, $value) { ··· 72 72 'not own.')); 73 73 } 74 74 75 - if ($this->isViewerRejectingReviewer($object, $viewer)) { 75 + if ($this->isViewerFullyRejected($object, $viewer)) { 76 76 throw new Exception( 77 77 pht( 78 78 'You can not request changes to this revision because you have '.
+22 -6
src/applications/differential/xaction/DifferentialRevisionReviewTransaction.php
··· 13 13 return ($this->getViewerReviewerStatus($revision, $viewer) !== null); 14 14 } 15 15 16 - protected function isViewerAcceptingReviewer( 16 + protected function isViewerFullyAccepted( 17 17 DifferentialRevision $revision, 18 18 PhabricatorUser $viewer) { 19 - return $this->isViewerReviewerStatusAmong( 19 + return $this->isViewerReviewerStatusFullyAmong( 20 20 $revision, 21 21 $viewer, 22 22 array( ··· 24 24 )); 25 25 } 26 26 27 - protected function isViewerRejectingReviewer( 27 + protected function isViewerFullyRejected( 28 28 DifferentialRevision $revision, 29 29 PhabricatorUser $viewer) { 30 - return $this->isViewerReviewerStatusAmong( 30 + return $this->isViewerReviewerStatusFullyAmong( 31 31 $revision, 32 32 $viewer, 33 33 array( ··· 54 54 return null; 55 55 } 56 56 57 - protected function isViewerReviewerStatusAmong( 57 + protected function isViewerReviewerStatusFullyAmong( 58 58 DifferentialRevision $revision, 59 59 PhabricatorUser $viewer, 60 60 array $status_list) { 61 61 62 + // If the user themselves is not a reviewer, the reviews they have 63 + // authority over can not all be in any set of states since their own 64 + // personal review has no state. 62 65 $status = $this->getViewerReviewerStatus($revision, $viewer); 63 66 if ($status === null) { 64 67 return false; 65 68 } 66 69 70 + // Otherwise, check that all reviews they have authority over are in 71 + // the desired set of states. 67 72 $status_map = array_fuse($status_list); 68 - return isset($status_map[$status]); 73 + foreach ($revision->getReviewerStatus() as $reviewer) { 74 + if (!$reviewer->hasAuthority($viewer)) { 75 + continue; 76 + } 77 + 78 + $status = $reviewer->getStatus(); 79 + if (!isset($status_map[$status])) { 80 + return false; 81 + } 82 + } 83 + 84 + return true; 69 85 } 70 86 71 87 protected function applyReviewerEffect(