Differential D18731 Diff 44973 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 997 Lines • ▼ Show 20 Lines | private function requireDiff($phid, $need_changesets = false) { | ||||
return $diff; | return $diff; | ||||
} | } | ||||
/* -( Herald Integration )------------------------------------------------- */ | /* -( Herald Integration )------------------------------------------------- */ | ||||
protected function shouldApplyHeraldRules( | protected function shouldApplyHeraldRules( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
if ($this->getIsNewObject()) { | |||||
return true; | |||||
} | |||||
foreach ($xactions as $xaction) { | |||||
switch ($xaction->getTransactionType()) { | |||||
case DifferentialTransaction::TYPE_UPDATE: | |||||
if (!$this->getIsCloseByCommit()) { | |||||
return true; | return true; | ||||
} | } | ||||
break; | |||||
case DifferentialRevisionCommandeerTransaction::TRANSACTIONTYPE: | |||||
// When users commandeer revisions, we may need to trigger | |||||
// signatures or author-based rules. | |||||
return true; | |||||
} | |||||
} | |||||
return parent::shouldApplyHeraldRules($object, $xactions); | |||||
} | |||||
protected function didApplyHeraldRules( | protected function didApplyHeraldRules( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
HeraldAdapter $adapter, | HeraldAdapter $adapter, | ||||
HeraldTranscript $transcript) { | HeraldTranscript $transcript) { | ||||
$repository = $object->getRepository(); | $repository = $object->getRepository(); | ||||
if (!$repository) { | if (!$repository) { | ||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | if (!$revision) { | ||||
throw new Exception( | throw new Exception( | ||||
pht('Failed to load revision for Herald adapter construction!')); | pht('Failed to load revision for Herald adapter construction!')); | ||||
} | } | ||||
$adapter = HeraldDifferentialRevisionAdapter::newLegacyAdapter( | $adapter = HeraldDifferentialRevisionAdapter::newLegacyAdapter( | ||||
$revision, | $revision, | ||||
$revision->getActiveDiff()); | $revision->getActiveDiff()); | ||||
// If the object is still a draft, prevent "Send me an email" and other | |||||
// similar rules from acting yet. | |||||
if (!$object->shouldBroadcast()) { | |||||
$adapter->setForbiddenAction( | |||||
HeraldMailableState::STATECONST, | |||||
DifferentialHeraldStateReasons::REASON_DRAFT); | |||||
} | |||||
// If this edit didn't actually change the diff (for example, a user | |||||
// edited the title or changed subscribers), prevent "Run build plan" | |||||
// and other similar rules from acting yet, since the build results will | |||||
// not (or, at least, should not) change unless the actual source changes. | |||||
$has_update = false; | |||||
$type_update = DifferentialTransaction::TYPE_UPDATE; | |||||
foreach ($xactions as $xaction) { | |||||
if ($xaction->getTransactionType() == $type_update) { | |||||
$has_update = true; | |||||
break; | |||||
} | |||||
} | |||||
if (!$has_update) { | |||||
$adapter->setForbiddenAction( | |||||
HeraldBuildableState::STATECONST, | |||||
DifferentialHeraldStateReasons::REASON_UNCHANGED); | |||||
} | |||||
return $adapter; | return $adapter; | ||||
} | } | ||||
/** | /** | ||||
* Update the table which links Differential revisions to paths they affect, | * Update the table which links Differential revisions to paths they affect, | ||||
* so Diffusion can efficiently find pending revisions for a given file. | * so Diffusion can efficiently find pending revisions for a given file. | ||||
*/ | */ | ||||
private function updateAffectedPathTable( | private function updateAffectedPathTable( | ||||
▲ Show 20 Lines • Show All 368 Lines • Show Last 20 Lines |