Differential D15915 Diff 38331 src/applications/differential/editor/DifferentialTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialTransactionEditor.php
| <?php | <?php | ||||
| final class DifferentialTransactionEditor | final class DifferentialTransactionEditor | ||||
| extends PhabricatorApplicationTransactionEditor { | extends PhabricatorApplicationTransactionEditor { | ||||
| private $changedPriorToCommitURI; | private $changedPriorToCommitURI; | ||||
| private $isCloseByCommit; | private $isCloseByCommit; | ||||
| private $repositoryPHIDOverride = false; | private $repositoryPHIDOverride = false; | ||||
| private $didExpandInlineState = false; | private $didExpandInlineState = false; | ||||
| private $affectedPaths; | |||||
| public function getEditorApplicationClass() { | public function getEditorApplicationClass() { | ||||
| return 'PhabricatorDifferentialApplication'; | return 'PhabricatorDifferentialApplication'; | ||||
| } | } | ||||
| public function getEditorObjectsDescription() { | public function getEditorObjectsDescription() { | ||||
| return pht('Differential Revisions'); | return pht('Differential Revisions'); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,458 Lines • ▼ Show 20 Lines | foreach ($xactions as $xaction) { | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return parent::shouldApplyHeraldRules($object, $xactions); | return parent::shouldApplyHeraldRules($object, $xactions); | ||||
| } | } | ||||
| protected function didApplyHeraldRules( | |||||
| PhabricatorLiskDAO $object, | |||||
| HeraldAdapter $adapter, | |||||
| HeraldTranscript $transcript) { | |||||
| $repository = $object->getRepository(); | |||||
| if (!$repository) { | |||||
| return array(); | |||||
| } | |||||
| if (!$this->affectedPaths) { | |||||
| return array(); | |||||
| } | |||||
| $packages = PhabricatorOwnersPackage::loadAffectedPackages( | |||||
| $repository, | |||||
| $this->affectedPaths); | |||||
| foreach ($packages as $key => $package) { | |||||
| if ($package->isArchived()) { | |||||
| unset($packages[$key]); | |||||
| } | |||||
| } | |||||
| if (!$packages) { | |||||
| return array(); | |||||
| } | |||||
| $auto_subscribe = array(); | |||||
| $auto_review = array(); | |||||
| $auto_block = array(); | |||||
| foreach ($packages as $package) { | |||||
| switch ($package->getAutoReview()) { | |||||
| case PhabricatorOwnersPackage::AUTOREVIEW_SUBSCRIBE: | |||||
| $auto_subscribe[] = $package; | |||||
| break; | |||||
| case PhabricatorOwnersPackage::AUTOREVIEW_REVIEW: | |||||
| $auto_review[] = $package; | |||||
| break; | |||||
| case PhabricatorOwnersPackage::AUTOREVIEW_BLOCK: | |||||
| $auto_block[] = $package; | |||||
| break; | |||||
| case PhabricatorOwnersPackage::AUTOREVIEW_NONE: | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| $owners_phid = id(new PhabricatorOwnersApplication()) | |||||
| ->getPHID(); | |||||
| $xactions = array(); | |||||
| if ($auto_subscribe) { | |||||
| $xactions[] = $object->getApplicationTransactionTemplate() | |||||
| ->setAuthorPHID($owners_phid) | |||||
| ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) | |||||
| ->setNewValue( | |||||
| array( | |||||
| '+' => mpull($auto_subscribe, 'getPHID'), | |||||
| )); | |||||
| } | |||||
| // TODO: Implement autoreview and autoblock, but these are more invovled. | |||||
| return $xactions; | |||||
| } | |||||
| protected function buildHeraldAdapter( | protected function buildHeraldAdapter( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| $revision = id(new DifferentialRevisionQuery()) | $revision = id(new DifferentialRevisionQuery()) | ||||
| ->setViewer($this->getActor()) | ->setViewer($this->getActor()) | ||||
| ->withPHIDs(array($object->getPHID())) | ->withPHIDs(array($object->getPHID())) | ||||
| ->needActiveDiffs(true) | ->needActiveDiffs(true) | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | private function updateAffectedPathTable( | ||||
| $all_paths = array(); | $all_paths = array(); | ||||
| foreach ($paths as $local) { | foreach ($paths as $local) { | ||||
| foreach (DiffusionPathIDQuery::expandPathToRoot($local) as $path) { | foreach (DiffusionPathIDQuery::expandPathToRoot($local) as $path) { | ||||
| $all_paths[$path] = true; | $all_paths[$path] = true; | ||||
| } | } | ||||
| } | } | ||||
| $all_paths = array_keys($all_paths); | $all_paths = array_keys($all_paths); | ||||
| // Save the affected paths; we'll use them later to query Owners. | |||||
| $this->affectedPaths = $all_paths; | |||||
| $path_ids = | $path_ids = | ||||
| PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths( | PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths( | ||||
| $all_paths); | $all_paths); | ||||
| $table = new DifferentialAffectedPath(); | $table = new DifferentialAffectedPath(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| $sql = array(); | $sql = array(); | ||||
| ▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines | |||||