mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
differential.createrevision
Summary: Conduit method. Test Plan: Meta Reviewers: CC: Differential Revision: 23
This commit is contained in:
parent
787eb778b1
commit
5817840894
5 changed files with 135 additions and 56 deletions
|
@ -27,7 +27,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'aphront-error-view-css' =>
|
'aphront-error-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/5ea93eb4/rsrc/css/aphront/error-view.css',
|
'uri' => '/res/19b27527/rsrc/css/aphront/error-view.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -36,7 +36,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'aphront-form-view-css' =>
|
'aphront-form-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/d88ebe30/rsrc/css/aphront/form-view.css',
|
'uri' => '/res/8aaef437/rsrc/css/aphront/form-view.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -407,7 +407,7 @@ celerity_register_resource_map(array(
|
||||||
), array (
|
), array (
|
||||||
'packages' =>
|
'packages' =>
|
||||||
array (
|
array (
|
||||||
'65be8bf1' =>
|
'8cbb3650' =>
|
||||||
array (
|
array (
|
||||||
'name' => 'core.pkg.css',
|
'name' => 'core.pkg.css',
|
||||||
'symbols' =>
|
'symbols' =>
|
||||||
|
@ -426,7 +426,7 @@ celerity_register_resource_map(array(
|
||||||
11 => 'phabricator-remarkup-css',
|
11 => 'phabricator-remarkup-css',
|
||||||
12 => 'syntax-highlighting-css',
|
12 => 'syntax-highlighting-css',
|
||||||
),
|
),
|
||||||
'uri' => '/res/pkg/65be8bf1/core.pkg.css',
|
'uri' => '/res/pkg/8cbb3650/core.pkg.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
),
|
),
|
||||||
'4b8af7b5' =>
|
'4b8af7b5' =>
|
||||||
|
@ -463,19 +463,19 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'reverse' =>
|
'reverse' =>
|
||||||
array (
|
array (
|
||||||
'phabricator-core-css' => '65be8bf1',
|
'phabricator-core-css' => '8cbb3650',
|
||||||
'phabricator-core-buttons-css' => '65be8bf1',
|
'phabricator-core-buttons-css' => '8cbb3650',
|
||||||
'phabricator-standard-page-view' => '65be8bf1',
|
'phabricator-standard-page-view' => '8cbb3650',
|
||||||
'aphront-dialog-view-css' => '65be8bf1',
|
'aphront-dialog-view-css' => '8cbb3650',
|
||||||
'aphront-form-view-css' => '65be8bf1',
|
'aphront-form-view-css' => '8cbb3650',
|
||||||
'aphront-panel-view-css' => '65be8bf1',
|
'aphront-panel-view-css' => '8cbb3650',
|
||||||
'aphront-side-nav-view-css' => '65be8bf1',
|
'aphront-side-nav-view-css' => '8cbb3650',
|
||||||
'aphront-table-view-css' => '65be8bf1',
|
'aphront-table-view-css' => '8cbb3650',
|
||||||
'aphront-tokenizer-control-css' => '65be8bf1',
|
'aphront-tokenizer-control-css' => '8cbb3650',
|
||||||
'aphront-typeahead-control-css' => '65be8bf1',
|
'aphront-typeahead-control-css' => '8cbb3650',
|
||||||
'phabricator-directory-css' => '65be8bf1',
|
'phabricator-directory-css' => '8cbb3650',
|
||||||
'phabricator-remarkup-css' => '65be8bf1',
|
'phabricator-remarkup-css' => '8cbb3650',
|
||||||
'syntax-highlighting-css' => '65be8bf1',
|
'syntax-highlighting-css' => '8cbb3650',
|
||||||
'differential-core-view-css' => '4b8af7b5',
|
'differential-core-view-css' => '4b8af7b5',
|
||||||
'differential-changeset-view-css' => '4b8af7b5',
|
'differential-changeset-view-css' => '4b8af7b5',
|
||||||
'differential-revision-detail-css' => '4b8af7b5',
|
'differential-revision-detail-css' => '4b8af7b5',
|
||||||
|
|
|
@ -65,6 +65,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPIRequest' => 'applications/conduit/protocol/request',
|
'ConduitAPIRequest' => 'applications/conduit/protocol/request',
|
||||||
'ConduitAPI_conduit_connect_Method' => 'applications/conduit/method/conduit/connect',
|
'ConduitAPI_conduit_connect_Method' => 'applications/conduit/method/conduit/connect',
|
||||||
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
||||||
|
'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision',
|
||||||
'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage',
|
'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage',
|
||||||
'ConduitAPI_differential_setdiffproperty_Method' => 'applications/conduit/method/differential/setdiffproperty',
|
'ConduitAPI_differential_setdiffproperty_Method' => 'applications/conduit/method/differential/setdiffproperty',
|
||||||
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
|
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
|
||||||
|
@ -271,6 +272,7 @@ phutil_register_library_map(array(
|
||||||
'CelerityResourceController' => 'AphrontController',
|
'CelerityResourceController' => 'AphrontController',
|
||||||
'ConduitAPI_conduit_connect_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_conduit_connect_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
||||||
|
'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ConduitAPI_differential_createrevision_Method extends ConduitAPIMethod {
|
||||||
|
|
||||||
|
public function getMethodDescription() {
|
||||||
|
return "Create a new Differential revision.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineParamTypes() {
|
||||||
|
return array(
|
||||||
|
'diffid' => 'required diffid',
|
||||||
|
'fields' => 'required dict',
|
||||||
|
'user' => 'required guid',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineReturnType() {
|
||||||
|
return 'nonempty dict';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineErrorTypes() {
|
||||||
|
return array(
|
||||||
|
'ERR_BAD_DIFF' => 'Bad diff ID.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
|
$fields = $request->getValue('fields');
|
||||||
|
|
||||||
|
$diff = id(new DifferentialDiff())->load($request->getValue('diffid'));
|
||||||
|
if (!$diff) {
|
||||||
|
throw new ConduitException('ERR_BAD_DIFF');
|
||||||
|
}
|
||||||
|
|
||||||
|
$revision = DifferentialRevisionEditor::newRevisionFromConduitWithDiff(
|
||||||
|
$fields,
|
||||||
|
$diff,
|
||||||
|
$request->getValue('user')); // TODO: Should be authoritative
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'revisionid' => $revision->getID(),
|
||||||
|
'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/editor/revision');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('ConduitAPI_differential_createrevision_Method.php');
|
|
@ -37,6 +37,42 @@ class DifferentialRevisionEditor {
|
||||||
$this->actorPHID = $actor_phid;
|
$this->actorPHID = $actor_phid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function newRevisionFromConduitWithDiff(
|
||||||
|
array $fields,
|
||||||
|
DifferentialDiff $diff,
|
||||||
|
$user_phid) {
|
||||||
|
|
||||||
|
$revision = new DifferentialRevision();
|
||||||
|
$revision->setPHID($revision->generatePHID());
|
||||||
|
|
||||||
|
$revision->setAuthorPHID($user_phid);
|
||||||
|
$revision->setStatus(DifferentialRevisionStatus::NEEDS_REVIEW);
|
||||||
|
|
||||||
|
$editor = new DifferentialRevisionEditor($revision, $user_phid);
|
||||||
|
|
||||||
|
$editor->copyFieldsFromConduit($fields);
|
||||||
|
|
||||||
|
$editor->addDiff($diff, null);
|
||||||
|
$editor->save();
|
||||||
|
|
||||||
|
return $revision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function copyFieldsFromConduit(array $fields) {
|
||||||
|
|
||||||
|
$revision = $this->revision;
|
||||||
|
|
||||||
|
$revision->setTitle((string)$fields['title']);
|
||||||
|
$revision->setSummary((string)$fields['summary']);
|
||||||
|
$revision->setTestPlan((string)$fields['testPlan']);
|
||||||
|
$revision->setBlameRevision((string)$fields['blameRevision']);
|
||||||
|
$revision->setRevertPlan((string)$fields['revertPlan']);
|
||||||
|
|
||||||
|
$this->setReviewers($fields['reviewerPHIDs']);
|
||||||
|
$this->setCCPHIDs($fields['ccPHIDs']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public static function newRevisionFromRawMessageWithDiff(
|
public static function newRevisionFromRawMessageWithDiff(
|
||||||
DifferentialRawMessage $message,
|
DifferentialRawMessage $message,
|
||||||
|
@ -72,29 +108,6 @@ class DifferentialRevisionEditor {
|
||||||
return $revision;
|
return $revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function newRevisionFromConduitWithDiff(
|
|
||||||
array $fields,
|
|
||||||
Diff $diff,
|
|
||||||
$user) {
|
|
||||||
|
|
||||||
$revision = new DifferentialRevision();
|
|
||||||
$revision->setPHID($revision->generatePHID());
|
|
||||||
|
|
||||||
$revision->setOwnerID($user);
|
|
||||||
$revision->setStatus(DifferentialRevisionStatus::NEEDS_REVIEW);
|
|
||||||
$revision->attachReviewers(array());
|
|
||||||
$revision->attachCCPHIDs(array());
|
|
||||||
|
|
||||||
$editor = new DifferentialRevisionEditor($revision, $user);
|
|
||||||
|
|
||||||
$editor->copyFieldFromConduit($fields);
|
|
||||||
|
|
||||||
$editor->addDiff($diff, null);
|
|
||||||
$editor->save();
|
|
||||||
|
|
||||||
return $revision;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static function copyFields(
|
public static function copyFields(
|
||||||
DifferentialRevisionEditor $editor,
|
DifferentialRevisionEditor $editor,
|
||||||
|
@ -114,22 +127,6 @@ class DifferentialRevisionEditor {
|
||||||
$editor->setCCPHIDs($message->getCCPHIDs());
|
$editor->setCCPHIDs($message->getCCPHIDs());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function copyFieldFromConduit(array $fields) {
|
|
||||||
|
|
||||||
$user = $this->actorPHID;
|
|
||||||
$revision = $this->revision;
|
|
||||||
|
|
||||||
$revision->setName($fields['title']);
|
|
||||||
$revision->setSummary($fields['summary']);
|
|
||||||
$revision->setTestPlan($fields['testPlan']);
|
|
||||||
$revision->setSVNBlameRevision($fields['blameRevision']);
|
|
||||||
$revision->setRevert($fields['revertPlan']);
|
|
||||||
$revision->setPlatformImpact($fields['platformImpact']);
|
|
||||||
$revision->setBugzillaID($fields['bugzillaID']);
|
|
||||||
|
|
||||||
$this->setReviewers($fields['reviewerGUIDs']);
|
|
||||||
$this->setCCPHIDs($fields['ccGUIDs']);
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function getRevision() {
|
public function getRevision() {
|
||||||
|
|
Loading…
Reference in a new issue