diff --git a/src/applications/conduit/method/differential/ConduitAPI_differential_query_Method.php b/src/applications/conduit/method/differential/ConduitAPI_differential_query_Method.php index 2c2c4d52a0..5ff4d52c40 100644 --- a/src/applications/conduit/method/differential/ConduitAPI_differential_query_Method.php +++ b/src/applications/conduit/method/differential/ConduitAPI_differential_query_Method.php @@ -48,9 +48,7 @@ final class ConduitAPI_differential_query_Method 'authors' => 'optional list', 'ccs' => 'optional list', 'reviewers' => 'optional list', - // TODO: Implement this, it needs to accept a repository ID in addition - // to a path so the signature needs to be a little more complicated. - // 'paths' => 'optional list>', + 'paths' => 'optional list>', 'commitHashes' => 'optional list, string>>', 'status' => 'optional enum<'.$status_types.'>', @@ -82,6 +80,7 @@ final class ConduitAPI_differential_query_Method $reviewers = $request->getValue('reviewers'); $status = $request->getValue('status'); $order = $request->getValue('order'); + $path_pairs = $request->getValue('paths'); $commit_hashes = $request->getValue('commitHashes'); $limit = $request->getValue('limit'); $offset = $request->getValue('offset'); @@ -102,17 +101,47 @@ final class ConduitAPI_differential_query_Method if ($reviewers) { $query->withReviewers($reviewers); } -/* TODO: Implement. - $paths = $request->getValue('paths'); - if ($paths) { - foreach ($paths as $path) { - // (Lookup the repository IDs.) + if ($path_pairs) { + $paths = array(); + foreach ($path_pairs as $pair) { + list($callsign, $path) = $pair; + $paths[] = $path; + } - $query->withPath($repository_id, $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( + 'Unknown paths: '.implode(', ', $unknown_paths)); + } + + $repos = array(); + foreach ($path_pairs as $pair) { + list($callsign, $path) = $pair; + if (!idx($repos, $callsign)) { + $repos[$callsign] = id(new PhabricatorRepository())->loadOneWhere( + 'callsign = %s', + $callsign); + + if (!$repos[$callsign]) { + throw id(new ConduitException('ERR-INVALID-PARAMETER')) + ->setErrorDescription( + 'Unknown repo callsign: '.$callsign); + } + } + $repo = $repos[$callsign]; + + $query->withPath($repo->getID(), idx($path_map, $path)); } } - */ + if ($commit_hashes) { $hash_types = ArcanistDifferentialRevisionHash::getTypes(); foreach ($commit_hashes as $info) {