Differential D21613 Diff 51459 src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php
Show All 32 Lines | $order_types = array( | ||||
DifferentialRevisionQuery::ORDER_CREATED, | DifferentialRevisionQuery::ORDER_CREATED, | ||||
); | ); | ||||
$order_const = $this->formatStringConstants($order_types); | $order_const = $this->formatStringConstants($order_types); | ||||
return array( | return array( | ||||
'authors' => 'optional list<phid>', | 'authors' => 'optional list<phid>', | ||||
'ccs' => 'optional list<phid>', | 'ccs' => 'optional list<phid>', | ||||
'reviewers' => 'optional list<phid>', | 'reviewers' => 'optional list<phid>', | ||||
'paths' => 'optional list<pair<callsign, path>>', | 'paths' => 'unsupported', | ||||
'commitHashes' => 'optional list<pair<'.$hash_const.', string>>', | 'commitHashes' => 'optional list<pair<'.$hash_const.', string>>', | ||||
'status' => 'optional '.$status_const, | 'status' => 'optional '.$status_const, | ||||
'order' => 'optional '.$order_const, | 'order' => 'optional '.$order_const, | ||||
'limit' => 'optional uint', | 'limit' => 'optional uint', | ||||
'offset' => 'optional uint', | 'offset' => 'optional uint', | ||||
'ids' => 'optional list<uint>', | 'ids' => 'optional list<uint>', | ||||
'phids' => 'optional list<phid>', | 'phids' => 'optional list<phid>', | ||||
'subscribers' => 'optional list<phid>', | 'subscribers' => 'optional list<phid>', | ||||
Show All 37 Lines | protected function execute(ConduitAPIRequest $request) { | ||||
if ($ccs) { | if ($ccs) { | ||||
$query->withCCs($ccs); | $query->withCCs($ccs); | ||||
} | } | ||||
if ($reviewers) { | if ($reviewers) { | ||||
$query->withReviewers($reviewers); | $query->withReviewers($reviewers); | ||||
} | } | ||||
if ($path_pairs) { | if ($path_pairs) { | ||||
$paths = array(); | throw new Exception( | ||||
foreach ($path_pairs as $pair) { | |||||
list($callsign, $path) = $pair; | |||||
$paths[] = $path; | |||||
} | |||||
$path_map = id(new DiffusionPathIDQuery($paths))->loadPathIDs(); | |||||
if (count($path_map) != count($paths)) { | |||||
$unknown_paths = array(); | |||||
foreach ($paths as $p) { | |||||
if (!idx($path_map, $p)) { | |||||
$unknown_paths[] = $p; | |||||
} | |||||
} | |||||
throw id(new ConduitException('ERR-INVALID-PARAMETER')) | |||||
->setErrorDescription( | |||||
pht( | |||||
'Unknown paths: %s', | |||||
implode(', ', $unknown_paths))); | |||||
} | |||||
$repos = array(); | |||||
foreach ($path_pairs as $pair) { | |||||
list($callsign, $path) = $pair; | |||||
if (!idx($repos, $callsign)) { | |||||
$repos[$callsign] = id(new PhabricatorRepositoryQuery()) | |||||
->setViewer($request->getUser()) | |||||
->withCallsigns(array($callsign)) | |||||
->executeOne(); | |||||
if (!$repos[$callsign]) { | |||||
throw id(new ConduitException('ERR-INVALID-PARAMETER')) | |||||
->setErrorDescription( | |||||
pht( | pht( | ||||
'Unknown repo callsign: %s', | 'Parameter "paths" to Conduit API method "differential.query" is '. | ||||
$callsign)); | 'no longer supported. Use the "paths" constraint to '. | ||||
} | '"differential.revision.search" instead. See T13639.')); | ||||
} | |||||
$repo = $repos[$callsign]; | |||||
$query->withPath($repo->getID(), idx($path_map, $path)); | |||||
} | |||||
} | } | ||||
if ($commit_hashes) { | if ($commit_hashes) { | ||||
$hash_types = ArcanistDifferentialRevisionHash::getTypes(); | $hash_types = ArcanistDifferentialRevisionHash::getTypes(); | ||||
foreach ($commit_hashes as $info) { | foreach ($commit_hashes as $info) { | ||||
list($type, $hash) = $info; | list($type, $hash) = $info; | ||||
if (empty($type) || | if (empty($type) || | ||||
!in_array($type, $hash_types) || | !in_array($type, $hash_types) || | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |