1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

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:
epriestley 2015-10-26 19:58:37 +00:00 committed by epriestley
parent 9c39493796
commit a0fba642b3
4 changed files with 73 additions and 3 deletions

View file

@ -58,6 +58,48 @@ final class DifferentialRevisionOperationController
$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()) {
// NOTE: The operation is locked to the current active diff, so if the
// revision is updated before the operation applies nothing sneaky
@ -65,8 +107,6 @@ final class DifferentialRevisionOperationController
$diff = $revision->getActiveDiff();
$op = new DrydockLandRepositoryOperation();
$operation = DrydockRepositoryOperation::initializeNewOperation($op)
->setAuthorPHID($viewer->getPHID())
->setObjectPHID($revision->getPHID())

View file

@ -1047,6 +1047,10 @@ final class DifferentialRevisionViewController extends DifferentialController {
$operations = id(new DrydockRepositoryOperationQuery())
->setViewer($viewer)
->withObjectPHIDs(array($revision->getPHID()))
->withOperationTypes(
array(
DrydockLandRepositoryOperation::OPCONST,
))
->withOperationStates(
array(
DrydockRepositoryOperation::STATE_WAIT,
@ -1058,7 +1062,16 @@ final class DifferentialRevisionViewController extends DifferentialController {
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())
->setHeaderText(pht('Active Operations'));

View file

@ -7,6 +7,7 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
private $objectPHIDs;
private $repositoryPHIDs;
private $operationStates;
private $operationTypes;
public function withIDs(array $ids) {
$this->ids = $ids;
@ -33,6 +34,11 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
return $this;
}
public function withOperationTypes(array $types) {
$this->operationTypes = $types;
return $this;
}
public function newResultObject() {
return new DrydockRepositoryOperation();
}
@ -139,6 +145,13 @@ final class DrydockRepositoryOperationQuery extends DrydockQuery {
$this->operationStates);
}
if ($this->operationTypes !== null) {
$where[] = qsprintf(
$conn,
'operationType IN (%Ls)',
$this->operationTypes);
}
return $where;
}

View file

@ -158,6 +158,10 @@ final class DrydockRepositoryOperation extends DrydockDAO
return false;
}
public function isDone() {
return ($this->getOperationState() === self::STATE_DONE);
}
public function getWorkingCopyMerges() {
return $this->getImplementation()->getWorkingCopyMerges(
$this);