Differential D12894 Diff 31029 src/applications/differential/conduit/DifferentialGetRevisionConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/conduit/DifferentialGetRevisionConduitAPIMethod.php
<?php | <?php | ||||
final class DifferentialGetRevisionConduitAPIMethod | final class DifferentialGetRevisionConduitAPIMethod | ||||
extends DifferentialConduitAPIMethod { | extends DifferentialConduitAPIMethod { | ||||
public function getAPIMethodName() { | public function getAPIMethodName() { | ||||
return 'differential.getrevision'; | return 'differential.getrevision'; | ||||
} | } | ||||
public function getMethodStatus() { | public function getMethodStatus() { | ||||
return self::METHOD_STATUS_DEPRECATED; | return self::METHOD_STATUS_DEPRECATED; | ||||
} | } | ||||
public function getMethodStatusDescription() { | public function getMethodStatusDescription() { | ||||
return "Replaced by 'differential.query'."; | return pht("Replaced by '%s'.", 'differential.query'); | ||||
} | } | ||||
public function getMethodDescription() { | public function getMethodDescription() { | ||||
return 'Load the content of a revision from Differential.'; | return pht('Load the content of a revision from Differential.'); | ||||
} | } | ||||
protected function defineParamTypes() { | protected function defineParamTypes() { | ||||
return array( | return array( | ||||
'revision_id' => 'required id', | 'revision_id' => 'required id', | ||||
); | ); | ||||
} | } | ||||
protected function defineReturnType() { | protected function defineReturnType() { | ||||
return 'nonempty dict'; | return 'nonempty dict'; | ||||
} | } | ||||
protected function defineErrorTypes() { | protected function defineErrorTypes() { | ||||
return array( | return array( | ||||
'ERR_BAD_REVISION' => 'No such revision exists.', | 'ERR_BAD_REVISION' => pht('No such revision exists.'), | ||||
); | ); | ||||
} | } | ||||
protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
$diff = null; | $diff = null; | ||||
$revision_id = $request->getValue('revision_id'); | $revision_id = $request->getValue('revision_id'); | ||||
$revision = id(new DifferentialRevisionQuery()) | $revision = id(new DifferentialRevisionQuery()) | ||||
->withIDs(array($revision_id)) | ->withIDs(array($revision_id)) | ||||
->setViewer($request->getUser()) | ->setViewer($request->getUser()) | ||||
->needRelationships(true) | ->needRelationships(true) | ||||
->needReviewerStatus(true) | ->needReviewerStatus(true) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$revision) { | if (!$revision) { | ||||
throw new ConduitException('ERR_BAD_REVISION'); | throw new ConduitException('ERR_BAD_REVISION'); | ||||
} | } | ||||
$reviewer_phids = array_values($revision->getReviewers()); | $reviewer_phids = array_values($revision->getReviewers()); | ||||
$diffs = id(new DifferentialDiffQuery()) | $diffs = id(new DifferentialDiffQuery()) | ||||
->setViewer($request->getUser()) | ->setViewer($request->getUser()) | ||||
->withRevisionIDs(array($revision_id)) | ->withRevisionIDs(array($revision_id)) | ||||
->needChangesets(true) | ->needChangesets(true) | ||||
->needArcanistProjects(true) | |||||
->execute(); | ->execute(); | ||||
$diff_dicts = mpull($diffs, 'getDiffDict'); | $diff_dicts = mpull($diffs, 'getDiffDict'); | ||||
$commit_dicts = array(); | $commit_dicts = array(); | ||||
$commit_phids = $revision->loadCommitPHIDs(); | $commit_phids = $revision->loadCommitPHIDs(); | ||||
$handles = id(new PhabricatorHandleQuery()) | $handles = id(new PhabricatorHandleQuery()) | ||||
->setViewer($request->getUser()) | ->setViewer($request->getUser()) | ||||
->withPHIDs($commit_phids) | ->withPHIDs($commit_phids) | ||||
Show All 36 Lines |