2015-10-14 00:46:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialRevisionOperationController
|
|
|
|
extends DifferentialController {
|
|
|
|
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$id = $request->getURIData('id');
|
|
|
|
|
|
|
|
$revision = id(new DifferentialRevisionQuery())
|
|
|
|
->withIDs(array($id))
|
|
|
|
->setViewer($viewer)
|
2015-10-14 00:46:30 +02:00
|
|
|
->needActiveDiffs(true)
|
2015-10-14 00:46:12 +02:00
|
|
|
->executeOne();
|
|
|
|
if (!$revision) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$detail_uri = "/D{$id}";
|
|
|
|
|
2015-10-26 20:58:37 +01:00
|
|
|
$op = new DrydockLandRepositoryOperation();
|
2015-10-27 19:51:59 +01:00
|
|
|
$barrier = $op->getBarrierToLanding($viewer, $revision);
|
|
|
|
if ($barrier) {
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle($barrier['title'])
|
|
|
|
->appendParagraph($barrier['body'])
|
|
|
|
->addCancelButton($detail_uri);
|
2015-10-26 20:58:37 +01:00
|
|
|
}
|
|
|
|
|
2015-10-14 00:46:12 +02:00
|
|
|
if ($request->isFormPost()) {
|
2015-10-14 00:46:30 +02:00
|
|
|
// 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();
|
2015-10-27 19:51:59 +01:00
|
|
|
$repository = $revision->getRepository();
|
2015-10-14 00:46:30 +02:00
|
|
|
|
2015-10-14 00:46:12 +02:00
|
|
|
$operation = DrydockRepositoryOperation::initializeNewOperation($op)
|
|
|
|
->setAuthorPHID($viewer->getPHID())
|
|
|
|
->setObjectPHID($revision->getPHID())
|
|
|
|
->setRepositoryPHID($repository->getPHID())
|
2015-10-14 00:46:30 +02:00
|
|
|
->setRepositoryTarget('branch:master')
|
|
|
|
->setProperty('differential.diffPHID', $diff->getPHID());
|
2015-10-14 00:46:12 +02:00
|
|
|
|
|
|
|
$operation->save();
|
|
|
|
$operation->scheduleUpdate();
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI($detail_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Land Revision'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'In theory, this will do approximately what `arc land` would do. '.
|
|
|
|
'In practice, that is almost certainly not what it will actually '.
|
|
|
|
'do.'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'THIS FEATURE IS EXPERIMENTAL AND DANGEROUS! USE IT AT YOUR '.
|
|
|
|
'OWN RISK!'))
|
|
|
|
->addCancelButton($detail_uri)
|
|
|
|
->addSubmitButton(pht('Mutate Repository Unpredictably'));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|