Details
Details
I'm giving this a try:
<?php require_once dirname(__FILE__).'/scripts/__init_script__.php'; $yelirekim = (new PhabricatorPeopleQuery) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withUsernames(['yelirekim']) ->executeOne(); $thing = (new ConduitCall('differential.updaterevision', [ 'id' => 15, 'diffid' => 24, 'fields' => [ 'phabricator:depends-on' => ['PHID-DREV-ovtaojecgkoims6zrui5'], ], ])) ->setUser($yelirekim) ->execute(); var_dump($thing);
The call doesn't error out, but it's not actually updating anything either.
Answers
Answers
You may be able to post a comment that says "Depends on X".
Likely no real way to do it via the API until after T5873 (general Conduit edge support).
This is totally not advised for you to use at all but if you for whatever reason really want to...
<?php final class EditRevisionDependenciesAPIMethod extends DifferentialConduitAPIMethod { public function getAPIMethodName() { return 'differential.editdependencies'; } public function getMethodDescription() { return pht('Edit the dependencies for differential revisions.'); } protected function defineParamTypes() { return [ 'revisionPHID' => 'required id', 'dependsOnRevisionPHIDs' => 'optional list<phid>', ]; } protected function defineReturnType() { return 'nonempty dict'; } protected function defineErrorTypes() { return [ 'ERR_GRAPH_CYCLE' => pht( 'The relationships between objects described in this request would creates a cycle in '. 'their dependency graph.'), 'ERR_BAD_REVISION' => pht( 'The specified revision PHID does not correspond to an existing differential revision.'), ]; } protected function execute(ConduitAPIRequest $request) { $user = $request->getUser(); $phid = $request->getValue('revisionPHID'); $attach_type = DifferentialRevisionPHIDType::TYPECONST; $action = PhabricatorSearchAttachController::ACTION_DEPENDENCIES; $revision = (new DifferentialRevisionQuery) ->setViewer($user) ->withPHIDs([$phid]) ->needRelationships(true) ->executeOne(); if (!$revision) { throw new ConduitException('ERR_BAD_REVISION'); } $edge_type = DifferentialRevisionDependsOnRevisionEdgeType::EDGECONST; $phids = $request->getValue('dependsOnRevisionPHIDs', []); $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $phid, $edge_type); $add_phids = $phids; $rem_phids = array_diff($old_phids, $add_phids); $txn_editor = $revision->getApplicationTransactionEditor() ->setActor($user) ->setContentSourceFromConduitRequest($request) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true); $txn_template = $revision->getApplicationTransactionTemplate() ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $edge_type) ->setNewValue([ '+' => array_fuse($add_phids), '-' => array_fuse($rem_phids), ]); try { $txn_editor->applyTransactions( $revision->getApplicationTransactionObject(), [$txn_template]); } catch (PhabricatorEdgeCycleException $ex) { throw new ConduitException('ERR_GRAPH_CYCLE'); } return [ 'revision' => [ 'id' => $revision->getID(), 'phid' => $revision->getPHID(), 'dependencies' => $phids, ], 'edits' => [ 'oldDependencies' => $old_phids, 'newDependencies' => $add_phids, 'removedDependencies' => $rem_phids, ], ]; } }
New Answer
New Answer