mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
aa6e788f36
Summary: Ref T12074. The "v3" API methods (`*.search`, `*.edit`) are currently marked as "unstable", but they're pretty stable and essentially all new code should be using them. Although these methods are seeing some changes, almost all changes are additive (support for new constraints or attachemnts) and do not break backward compatibility. We have no major, compatibility-breaking changes planned. I don't want to mark the older methods "deprecated" yet since `arc` still uses a lot of them and there are some capabilities not yet available on the v3 methods, but introduce a new "frozen" status with pointers to the new methods. Overall, this should gently push users toward the newer methods. Test Plan: {F2325323} Reviewers: chad Reviewed By: chad Maniphest Tasks: T12074 Differential Revision: https://secure.phabricator.com/D17158
89 lines
2.4 KiB
PHP
89 lines
2.4 KiB
PHP
<?php
|
|
|
|
final class DifferentialUpdateRevisionConduitAPIMethod
|
|
extends DifferentialConduitAPIMethod {
|
|
|
|
public function getAPIMethodName() {
|
|
return 'differential.updaterevision';
|
|
}
|
|
|
|
public function getMethodDescription() {
|
|
return pht('Update a Differential revision.');
|
|
}
|
|
|
|
public function getMethodStatus() {
|
|
return self::METHOD_STATUS_FROZEN;
|
|
}
|
|
|
|
public function getMethodStatusDescription() {
|
|
return pht(
|
|
'This method is frozen and will eventually be deprecated. New code '.
|
|
'should use "differential.revision.edit" instead.');
|
|
}
|
|
|
|
protected function defineParamTypes() {
|
|
return array(
|
|
'id' => 'required revisionid',
|
|
'diffid' => 'required diffid',
|
|
'fields' => 'required dict',
|
|
'message' => 'required string',
|
|
);
|
|
}
|
|
|
|
protected function defineReturnType() {
|
|
return 'nonempty dict';
|
|
}
|
|
|
|
protected function defineErrorTypes() {
|
|
return array(
|
|
'ERR_BAD_DIFF' => pht('Bad diff ID.'),
|
|
'ERR_BAD_REVISION' => pht('Bad revision ID.'),
|
|
'ERR_WRONG_USER' => pht('You are not the author of this revision.'),
|
|
'ERR_CLOSED' => pht('This revision has already been closed.'),
|
|
);
|
|
}
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
$viewer = $request->getUser();
|
|
|
|
$diff = id(new DifferentialDiffQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($request->getValue('diffid')))
|
|
->executeOne();
|
|
if (!$diff) {
|
|
throw new ConduitException('ERR_BAD_DIFF');
|
|
}
|
|
|
|
$revision = id(new DifferentialRevisionQuery())
|
|
->setViewer($request->getUser())
|
|
->withIDs(array($request->getValue('id')))
|
|
->needReviewerStatus(true)
|
|
->needActiveDiffs(true)
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->executeOne();
|
|
if (!$revision) {
|
|
throw new ConduitException('ERR_BAD_REVISION');
|
|
}
|
|
|
|
if ($revision->getStatus() == ArcanistDifferentialRevisionStatus::CLOSED) {
|
|
throw new ConduitException('ERR_CLOSED');
|
|
}
|
|
|
|
$this->applyFieldEdit(
|
|
$request,
|
|
$revision,
|
|
$diff,
|
|
$request->getValue('fields', array()),
|
|
$request->getValue('message'));
|
|
|
|
return array(
|
|
'revisionid' => $revision->getID(),
|
|
'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()),
|
|
);
|
|
}
|
|
|
|
}
|