Add an "Onto Branch" selector control to "Land Revision" dialog
Summary:
Ref T9952. This adds a typeahead so you can pick a branch to target.
It does not choose a default branch, the user must pick a branch explicitly.
Test Plan:
- Landed rGITTESTd587fada48fc to `master` (by typing "master").
- Landed rGITTEST86c339b2ef01 to `notmaster` (by typing "notmaster").
{F1020531}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9952
Differential Revision: https://secure.phabricator.com/D14733
This commit is contained in:
@@ -27,39 +27,90 @@ final class DifferentialRevisionOperationController
|
|||||||
->addCancelButton($detail_uri);
|
->addCancelButton($detail_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$diff = $revision->getActiveDiff();
|
||||||
|
$repository = $revision->getRepository();
|
||||||
|
|
||||||
|
$ref_types = array(
|
||||||
|
PhabricatorRepositoryRefCursor::TYPE_BRANCH,
|
||||||
|
);
|
||||||
|
|
||||||
|
$e_ref = true;
|
||||||
|
|
||||||
|
$errors = array();
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
// NOTE: The operation is locked to the current active diff, so if the
|
|
||||||
// revision is updated before the operation applies nothing sneaky
|
|
||||||
// occurs.
|
|
||||||
|
|
||||||
$diff = $revision->getActiveDiff();
|
$ref_phid = head($request->getArr('refPHIDs'));
|
||||||
$repository = $revision->getRepository();
|
if (!strlen($ref_phid)) {
|
||||||
|
$e_ref = pht('Required');
|
||||||
|
$errors[] = pht(
|
||||||
|
'You must select a branch to land this revision onto.');
|
||||||
|
} else {
|
||||||
|
$ref = id(new PhabricatorRepositoryRefCursorQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withPHIDs(array($ref_phid))
|
||||||
|
->withRepositoryPHIDs(array($repository->getPHID()))
|
||||||
|
->withRefTypes($ref_types)
|
||||||
|
->executeOne();
|
||||||
|
if (!$ref) {
|
||||||
|
$e_ref = pht('Invalid');
|
||||||
|
$errors[] = pht(
|
||||||
|
'You must select a branch from this repository to land this '.
|
||||||
|
'revision onto.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$operation = DrydockRepositoryOperation::initializeNewOperation($op)
|
if (!$errors) {
|
||||||
->setAuthorPHID($viewer->getPHID())
|
// NOTE: The operation is locked to the current active diff, so if the
|
||||||
->setObjectPHID($revision->getPHID())
|
// revision is updated before the operation applies nothing sneaky
|
||||||
->setRepositoryPHID($repository->getPHID())
|
// occurs.
|
||||||
->setRepositoryTarget('branch:master')
|
|
||||||
->setProperty('differential.diffPHID', $diff->getPHID());
|
|
||||||
|
|
||||||
$operation->save();
|
$target = 'branch:'.$ref->getRefName();
|
||||||
$operation->scheduleUpdate();
|
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())
|
$operation = DrydockRepositoryOperation::initializeNewOperation($op)
|
||||||
->setURI($detail_uri);
|
->setAuthorPHID($viewer->getPHID())
|
||||||
|
->setObjectPHID($revision->getPHID())
|
||||||
|
->setRepositoryPHID($repository->getPHID())
|
||||||
|
->setRepositoryTarget($target)
|
||||||
|
->setProperty('differential.diffPHID', $diff->getPHID());
|
||||||
|
|
||||||
|
$operation->save();
|
||||||
|
$operation->scheduleUpdate();
|
||||||
|
|
||||||
|
return id(new AphrontRedirectResponse())
|
||||||
|
->setURI($detail_uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->newDialog()
|
$ref_datasource = id(new DiffusionRefDatasource())
|
||||||
->setTitle(pht('Land Revision'))
|
->setParameters(
|
||||||
->appendParagraph(
|
array(
|
||||||
|
'repositoryPHIDs' => array($repository->getPHID()),
|
||||||
|
'refTypes' => $ref_types,
|
||||||
|
));
|
||||||
|
|
||||||
|
$form = id(new AphrontFormView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->appendRemarkupInstructions(
|
||||||
pht(
|
pht(
|
||||||
'In theory, this will do approximately what `arc land` would do. '.
|
'In theory, this will do approximately what `arc land` would do. '.
|
||||||
'In practice, that is almost certainly not what it will actually '.
|
'In practice, you will have a riveting adventure instead.'))
|
||||||
'do.'))
|
->appendControl(
|
||||||
->appendParagraph(
|
id(new AphrontFormTokenizerControl())
|
||||||
|
->setLabel(pht('Onto Branch'))
|
||||||
|
->setName('refPHIDs')
|
||||||
|
->setLimit(1)
|
||||||
|
->setError($e_ref)
|
||||||
|
->setDatasource($ref_datasource))
|
||||||
|
->appendRemarkupInstructions(
|
||||||
pht(
|
pht(
|
||||||
'THIS FEATURE IS EXPERIMENTAL AND DANGEROUS! USE IT AT YOUR '.
|
'(WARNING) THIS FEATURE IS EXPERIMENTAL AND DANGEROUS! USE IT AT '.
|
||||||
'OWN RISK!'))
|
'YOUR OWN RISK!'));
|
||||||
|
|
||||||
|
return $this->newDialog()
|
||||||
|
->setWidth(AphrontDialogView::WIDTH_FORM)
|
||||||
|
->setTitle(pht('Land Revision'))
|
||||||
|
->setErrors($errors)
|
||||||
|
->appendForm($form)
|
||||||
->addCancelButton($detail_uri)
|
->addCancelButton($detail_uri)
|
||||||
->addSubmitButton(pht('Mutate Repository Unpredictably'));
|
->addSubmitButton(pht('Mutate Repository Unpredictably'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ final class PhabricatorRepositoryRefCursorPHIDType
|
|||||||
return pht('Repository Ref');
|
return pht('Repository Ref');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTypeIcon() {
|
||||||
|
return 'fa-code-fork';
|
||||||
|
}
|
||||||
|
|
||||||
public function newObject() {
|
public function newObject() {
|
||||||
return new PhabricatorRepositoryRefCursor();
|
return new PhabricatorRepositoryRefCursor();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user