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

Restore some minor state behaviors to Differential on EditEngine

Summary:
Ref T11114. This restores:

- Commandeering should exeucte Herald.
- Commandeering should swap reviewers.
- "Request Review" on an "Accepted" revision should downgrade reviewers so they have to accept again.

Test Plan:
- Commandeered, saw Herald run and reviewers swap.
- Requested review of an accepted revision, saw it drop down to "Needs Review" with "Accepted Prior" on the reviewer.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11114

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

+63 -39
+59 -39
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 288 288 $downgrade_accepts = true; 289 289 } 290 290 break; 291 + case DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE: 292 + $downgrade_rejects = true; 293 + if ((!$is_sticky_accept) || 294 + ($object->getStatus() != $status_plan)) { 295 + // If the old state isn't "changes planned", downgrade the accepts. 296 + // This exception allows an accepted revision to go through 297 + // "Plan Changes" -> "Request Review" and return to "accepted" if 298 + // the author didn't update the revision, essentially undoing the 299 + // "Plan Changes". 300 + $downgrade_accepts = true; 301 + } 302 + break; 303 + 304 + // TODO: Remove this, obsoleted by ModularTransactions above. 291 305 case DifferentialTransaction::TYPE_ACTION: 292 306 switch ($xaction->getNewValue()) { 293 307 case DifferentialAction::ACTION_REQUEST: 294 308 $downgrade_rejects = true; 295 309 if ((!$is_sticky_accept) || 296 310 ($object->getStatus() != $status_plan)) { 297 - // If the old state isn't "changes planned", downgrade the 298 - // accepts. This exception allows an accepted revision to 299 - // go through Plan Changes -> Request Review to return to 300 - // "accepted" if the author didn't update the revision. 301 311 $downgrade_accepts = true; 302 312 } 303 313 break; ··· 353 363 } 354 364 } 355 365 366 + $is_commandeer = false; 356 367 switch ($xaction->getTransactionType()) { 357 368 case DifferentialTransaction::TYPE_UPDATE: 358 369 if ($this->getIsCloseByCommit()) { ··· 424 435 } 425 436 break; 426 437 438 + case DifferentialRevisionCommandeerTransaction::TRANSACTIONTYPE: 439 + $is_commandeer = true; 440 + break; 441 + 427 442 case DifferentialTransaction::TYPE_ACTION: 428 443 $action_type = $xaction->getNewValue(); 429 444 ··· 463 478 break; 464 479 465 480 case DifferentialAction::ACTION_CLAIM: 466 - // If the user is commandeering, add the previous owner as a 467 - // reviewer and remove the actor. 468 - 469 - $edits = array( 470 - '-' => array( 471 - $actor_phid => $actor_phid, 472 - ), 473 - ); 474 - 475 - $owner_phid = $object->getAuthorPHID(); 476 - if ($owner_phid) { 477 - $reviewer = new DifferentialReviewerProxy( 478 - $owner_phid, 479 - array( 480 - 'status' => DifferentialReviewerStatus::STATUS_ADDED, 481 - )); 482 - 483 - $edits['+'] = array( 484 - $owner_phid => array( 485 - 'data' => $reviewer->getEdgeData(), 486 - ), 487 - ); 488 - } 489 - 490 - // NOTE: We're setting setIsCommandeerSideEffect() on this because 491 - // normally you can't add a revision's author as a reviewer, but 492 - // this action swaps them after validation executes. 493 - 494 - $results[] = id(new DifferentialTransaction()) 495 - ->setTransactionType($type_edge) 496 - ->setMetadataValue('edge:type', $edge_reviewer) 497 - ->setIgnoreOnNoEffect(true) 498 - ->setIsCommandeerSideEffect(true) 499 - ->setNewValue($edits); 500 - 481 + $is_commandeer = true; 501 482 break; 502 483 case DifferentialAction::ACTION_RESIGN: 503 484 // If the user is resigning, add a separate reviewer edit ··· 517 498 break; 518 499 } 519 500 break; 501 + } 502 + 503 + if ($is_commandeer) { 504 + $results[] = $this->newCommandeerReviewerTransaction($object); 520 505 } 521 506 522 507 if (!$this->didExpandInlineState) { ··· 1499 1484 return true; 1500 1485 } 1501 1486 break; 1487 + case DifferentialRevisionCommandeerTransaction::TRANSACTIONTYPE: 1488 + // When users commandeer revisions, we may need to trigger 1489 + // signatures or author-based rules. 1490 + return true; 1502 1491 case DifferentialTransaction::TYPE_ACTION: 1503 1492 switch ($xaction->getNewValue()) { 1504 1493 case DifferentialAction::ACTION_CLAIM: ··· 1920 1909 protected function loadCustomWorkerState(array $state) { 1921 1910 $this->changedPriorToCommitURI = idx($state, 'changedPriorToCommitURI'); 1922 1911 return $this; 1912 + } 1913 + 1914 + private function newCommandeerReviewerTransaction( 1915 + DifferentialRevision $revision) { 1916 + 1917 + $actor_phid = $this->getActingAsPHID(); 1918 + $owner_phid = $revision->getAuthorPHID(); 1919 + 1920 + // If the user is commandeering, add the previous owner as a 1921 + // reviewer and remove the actor. 1922 + 1923 + $edits = array( 1924 + '-' => array( 1925 + $actor_phid, 1926 + ), 1927 + '+' => array( 1928 + $owner_phid, 1929 + ), 1930 + ); 1931 + 1932 + // NOTE: We're setting setIsCommandeerSideEffect() on this because normally 1933 + // you can't add a revision's author as a reviewer, but this action swaps 1934 + // them after validation executes. 1935 + 1936 + $xaction_type = DifferentialRevisionReviewersTransaction::TRANSACTIONTYPE; 1937 + 1938 + return id(new DifferentialTransaction()) 1939 + ->setTransactionType($xaction_type) 1940 + ->setIgnoreOnNoEffect(true) 1941 + ->setIsCommandeerSideEffect(true) 1942 + ->setNewValue($edits); 1923 1943 } 1924 1944 1925 1945 }
+4
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 1805 1805 1806 1806 try { 1807 1807 $xactions = $editor->applyTransactions($object, $xactions); 1808 + } catch (PhabricatorApplicationTransactionValidationException $ex) { 1809 + return id(new PhabricatorApplicationTransactionValidationResponse()) 1810 + ->setCancelURI($view_uri) 1811 + ->setException($ex); 1808 1812 } catch (PhabricatorApplicationTransactionNoEffectException $ex) { 1809 1813 return id(new PhabricatorApplicationTransactionNoEffectResponse()) 1810 1814 ->setCancelURI($view_uri)