2012-06-20 21:35:04 +02:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class DifferentialCreateRawDiffConduitAPIMethod
|
|
|
|
extends DifferentialConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'differential.createrawdiff';
|
|
|
|
}
|
2012-06-20 21:35:04 +02:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Create a new Differential diff from a raw diff source.');
|
2012-06-20 21:35:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function defineParamTypes() {
|
|
|
|
return array(
|
|
|
|
'diff' => 'required string',
|
2014-05-10 03:06:41 +02:00
|
|
|
'repositoryPHID' => 'optional string',
|
2014-11-19 21:16:07 +01:00
|
|
|
'viewPolicy' => 'optional string',
|
2012-06-20 21:35:04 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineReturnType() {
|
|
|
|
return 'nonempty dict';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineErrorTypes() {
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
2014-05-10 03:06:41 +02:00
|
|
|
$viewer = $request->getUser();
|
2012-06-20 21:35:04 +02:00
|
|
|
$raw_diff = $request->getValue('diff');
|
|
|
|
|
2014-05-10 03:06:41 +02:00
|
|
|
$repository_phid = $request->getValue('repositoryPHID');
|
|
|
|
if ($repository_phid) {
|
|
|
|
$repository = id(new PhabricatorRepositoryQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withPHIDs(array($repository_phid))
|
|
|
|
->executeOne();
|
|
|
|
if (!$repository) {
|
|
|
|
throw new Exception(
|
|
|
|
pht('No such repository "%s"!', $repository_phid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-20 21:35:04 +02:00
|
|
|
$parser = new ArcanistDiffParser();
|
|
|
|
$changes = $parser->parseDiff($raw_diff);
|
2014-11-19 21:16:07 +01:00
|
|
|
$diff = DifferentialDiff::newFromRawChanges($viewer, $changes);
|
2012-06-20 21:35:04 +02:00
|
|
|
|
2014-11-19 00:32:23 +01:00
|
|
|
$diff_data_dict = array(
|
|
|
|
'creationMethod' => 'web',
|
|
|
|
'authorPHID' => $viewer->getPHID(),
|
|
|
|
'repositoryPHID' => $repository_phid,
|
|
|
|
'lintStatus' => DifferentialLintStatus::LINT_SKIP,
|
|
|
|
'unitStatus' => DifferentialUnitStatus::UNIT_SKIP,);
|
2012-06-20 21:35:04 +02:00
|
|
|
|
2014-11-19 00:32:23 +01:00
|
|
|
$xactions = array(id(new DifferentialTransaction())
|
|
|
|
->setTransactionType(DifferentialDiffTransaction::TYPE_DIFF_CREATE)
|
|
|
|
->setNewValue($diff_data_dict),);
|
2014-05-10 03:06:41 +02:00
|
|
|
|
2014-11-19 21:16:07 +01:00
|
|
|
if ($request->getValue('viewPolicy')) {
|
|
|
|
$xactions[] = id(new DifferentialTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
|
|
|
->setNewValue($request->getValue('viewPolicy'));
|
|
|
|
}
|
|
|
|
|
2014-08-20 23:26:29 +02:00
|
|
|
id(new DifferentialDiffEditor())
|
|
|
|
->setActor($viewer)
|
2014-11-19 00:32:23 +01:00
|
|
|
->setContentSourceFromConduitRequest($request)
|
2014-12-01 21:13:04 +01:00
|
|
|
->setContinueOnNoEffect(true)
|
Differential - refine selecting a repository diff --> revision workflow
Summary: Fixes T6200. Ref T6237. When creating a diff from the web view, allow the user to select the repository at that time. When viewing a diff that has no associated revision and then creating a revision, pass along the repository phid to the create revision controller. Within the create revision controller, default the repository selector to this repository phid. Finally, in the editor, stop aggressively resetting the repository phid for every TYPE_UPDATE; rather, do so if its not a new object -- the diff should reign supreme in that case -- or if there's no repository -- let the diff be the guide.
Test Plan:
- made a diff with an associated repo, made a revision from the diff, saw the associated repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo to nothing and it stuck on save!
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T6237, T6200
Differential Revision: https://secure.phabricator.com/D10872
2014-11-19 20:11:09 +01:00
|
|
|
->setLookupRepository(false) // respect user choice
|
2014-11-19 00:32:23 +01:00
|
|
|
->applyTransactions($diff, $xactions);
|
2012-06-20 21:35:04 +02:00
|
|
|
|
|
|
|
return $this->buildDiffInfoDictionary($diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|