Differential D11074 Diff 26680 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 263 Lines • ▼ Show 20 Lines | protected function expandTransaction( | ||||
$results = parent::expandTransaction($object, $xaction); | $results = parent::expandTransaction($object, $xaction); | ||||
$actor = $this->getActor(); | $actor = $this->getActor(); | ||||
$actor_phid = $this->getActingAsPHID(); | $actor_phid = $this->getActingAsPHID(); | ||||
$type_edge = PhabricatorTransactions::TYPE_EDGE; | $type_edge = PhabricatorTransactions::TYPE_EDGE; | ||||
$status_plan = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED; | $status_plan = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED; | ||||
$edge_reviewer = PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER; | $edge_reviewer = DifferentialRevisionHasReviewerEdgeType::EDGECONST; | ||||
$edge_ref_task = DifferentialRevisionHasTaskEdgeType::EDGECONST; | $edge_ref_task = DifferentialRevisionHasTaskEdgeType::EDGECONST; | ||||
$is_sticky_accept = PhabricatorEnv::getEnvConfig( | $is_sticky_accept = PhabricatorEnv::getEnvConfig( | ||||
'differential.sticky-accept'); | 'differential.sticky-accept'); | ||||
$downgrade_rejects = false; | $downgrade_rejects = false; | ||||
$downgrade_accepts = false; | $downgrade_accepts = false; | ||||
if ($this->getIsCloseByCommit()) { | if ($this->getIsCloseByCommit()) { | ||||
▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | protected function applyCustomExternalTransaction( | ||||
return parent::applyCustomExternalTransaction($object, $xaction); | return parent::applyCustomExternalTransaction($object, $xaction); | ||||
} | } | ||||
protected function mergeEdgeData($type, array $u, array $v) { | protected function mergeEdgeData($type, array $u, array $v) { | ||||
$result = parent::mergeEdgeData($type, $u, $v); | $result = parent::mergeEdgeData($type, $u, $v); | ||||
switch ($type) { | switch ($type) { | ||||
case PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER: | case DifferentialRevisionHasReviewerEdgeType::EDGECONST: | ||||
// When the same reviewer has their status updated by multiple | // When the same reviewer has their status updated by multiple | ||||
// transactions, we want the strongest status to win. An example of | // transactions, we want the strongest status to win. An example of | ||||
// this is when a user adds a comment and also accepts a revision which | // this is when a user adds a comment and also accepts a revision which | ||||
// they are a reviewer on. The comment creates a "commented" status, | // they are a reviewer on. The comment creates a "commented" status, | ||||
// while the accept creates an "accepted" status. Since accept is | // while the accept creates an "accepted" status. Since accept is | ||||
// stronger, it should win and persist. | // stronger, it should win and persist. | ||||
$u_status = idx($u, 'status'); | $u_status = idx($u, 'status'); | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | protected function validateTransaction( | ||||
$config_self_accept_key = 'differential.allow-self-accept'; | $config_self_accept_key = 'differential.allow-self-accept'; | ||||
$allow_self_accept = PhabricatorEnv::getEnvConfig($config_self_accept_key); | $allow_self_accept = PhabricatorEnv::getEnvConfig($config_self_accept_key); | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
switch ($type) { | switch ($type) { | ||||
case PhabricatorTransactions::TYPE_EDGE: | case PhabricatorTransactions::TYPE_EDGE: | ||||
switch ($xaction->getMetadataValue('edge:type')) { | switch ($xaction->getMetadataValue('edge:type')) { | ||||
case PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER: | case DifferentialRevisionHasReviewerEdgeType::EDGECONST: | ||||
// Prevent the author from becoming a reviewer. | // Prevent the author from becoming a reviewer. | ||||
// NOTE: This is pretty gross, but this restriction is unusual. | // NOTE: This is pretty gross, but this restriction is unusual. | ||||
// If we end up with too much more of this, we should try to clean | // If we end up with too much more of this, we should try to clean | ||||
// this up -- maybe by moving validation to after transactions | // this up -- maybe by moving validation to after transactions | ||||
// are adjusted (so we can just examine the final value) or adding | // are adjusted (so we can just examine the final value) or adding | ||||
// a second phase there? | // a second phase there? | ||||
▲ Show 20 Lines • Show All 561 Lines • ▼ Show 20 Lines | if ($rev_map) { | ||||
->execute(); | ->execute(); | ||||
$rev_phids = mpull($revs, 'getPHID', 'getPHID'); | $rev_phids = mpull($revs, 'getPHID', 'getPHID'); | ||||
// NOTE: Skip any write attempts if a user cleverly implies a revision | // NOTE: Skip any write attempts if a user cleverly implies a revision | ||||
// depends upon itself. | // depends upon itself. | ||||
unset($rev_phids[$object->getPHID()]); | unset($rev_phids[$object->getPHID()]); | ||||
if ($revs) { | if ($revs) { | ||||
$edge_depends = PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV; | $depends = DifferentialRevisionDependsOnRevisionEdgeType::EDGECONST; | ||||
$edges[$edge_depends] = $rev_phids; | $edges[$depends] = $rev_phids; | ||||
} | } | ||||
} | } | ||||
$result = array(); | $result = array(); | ||||
foreach ($edges as $type => $specs) { | foreach ($edges as $type => $specs) { | ||||
$result[] = id(new DifferentialTransaction()) | $result[] = id(new DifferentialTransaction()) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | ||||
->setMetadataValue('edge:type', $type) | ->setMetadataValue('edge:type', $type) | ||||
▲ Show 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | foreach ($reviewers as $status => $phids) { | ||||
'data' => array( | 'data' => array( | ||||
'status' => $status, | 'status' => $status, | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
if ($value) { | if ($value) { | ||||
$edge_reviewer = PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER; | $edge_reviewer = DifferentialRevisionHasReviewerEdgeType::EDGECONST; | ||||
$xactions[] = id(new DifferentialTransaction()) | $xactions[] = id(new DifferentialTransaction()) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | ||||
->setMetadataValue('edge:type', $edge_reviewer) | ->setMetadataValue('edge:type', $edge_reviewer) | ||||
->setNewValue($value); | ->setNewValue($value); | ||||
} | } | ||||
// Require legalpad document signatures. | // Require legalpad document signatures. | ||||
▲ Show 20 Lines • Show All 241 Lines • Show Last 20 Lines |