Differential D8506 Diff 20187 src/applications/differential/editor/DifferentialTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialTransactionEditor.php
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
return; | return; | ||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS: | case PhabricatorTransactions::TYPE_SUBSCRIBERS: | ||||
case PhabricatorTransactions::TYPE_COMMENT: | case PhabricatorTransactions::TYPE_COMMENT: | ||||
case DifferentialTransaction::TYPE_INLINE: | case DifferentialTransaction::TYPE_INLINE: | ||||
return; | return; | ||||
case PhabricatorTransactions::TYPE_EDGE: | case PhabricatorTransactions::TYPE_EDGE: | ||||
return; | return; | ||||
case DifferentialTransaction::TYPE_UPDATE: | case DifferentialTransaction::TYPE_UPDATE: | ||||
if (!$this->getIsCloseByCommit()) { | if (!$this->getIsCloseByCommit() && | ||||
(($object->getStatus() == $status_revision) || | |||||
($object->getStatus() == $status_plan))) { | |||||
$object->setStatus($status_review); | $object->setStatus($status_review); | ||||
} | } | ||||
// TODO: Update the `diffPHID` once we add that. | // TODO: Update the `diffPHID` once we add that. | ||||
return; | return; | ||||
case DifferentialTransaction::TYPE_ACTION: | case DifferentialTransaction::TYPE_ACTION: | ||||
switch ($xaction->getNewValue()) { | switch ($xaction->getNewValue()) { | ||||
case DifferentialAction::ACTION_RESIGN: | case DifferentialAction::ACTION_RESIGN: | ||||
case DifferentialAction::ACTION_ACCEPT: | case DifferentialAction::ACTION_ACCEPT: | ||||
▲ Show 20 Lines • Show All 405 Lines • ▼ Show 20 Lines | switch ($old_status) { | ||||
$new_status = $status_revision; | $new_status = $status_revision; | ||||
} else if ($old_status == $status_accepted) { | } else if ($old_status == $status_accepted) { | ||||
// This revision was accepted, but it no longer satisfies the | // This revision was accepted, but it no longer satisfies the | ||||
// conditions for acceptance. This usually happens after an accepting | // conditions for acceptance. This usually happens after an accepting | ||||
// reviewer resigns or is removed. | // reviewer resigns or is removed. | ||||
$new_status = $status_review; | $new_status = $status_review; | ||||
} | } | ||||
if ($new_status !== null && $new_status != $old_status) { | if ($new_status !== null && ($new_status != $old_status)) { | ||||
$xaction = id(new DifferentialTransaction()) | $xaction = id(new DifferentialTransaction()) | ||||
->setTransactionType(DifferentialTransaction::TYPE_STATUS) | ->setTransactionType(DifferentialTransaction::TYPE_STATUS) | ||||
->setOldValue($old_status) | ->setOldValue($old_status) | ||||
->setNewValue($new_status); | ->setNewValue($new_status); | ||||
$xaction = $this->populateTransaction($object, $xaction)->save(); | $xaction = $this->populateTransaction($object, $xaction)->save(); | ||||
$xactions[] = $xaction; | $xactions[] = $xaction; | ||||
▲ Show 20 Lines • Show All 762 Lines • ▼ Show 20 Lines | protected function didApplyHeraldRules( | ||||
// Build a transaction to adjust reviewers. | // Build a transaction to adjust reviewers. | ||||
$reviewers = array( | $reviewers = array( | ||||
DifferentialReviewerStatus::STATUS_ADDED => | DifferentialReviewerStatus::STATUS_ADDED => | ||||
array_keys($adapter->getReviewersAddedByHerald()), | array_keys($adapter->getReviewersAddedByHerald()), | ||||
DifferentialReviewerStatus::STATUS_BLOCKING => | DifferentialReviewerStatus::STATUS_BLOCKING => | ||||
array_keys($adapter->getBlockingReviewersAddedByHerald()), | array_keys($adapter->getBlockingReviewersAddedByHerald()), | ||||
); | ); | ||||
$old_reviewers = $object->getReviewerStatus(); | |||||
$old_reviewers = mpull($old_reviewers, null, 'getReviewerPHID'); | |||||
$value = array(); | $value = array(); | ||||
foreach ($reviewers as $status => $phids) { | foreach ($reviewers as $status => $phids) { | ||||
foreach ($phids as $phid) { | foreach ($phids as $phid) { | ||||
if ($phid == $object->getAuthorPHID()) { | if ($phid == $object->getAuthorPHID()) { | ||||
// Don't try to add the revision's author as a reviewer, since this | // Don't try to add the revision's author as a reviewer, since this | ||||
// isn't valid and doesn't make sense. | // isn't valid and doesn't make sense. | ||||
continue; | continue; | ||||
} | } | ||||
// If the target is already a reviewer, don't try to change anything | |||||
// if their current status is at least as strong as the new status. | |||||
// For example, don't downgrade an "Accepted" to a "Blocking Reviewer". | |||||
$old_reviewer = idx($old_reviewers, $phid); | |||||
if ($old_reviewer) { | |||||
$old_status = $old_reviewer->getStatus(); | |||||
$old_strength = DifferentialReviewerStatus::getStatusStrength( | |||||
$old_status); | |||||
$new_strength = DifferentialReviewerStatus::getStatusStrength( | |||||
$status); | |||||
if ($new_strength <= $old_strength) { | |||||
continue; | |||||
} | |||||
} | |||||
$value['+'][$phid] = array( | $value['+'][$phid] = array( | ||||
'data' => array( | 'data' => array( | ||||
'status' => $status, | 'status' => $status, | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines |