Show the oldest non-failing revision land operation, or the newest failure
Summary: Ref T182. - We just show the oldest operation right now, but we usually care about the oldest non-failure. - Only query for actual land operations when rendering the revision operations dialog (maybe eventually we'll show more stuff?). - For now, prevent multiple lands / repeated lands or queueing up lands while other lands are happening. Test Plan: Landed a revision. Tried to land it more / again. Reviewers: chad Reviewed By: chad Maniphest Tasks: T182 Differential Revision: https://secure.phabricator.com/D14338
This commit is contained in:
@@ -58,6 +58,48 @@ final class DifferentialRevisionOperationController
|
|||||||
$repository->getMonogram()));
|
$repository->getMonogram()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$op = new DrydockLandRepositoryOperation();
|
||||||
|
|
||||||
|
// Check for other operations. Eventually this should probably be more
|
||||||
|
// general (e.g., it's OK to land to multiple different branches
|
||||||
|
// simultaneously) but just put this in as a sanity check for now.
|
||||||
|
$other_operations = id(new DrydockRepositoryOperationQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withObjectPHIDs(array($revision->getPHID()))
|
||||||
|
->withOperationTypes(
|
||||||
|
array(
|
||||||
|
$op->getOperationConstant(),
|
||||||
|
))
|
||||||
|
->withOperationStates(
|
||||||
|
array(
|
||||||
|
DrydockRepositoryOperation::STATE_WAIT,
|
||||||
|
DrydockRepositoryOperation::STATE_WORK,
|
||||||
|
DrydockRepositoryOperation::STATE_DONE,
|
||||||
|
))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
if ($other_operations) {
|
||||||
|
$any_done = false;
|
||||||
|
foreach ($other_operations as $operation) {
|
||||||
|
if ($operation->isDone()) {
|
||||||
|
$any_done = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($any_done) {
|
||||||
|
return $this->rejectOperation(
|
||||||
|
$revision,
|
||||||
|
pht('Already Complete'),
|
||||||
|
pht('This revision has already landed.'));
|
||||||
|
} else {
|
||||||
|
return $this->rejectOperation(
|
||||||
|
$revision,
|
||||||
|
pht('Already In Flight'),
|
||||||
|
pht('This revision is already landing.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
// NOTE: The operation is locked to the current active diff, so if the
|
// NOTE: The operation is locked to the current active diff, so if the
|
||||||
// revision is updated before the operation applies nothing sneaky
|
// revision is updated before the operation applies nothing sneaky
|
||||||
@@ -65,8 +107,6 @@ final class DifferentialRevisionOperationController
|
|||||||
|
|
||||||
$diff = $revision->getActiveDiff();
|
$diff = $revision->getActiveDiff();
|
||||||
|
|
||||||
$op = new DrydockLandRepositoryOperation();
|
|
||||||
|
|
||||||
$operation = DrydockRepositoryOperation::initializeNewOperation($op)
|
$operation = DrydockRepositoryOperation::initializeNewOperation($op)
|
||||||
->setAuthorPHID($viewer->getPHID())
|
->setAuthorPHID($viewer->getPHID())
|
||||||
->setObjectPHID($revision->getPHID())
|
->setObjectPHID($revision->getPHID())
|
||||||
|
|||||||
@@ -1047,6 +1047,10 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||||||
$operations = id(new DrydockRepositoryOperationQuery())
|
$operations = id(new DrydockRepositoryOperationQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withObjectPHIDs(array($revision->getPHID()))
|
->withObjectPHIDs(array($revision->getPHID()))
|
||||||
|
->withOperationTypes(
|
||||||
|
array(
|
||||||
|
DrydockLandRepositoryOperation::OPCONST,
|
||||||
|
))
|
||||||
->withOperationStates(
|
->withOperationStates(
|
||||||
array(
|
array(
|
||||||
DrydockRepositoryOperation::STATE_WAIT,
|
DrydockRepositoryOperation::STATE_WAIT,
|
||||||
@@ -1058,7 +1062,16 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$operation = head(msort($operations, 'getID'));
|
$state_fail = DrydockRepositoryOperation::STATE_FAIL;
|
||||||
|
|
||||||
|
// We're going to show the oldest operation which hasn't failed, or the
|
||||||
|
// most recent failure if they're all failures.
|
||||||
|
$operations = msort($operations, 'getID');
|
||||||
|
foreach ($operations as $operation) {
|
||||||
|
if ($operation->getOperationState() != $state_fail) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$box_view = id(new PHUIObjectBoxView())
|
$box_view = id(new PHUIObjectBoxView())
|
||||||
->setHeaderText(pht('Active Operations'));
|
->setHeaderText(pht('Active Operations'));
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
|
|||||||
private $objectPHIDs;
|
private $objectPHIDs;
|
||||||
private $repositoryPHIDs;
|
private $repositoryPHIDs;
|
||||||
private $operationStates;
|
private $operationStates;
|
||||||
|
private $operationTypes;
|
||||||
|
|
||||||
public function withIDs(array $ids) {
|
public function withIDs(array $ids) {
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
@@ -33,6 +34,11 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withOperationTypes(array $types) {
|
||||||
|
$this->operationTypes = $types;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function newResultObject() {
|
public function newResultObject() {
|
||||||
return new DrydockRepositoryOperation();
|
return new DrydockRepositoryOperation();
|
||||||
}
|
}
|
||||||
@@ -139,6 +145,13 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
|
|||||||
$this->operationStates);
|
$this->operationStates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->operationTypes !== null) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn,
|
||||||
|
'operationType IN (%Ls)',
|
||||||
|
$this->operationTypes);
|
||||||
|
}
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ final class DrydockRepositoryOperation extends DrydockDAO
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isDone() {
|
||||||
|
return ($this->getOperationState() === self::STATE_DONE);
|
||||||
|
}
|
||||||
|
|
||||||
public function getWorkingCopyMerges() {
|
public function getWorkingCopyMerges() {
|
||||||
return $this->getImplementation()->getWorkingCopyMerges(
|
return $this->getImplementation()->getWorkingCopyMerges(
|
||||||
$this);
|
$this);
|
||||||
|
|||||||
Reference in New Issue
Block a user