Commit f3aefef7 authored by Daniel Stone's avatar Daniel Stone Committed by Ana Rute Mendes

LOCAL/POLICY: Differential: Clear 'Depends On' when attaching new diff

When we attach a new diff to a Differential revision, clear out its
'Depends On' field. This is so we don't end up with dependency cycles
when we rebase/cherry-pick commits out of order.

As upstream do not use rebasing/chery-picking/multi-patch-branch
workflows, this is unlikely to be accepted.
parent ceb5d374
......@@ -160,9 +160,11 @@ final class DifferentialTransactionEditor
$type_edge = PhabricatorTransactions::TYPE_EDGE;
$edge_ref_task = DifferentialRevisionHasTaskEdgeType::EDGECONST;
$edge_deps = DifferentialRevisionDependsOnRevisionEdgeType::EDGECONST;
$want_downgrade = array();
$must_downgrade = array();
$kill_deps = false;
if ($this->getIsCloseByCommit()) {
// Never downgrade reviewers when we're closing a revision after a
// commit.
......@@ -171,6 +173,11 @@ final class DifferentialTransactionEditor
case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE:
$want_downgrade[] = DifferentialReviewerStatus::STATUS_ACCEPTED;
$want_downgrade[] = DifferentialReviewerStatus::STATUS_REJECTED;
// If the PHID is null, this is a newly-created revision, so there
// are no old deps to kill.
if ($object->getPHID()) {
$kill_deps = true;
}
break;
case DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE:
if (!$object->isChangePlanned()) {
......@@ -198,6 +205,20 @@ final class DifferentialTransactionEditor
->setNewValue($want_downgrade);
}
if ($kill_deps) {
$deps_to_remove = PhabricatorEdgeQuery::loadDestinationPHIDs(
$object->getPHID(),
$edge_deps);
if ($deps_to_remove) {
$results[] = id(new DifferentialTransaction())
->setTransactionType($type_edge)
->setMetadataValue('edge:type', $edge_deps)
->setIgnoreOnNoEffect(true)
->setNewValue(array('-' => array_fuse($deps_to_remove)));
}
}
$is_commandeer = false;
switch ($xaction->getTransactionType()) {
case DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment