Fix two transactional issues around revision status
Summary: Two issues: - Herald is currently overwriting accepts and rejects with "blocking reviewer". Just stop it from doing that. - When you update an accepted revision, we put it back in "needs review", then return it to "accepted", generating an extra transaction. Instead, don't. Test Plan: - Updated a revision with an accepting, herald-based blocking project reviewer. Reviewer was still accepting. - Updated an accepted revision, didn't get an extra transaction. Reviewers: btrahan Reviewed By: btrahan Subscribers: aran, epriestley Differential Revision: https://secure.phabricator.com/D8506
This commit is contained in:
parent
193e8a54fc
commit
3b861ab741
|
@ -178,7 +178,9 @@ final class DifferentialTransactionEditor
|
||||||
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.
|
||||||
|
@ -600,7 +602,7 @@ final class DifferentialTransactionEditor
|
||||||
$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)
|
||||||
|
@ -1379,6 +1381,9 @@ final class DifferentialTransactionEditor
|
||||||
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) {
|
||||||
|
@ -1388,6 +1393,23 @@ final class DifferentialTransactionEditor
|
||||||
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,
|
||||||
|
|
Loading…
Reference in a new issue