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

Use ModularTransactions for accept/reject/resign in "differential.createcomment"

Summary:
Ref T10967. `differential.createcomment` is a frozen API method which has been obsoleted by `differential.revision.edit`.

It is the only remaining way to apply an "accept", "reject", or "resign" action using the old "ACTION" code.

Instead of using the old code, sneakly apply a new type of transaction in these cases instead.

Then, remove all the remaining old code for this stuff on the write pathways.

Test Plan:
- Used "differential.createcomment" to accept, reject, and resign from a revision.
- Grepped for all removed ACTION_X constants, found them only in rendering code.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10967

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

+20 -180
+20 -3
src/applications/differential/conduit/DifferentialCreateCommentConduitAPIMethod.php
··· 56 56 57 57 $xactions = array(); 58 58 59 + $modular_map = array( 60 + 'accept' => DifferentialRevisionAcceptTransaction::TRANSACTIONTYPE, 61 + 'reject' => DifferentialRevisionRejectTransaction::TRANSACTIONTYPE, 62 + 'resign' => DifferentialRevisionResignTransaction::TRANSACTIONTYPE, 63 + ); 64 + 59 65 $action = $request->getValue('action'); 60 - if ($action && ($action != 'comment') && ($action != 'none')) { 66 + if (isset($modular_map[$action])) { 61 67 $xactions[] = id(new DifferentialTransaction()) 62 - ->setTransactionType(DifferentialTransaction::TYPE_ACTION) 63 - ->setNewValue($action); 68 + ->setTransactionType($modular_map[$action]) 69 + ->setNewValue(true); 70 + } else if ($action) { 71 + switch ($action) { 72 + case 'comment': 73 + case 'none': 74 + break; 75 + default: 76 + $xactions[] = id(new DifferentialTransaction()) 77 + ->setTransactionType(DifferentialTransaction::TYPE_ACTION) 78 + ->setNewValue($action); 79 + break; 80 + } 64 81 } 65 82 66 83 $content = $request->getValue('message');
-33
src/applications/differential/constants/DifferentialAction.php
··· 119 119 return $title; 120 120 } 121 121 122 - public static function getActionVerb($action) { 123 - $verbs = array( 124 - self::ACTION_COMMENT => pht('Comment'), 125 - self::ACTION_ACCEPT => pht("Accept Revision \xE2\x9C\x94"), 126 - self::ACTION_REJECT => pht("Request Changes \xE2\x9C\x98"), 127 - self::ACTION_RETHINK => pht("Plan Changes \xE2\x9C\x98"), 128 - self::ACTION_ABANDON => pht('Abandon Revision'), 129 - self::ACTION_REQUEST => pht('Request Review'), 130 - self::ACTION_RECLAIM => pht('Reclaim Revision'), 131 - self::ACTION_RESIGN => pht('Resign as Reviewer'), 132 - self::ACTION_ADDREVIEWERS => pht('Add Reviewers'), 133 - self::ACTION_ADDCCS => pht('Add Subscribers'), 134 - self::ACTION_CLOSE => pht('Close Revision'), 135 - self::ACTION_CLAIM => pht('Commandeer Revision'), 136 - self::ACTION_REOPEN => pht('Reopen'), 137 - ); 138 - 139 - if (!empty($verbs[$action])) { 140 - return $verbs[$action]; 141 - } else { 142 - return pht('brazenly %s', $action); 143 - } 144 - } 145 - 146 - public static function allowReviewers($action) { 147 - if ($action == self::ACTION_ADDREVIEWERS || 148 - $action == self::ACTION_REQUEST || 149 - $action == self::ACTION_RESIGN) { 150 - return true; 151 - } 152 - return false; 153 - } 154 - 155 122 }
-144
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 130 130 131 131 $action_type = $xaction->getNewValue(); 132 132 switch ($action_type) { 133 - case DifferentialAction::ACTION_ACCEPT: 134 - case DifferentialAction::ACTION_REJECT: 135 - if ($action_type == DifferentialAction::ACTION_ACCEPT) { 136 - $new_status = DifferentialReviewerStatus::STATUS_ACCEPTED; 137 - } else { 138 - $new_status = DifferentialReviewerStatus::STATUS_REJECTED; 139 - } 140 - 141 - $actor = $this->getActor(); 142 - 143 - // These transactions can cause effects in two ways: by altering the 144 - // status of an existing reviewer; or by adding the actor as a new 145 - // reviewer. 146 - 147 - $will_add_reviewer = true; 148 - foreach ($object->getReviewerStatus() as $reviewer) { 149 - if ($reviewer->hasAuthority($actor)) { 150 - if ($reviewer->getStatus() != $new_status) { 151 - return true; 152 - } 153 - } 154 - if ($reviewer->getReviewerPHID() == $actor_phid) { 155 - $will_add_reviwer = false; 156 - } 157 - } 158 - 159 - return $will_add_reviewer; 160 133 case DifferentialAction::ACTION_CLOSE: 161 134 return ($object->getStatus() != $status_closed); 162 135 case DifferentialAction::ACTION_ABANDON: ··· 169 142 return ($object->getStatus() != $status_plan); 170 143 case DifferentialAction::ACTION_REQUEST: 171 144 return ($object->getStatus() != $status_review); 172 - case DifferentialAction::ACTION_RESIGN: 173 - foreach ($object->getReviewerStatus() as $reviewer) { 174 - if ($reviewer->getReviewerPHID() == $actor_phid) { 175 - return true; 176 - } 177 - } 178 - return false; 179 145 case DifferentialAction::ACTION_CLAIM: 180 146 return ($actor_phid != $object->getAuthorPHID()); 181 147 } ··· 222 188 return; 223 189 case DifferentialTransaction::TYPE_ACTION: 224 190 switch ($xaction->getNewValue()) { 225 - case DifferentialAction::ACTION_RESIGN: 226 - case DifferentialAction::ACTION_ACCEPT: 227 - case DifferentialAction::ACTION_REJECT: 228 - // These have no direct effects, and affect review status only 229 - // indirectly by altering reviewers with TYPE_EDGE transactions. 230 - return; 231 191 case DifferentialAction::ACTION_ABANDON: 232 192 $object->setStatus(ArcanistDifferentialRevisionStatus::ABANDONED); 233 193 return; ··· 482 442 $action_type = $xaction->getNewValue(); 483 443 484 444 switch ($action_type) { 485 - case DifferentialAction::ACTION_ACCEPT: 486 - case DifferentialAction::ACTION_REJECT: 487 - if ($action_type == DifferentialAction::ACTION_ACCEPT) { 488 - $data = array( 489 - 'status' => DifferentialReviewerStatus::STATUS_ACCEPTED, 490 - ); 491 - } else { 492 - $data = array( 493 - 'status' => DifferentialReviewerStatus::STATUS_REJECTED, 494 - ); 495 - } 496 - 497 - $edits = array(); 498 - 499 - foreach ($object->getReviewerStatus() as $reviewer) { 500 - if ($reviewer->hasAuthority($actor)) { 501 - $edits[$reviewer->getReviewerPHID()] = array( 502 - 'data' => $data, 503 - ); 504 - } 505 - } 506 - 507 - // Also either update or add the actor themselves as a reviewer. 508 - $edits[$actor_phid] = array( 509 - 'data' => $data, 510 - ); 511 - 512 - $results[] = id(new DifferentialTransaction()) 513 - ->setTransactionType($type_edge) 514 - ->setMetadataValue('edge:type', $edge_reviewer) 515 - ->setIgnoreOnNoEffect(true) 516 - ->setNewValue(array('+' => $edits)); 517 - break; 518 - 519 445 case DifferentialAction::ACTION_CLAIM: 520 446 $is_commandeer = true; 521 - break; 522 - case DifferentialAction::ACTION_RESIGN: 523 - // If the user is resigning, add a separate reviewer edit 524 - // transaction which removes them as a reviewer. 525 - 526 - $results[] = id(new DifferentialTransaction()) 527 - ->setTransactionType($type_edge) 528 - ->setMetadataValue('edge:type', $edge_reviewer) 529 - ->setIgnoreOnNoEffect(true) 530 - ->setNewValue( 531 - array( 532 - '-' => array( 533 - $actor_phid => $actor_phid, 534 - ), 535 - )); 536 - 537 447 break; 538 448 } 539 449 break; ··· 925 835 $status_closed = ArcanistDifferentialRevisionStatus::CLOSED; 926 836 927 837 switch ($action) { 928 - case DifferentialAction::ACTION_ACCEPT: 929 - if ($actor_is_author && !$allow_self_accept) { 930 - return pht( 931 - 'You can not accept this revision because you are the owner.'); 932 - } 933 - 934 - if ($revision_status == $status_abandoned) { 935 - return pht( 936 - 'You can not accept this revision because it has been '. 937 - 'abandoned.'); 938 - } 939 - 940 - if ($revision_status == $status_closed) { 941 - return pht( 942 - 'You can not accept this revision because it has already been '. 943 - 'closed.'); 944 - } 945 - 946 - // TODO: It would be nice to make this generic at some point. 947 - $signatures = DifferentialRequiredSignaturesField::loadForRevision( 948 - $revision); 949 - foreach ($signatures as $phid => $signed) { 950 - if (!$signed) { 951 - return pht( 952 - 'You can not accept this revision because the author has '. 953 - 'not signed all of the required legal documents.'); 954 - } 955 - } 956 - 957 - break; 958 - 959 - case DifferentialAction::ACTION_REJECT: 960 - if ($actor_is_author) { 961 - return pht('You can not request changes to your own revision.'); 962 - } 963 - 964 - if ($revision_status == $status_abandoned) { 965 - return pht( 966 - 'You can not request changes to this revision because it has been '. 967 - 'abandoned.'); 968 - } 969 - 970 - if ($revision_status == $status_closed) { 971 - return pht( 972 - 'You can not request changes to this revision because it has '. 973 - 'already been closed.'); 974 - } 975 - break; 976 - 977 - case DifferentialAction::ACTION_RESIGN: 978 - // You can always resign from a revision if you're a reviewer. If you 979 - // aren't, this is a no-op rather than invalid. 980 - break; 981 - 982 838 case DifferentialAction::ACTION_CLAIM: 983 839 // You can claim a revision if you're not the owner. If you are, this 984 840 // is a no-op rather than invalid.