2011-04-21 01:38:16 +02:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class DifferentialGetRevisionConduitAPIMethod
|
|
|
|
extends DifferentialConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'differential.getrevision';
|
|
|
|
}
|
2011-04-21 01:38:16 +02:00
|
|
|
|
2012-04-18 23:25:27 +02:00
|
|
|
public function getMethodStatus() {
|
|
|
|
return self::METHOD_STATUS_DEPRECATED;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMethodStatusDescription() {
|
|
|
|
return "Replaced by 'differential.query'.";
|
|
|
|
}
|
|
|
|
|
2011-04-21 01:38:16 +02:00
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return 'Load the content of a revision from Differential.';
|
2011-04-21 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineParamTypes() {
|
2011-04-21 01:38:16 +02:00
|
|
|
return array(
|
|
|
|
'revision_id' => 'required id',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineReturnType() {
|
2011-04-21 01:38:16 +02:00
|
|
|
return 'nonempty dict';
|
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineErrorTypes() {
|
2011-04-21 01:38:16 +02:00
|
|
|
return array(
|
|
|
|
'ERR_BAD_REVISION' => 'No such revision exists.',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$diff = null;
|
|
|
|
|
|
|
|
$revision_id = $request->getValue('revision_id');
|
2013-07-15 12:29:12 +02:00
|
|
|
$revision = id(new DifferentialRevisionQuery())
|
|
|
|
->withIDs(array($revision_id))
|
|
|
|
->setViewer($request->getUser())
|
|
|
|
->needRelationships(true)
|
|
|
|
->needReviewerStatus(true)
|
|
|
|
->executeOne();
|
|
|
|
|
2011-04-21 01:38:16 +02:00
|
|
|
if (!$revision) {
|
|
|
|
throw new ConduitException('ERR_BAD_REVISION');
|
|
|
|
}
|
|
|
|
|
2011-04-24 09:10:47 +02:00
|
|
|
$reviewer_phids = array_values($revision->getReviewers());
|
|
|
|
|
2013-09-17 22:55:41 +02:00
|
|
|
$diffs = id(new DifferentialDiffQuery())
|
2013-09-24 00:22:57 +02:00
|
|
|
->setViewer($request->getUser())
|
2013-09-17 22:55:41 +02:00
|
|
|
->withRevisionIDs(array($revision_id))
|
|
|
|
->needChangesets(true)
|
|
|
|
->needArcanistProjects(true)
|
|
|
|
->execute();
|
|
|
|
$diff_dicts = mpull($diffs, 'getDiffDict');
|
2011-04-21 01:38:16 +02:00
|
|
|
|
2011-04-23 00:10:42 +02:00
|
|
|
$commit_dicts = array();
|
|
|
|
$commit_phids = $revision->loadCommitPHIDs();
|
2013-09-11 21:27:28 +02:00
|
|
|
$handles = id(new PhabricatorHandleQuery())
|
2013-03-01 02:15:09 +01:00
|
|
|
->setViewer($request->getUser())
|
2013-09-11 21:27:28 +02:00
|
|
|
->withPHIDs($commit_phids)
|
|
|
|
->execute();
|
2011-04-23 00:10:42 +02:00
|
|
|
|
|
|
|
foreach ($commit_phids as $commit_phid) {
|
|
|
|
$commit_dicts[] = array(
|
|
|
|
'fullname' => $handles[$commit_phid]->getFullName(),
|
|
|
|
'dateCommitted' => $handles[$commit_phid]->getTimestamp(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-09 19:23:55 +01:00
|
|
|
$field_data = $this->loadCustomFieldsForRevisions(
|
|
|
|
$request->getUser(),
|
|
|
|
array($revision));
|
2011-08-11 00:48:44 +02:00
|
|
|
|
2011-04-21 01:38:16 +02:00
|
|
|
$dict = array(
|
|
|
|
'id' => $revision->getID(),
|
|
|
|
'phid' => $revision->getPHID(),
|
|
|
|
'authorPHID' => $revision->getAuthorPHID(),
|
2011-04-23 00:10:42 +02:00
|
|
|
'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()),
|
2011-04-21 01:38:16 +02:00
|
|
|
'title' => $revision->getTitle(),
|
|
|
|
'status' => $revision->getStatus(),
|
2012-01-10 20:39:11 +01:00
|
|
|
'statusName' =>
|
|
|
|
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
|
|
|
|
$revision->getStatus()),
|
2011-04-21 01:38:16 +02:00
|
|
|
'summary' => $revision->getSummary(),
|
|
|
|
'testPlan' => $revision->getTestPlan(),
|
|
|
|
'lineCount' => $revision->getLineCount(),
|
2011-04-24 09:10:47 +02:00
|
|
|
'reviewerPHIDs' => $reviewer_phids,
|
2011-04-21 01:38:16 +02:00
|
|
|
'diffs' => $diff_dicts,
|
2011-04-23 00:10:42 +02:00
|
|
|
'commits' => $commit_dicts,
|
2014-10-07 15:01:04 +02:00
|
|
|
'auxiliary' => idx($field_data, $revision->getPHID(), array()),
|
2011-04-21 01:38:16 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return $dict;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|