From df49a6c721f96d6ab8ad6a6538b101d347fad0d1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 6 Feb 2011 14:00:32 -0800 Subject: [PATCH] differential.updaterevision Summary: Test Plan: meta Reviewers: CC: Differential Revision: 24 --- src/__phutil_library_map__.php | 2 + ...API_differential_updaterevision_Method.php | 70 +++++++++++++++++++ .../differential/updaterevision/__init__.php | 19 +++++ 3 files changed, 91 insertions(+) create mode 100644 src/applications/conduit/method/differential/updaterevision/ConduitAPI_differential_updaterevision_Method.php create mode 100644 src/applications/conduit/method/differential/updaterevision/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4179843da5..712d972c0f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -68,6 +68,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision', 'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage', 'ConduitAPI_differential_setdiffproperty_Method' => 'applications/conduit/method/differential/setdiffproperty', + 'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision', 'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload', 'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find', 'ConduitException' => 'applications/conduit/protocol/exception', @@ -275,6 +276,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod', + 'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', 'DarkConsoleController' => 'PhabricatorController', diff --git a/src/applications/conduit/method/differential/updaterevision/ConduitAPI_differential_updaterevision_Method.php b/src/applications/conduit/method/differential/updaterevision/ConduitAPI_differential_updaterevision_Method.php new file mode 100644 index 0000000000..0eeae59a66 --- /dev/null +++ b/src/applications/conduit/method/differential/updaterevision/ConduitAPI_differential_updaterevision_Method.php @@ -0,0 +1,70 @@ + 'required revisionid', + 'diffid' => 'required diffid', + 'fields' => 'required dict', + 'message' => 'required string', + ); + } + + public function defineReturnType() { + return 'nonempty dict'; + } + + public function defineErrorTypes() { + return array( + 'ERR_BAD_DIFF' => 'Bad diff ID.', + 'ERR_BAD_REVISION' => 'Bad revision ID.', + ); + } + + protected function execute(ConduitAPIRequest $request) { + $diff = id(new DifferentialDiff())->load($request->getValue('diffid')); + if (!$diff) { + throw new ConduitException('ERR_BAD_DIFF'); + } + + $revision = id(new DifferentialRevision())->load($request->getValue('id')); + + // TODO: verify owned, non-committed, etc. + + $editor = new DifferentialRevisionEditor( + $revision, + $revision->getAuthorPHID()); + $fields = $request->getValue('fields'); + $editor->copyFieldsFromConduit($fields); + + $editor->addDiff($diff, $request->getValue('message')); + $editor->save(); + + return array( + 'revisionid' => $revision->getID(), + 'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()), + ); + } + +} diff --git a/src/applications/conduit/method/differential/updaterevision/__init__.php b/src/applications/conduit/method/differential/updaterevision/__init__.php new file mode 100644 index 0000000000..7ed1c36973 --- /dev/null +++ b/src/applications/conduit/method/differential/updaterevision/__init__.php @@ -0,0 +1,19 @@ +