From 6baeda8aade33697580b720d5484a68e45b75f0a Mon Sep 17 00:00:00 2001 From: tuomaspelkonen Date: Wed, 20 Apr 2011 15:29:02 -0700 Subject: [PATCH] Added a conduit method for getting all the diffs for a revision. Summary: Loading all diffs for a differential revision is needed by at least perflab. Test Plan: Created a simple script that queried the conduit and made sure that it returned correct values. Reviewed By: jungejason Reviewers: jungejason CC: epriestley, jungejason Differential Revision: 155 --- src/__phutil_library_map__.php | 2 + ...uitAPI_differential_getalldiffs_Method.php | 60 +++++++++++++++++++ .../differential/getalldiffs/__init__.php | 15 +++++ 3 files changed, 77 insertions(+) create mode 100644 src/applications/conduit/method/differential/getalldiffs/ConduitAPI_differential_getalldiffs_Method.php create mode 100644 src/applications/conduit/method/differential/getalldiffs/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8e3bd588ce..0313f14bac 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -78,6 +78,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff', 'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision', 'ConduitAPI_differential_find_Method' => 'applications/conduit/method/differential/find', + 'ConduitAPI_differential_getalldiffs_Method' => 'applications/conduit/method/differential/getalldiffs', 'ConduitAPI_differential_getcommitmessage_Method' => 'applications/conduit/method/differential/getcommitmessage', 'ConduitAPI_differential_getcommitpaths_Method' => 'applications/conduit/method/differential/getcommitpaths', 'ConduitAPI_differential_getdiff_Method' => 'applications/conduit/method/differential/getdiff', @@ -525,6 +526,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod', + 'ConduitAPI_differential_getalldiffs_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/method/differential/getalldiffs/ConduitAPI_differential_getalldiffs_Method.php b/src/applications/conduit/method/differential/getalldiffs/ConduitAPI_differential_getalldiffs_Method.php new file mode 100644 index 0000000000..93eb01d22b --- /dev/null +++ b/src/applications/conduit/method/differential/getalldiffs/ConduitAPI_differential_getalldiffs_Method.php @@ -0,0 +1,60 @@ + 'required list', + ); + } + + public function defineReturnType() { + return 'dict'; + } + + public function defineErrorTypes() { + return array(); + } + + protected function execute(ConduitAPIRequest $request) { + $results = array(); + $revision_ids = $request->getValue('revision_ids'); + + if (!$revision_ids) { + return $results; + } + + $diffs = id(new DifferentialDiff())->loadAllWhere( + 'revisionID IN (%Ld)', + $revision_ids); + + foreach ($diffs as $diff) { + $results[] = array( + 'revision_id' => $diff->getRevisionID(), + 'diff_id' => $diff->getID(), + ); + } + + return $results; + } +} diff --git a/src/applications/conduit/method/differential/getalldiffs/__init__.php b/src/applications/conduit/method/differential/getalldiffs/__init__.php new file mode 100644 index 0000000000..63152910d7 --- /dev/null +++ b/src/applications/conduit/method/differential/getalldiffs/__init__.php @@ -0,0 +1,15 @@ +