1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Enable updating task->revision assoc

Summary: add a conduit method to enable querying revisions' phid from
their revision_IDs, and another one to update the task->revision assoc.

Test Plan: for querying revision_phid method, tested empty, one, and two
revisions in the query. For the one to update the task->revision assoc,
I have another diff in facebook which verified it add and remove assoc
correctly.

Reviewers: tuomaspelkonen, epriestley

CC:

Differential Revision: 165
This commit is contained in:
jungejason 2011-04-21 18:47:04 -07:00
parent afedb711d9
commit a9e2e51b98
6 changed files with 106 additions and 4 deletions

View file

@ -88,6 +88,7 @@ phutil_register_library_map(array(
'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_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision', 'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision',
'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'applications/conduit/method/differential/updatetaskrevisionassoc',
'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits', 'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits',
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload', 'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners', 'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners',
@ -539,6 +540,7 @@ phutil_register_library_map(array(
'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod',
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod',
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod', 'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod',
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod', 'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod',

View file

@ -83,7 +83,7 @@ class PhabricatorConduitConsoleController
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel($param) ->setLabel($param)
->setName("params[{$param}]") ->setName("params[{$param}]")
->setCaption($desc)); ->setCaption(phutil_escape_html($desc)));
} }
$form $form

View file

@ -34,7 +34,7 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
return array( return array(
'query' => 'required enum<'.$types.'>', 'query' => 'required enum<'.$types.'>',
'guids' => 'required nonempty list<phid>', 'guids' => 'required nonempty list<guids>',
); );
} }
@ -49,11 +49,11 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
protected function execute(ConduitAPIRequest $request) { protected function execute(ConduitAPIRequest $request) {
$query = $request->getValue('query'); $query = $request->getValue('query');
$phids = $request->getValue('guids'); $guids = $request->getValue('guids');
$revisions = id(new DifferentialRevisionListData( $revisions = id(new DifferentialRevisionListData(
$query, $query,
(array)$phids)) (array)$guids))
->loadRevisions(); ->loadRevisions();
$results = array(); $results = array();
@ -64,6 +64,7 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
} }
$results[] = array( $results[] = array(
'id' => $revision->getID(), 'id' => $revision->getID(),
'phid' => $revision->getPHID(),
'name' => $revision->getTitle(), 'name' => $revision->getTitle(),
'statusName' => DifferentialRevisionStatus::getNameForRevisionStatus( 'statusName' => DifferentialRevisionStatus::getNameForRevisionStatus(
$revision->getStatus()), $revision->getStatus()),

View file

@ -0,0 +1,71 @@
<?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_updatetaskrevisionassoc_Method
extends ConduitAPIMethod {
public function getMethodDescription() {
return "Given a task together with its original and new associated ".
"revisions, update the revisions for their attached_tasks.";
}
public function defineParamTypes() {
return array(
'task_phid' => 'required nonempty string',
'orig_rev_phids' => 'required list<string>',
'new_rev_phids' => 'required list<string>',
);
}
public function defineReturnType() {
return 'void';
}
public function defineErrorTypes() {
return array(
'ERR_NO_TASKATTACHER_DEFINED' => 'No task attacher defined.',
);
}
protected function execute(ConduitAPIRequest $request) {
$task_phid = $request->getValue('task_phid');
$orig_rev_phids = $request->getValue('orig_rev_phids');
if (empty($orig_rev_phids)) {
$orig_rev_phids = array();
}
$new_rev_phids = $request->getValue('new_rev_phids');
if (empty($new_rev_phids)) {
$new_rev_phids = array();
}
$task_class = PhabricatorEnv::getEnvConfig(
'differential.attach-task-class');
if (!$task_class) {
throw new ConduitException('ERR_NO_TASKATTACHER_DEFINED');
}
PhutilSymbolLoader::loadClass($task_class);
$task_attacher = newv($task_class, array());
$task_attacher->updateTaskRevisionAssoc(
$task_phid,
$orig_rev_phids,
$new_rev_phids);
}
}

View file

@ -0,0 +1,17 @@
<?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', 'infrastructure/env');
phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils');
phutil_require_source('ConduitAPI_differential_updatetaskrevisionassoc_Method.php');

View file

@ -26,4 +26,15 @@ abstract class DifferentialTasksAttacher {
$user_phid, $user_phid,
DifferentialRevision $revision, DifferentialRevision $revision,
array $task_ids); array $task_ids);
/**
* This method will be called with a task and its original and new
* associated revisions. Implementation of this method should update
* the affected revisions to maintain the new associations.
*/
abstract public function updateTaskRevisionAssoc(
$task_phid,
array $orig_rev_phids,
array $new_rev_phids);
} }