@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

epriestley and committed by
epriestley
a0fba642 9c394937

+73 -3
+42 -2
src/applications/differential/controller/DifferentialRevisionOperationController.php
··· 58 58 $repository->getMonogram())); 59 59 } 60 60 61 + $op = new DrydockLandRepositoryOperation(); 62 + 63 + // Check for other operations. Eventually this should probably be more 64 + // general (e.g., it's OK to land to multiple different branches 65 + // simultaneously) but just put this in as a sanity check for now. 66 + $other_operations = id(new DrydockRepositoryOperationQuery()) 67 + ->setViewer($viewer) 68 + ->withObjectPHIDs(array($revision->getPHID())) 69 + ->withOperationTypes( 70 + array( 71 + $op->getOperationConstant(), 72 + )) 73 + ->withOperationStates( 74 + array( 75 + DrydockRepositoryOperation::STATE_WAIT, 76 + DrydockRepositoryOperation::STATE_WORK, 77 + DrydockRepositoryOperation::STATE_DONE, 78 + )) 79 + ->execute(); 80 + 81 + if ($other_operations) { 82 + $any_done = false; 83 + foreach ($other_operations as $operation) { 84 + if ($operation->isDone()) { 85 + $any_done = true; 86 + break; 87 + } 88 + } 89 + 90 + if ($any_done) { 91 + return $this->rejectOperation( 92 + $revision, 93 + pht('Already Complete'), 94 + pht('This revision has already landed.')); 95 + } else { 96 + return $this->rejectOperation( 97 + $revision, 98 + pht('Already In Flight'), 99 + pht('This revision is already landing.')); 100 + } 101 + } 102 + 61 103 if ($request->isFormPost()) { 62 104 // NOTE: The operation is locked to the current active diff, so if the 63 105 // revision is updated before the operation applies nothing sneaky 64 106 // occurs. 65 107 66 108 $diff = $revision->getActiveDiff(); 67 - 68 - $op = new DrydockLandRepositoryOperation(); 69 109 70 110 $operation = DrydockRepositoryOperation::initializeNewOperation($op) 71 111 ->setAuthorPHID($viewer->getPHID())
+14 -1
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 1047 1047 $operations = id(new DrydockRepositoryOperationQuery()) 1048 1048 ->setViewer($viewer) 1049 1049 ->withObjectPHIDs(array($revision->getPHID())) 1050 + ->withOperationTypes( 1051 + array( 1052 + DrydockLandRepositoryOperation::OPCONST, 1053 + )) 1050 1054 ->withOperationStates( 1051 1055 array( 1052 1056 DrydockRepositoryOperation::STATE_WAIT, ··· 1058 1062 return null; 1059 1063 } 1060 1064 1061 - $operation = head(msort($operations, 'getID')); 1065 + $state_fail = DrydockRepositoryOperation::STATE_FAIL; 1066 + 1067 + // We're going to show the oldest operation which hasn't failed, or the 1068 + // most recent failure if they're all failures. 1069 + $operations = msort($operations, 'getID'); 1070 + foreach ($operations as $operation) { 1071 + if ($operation->getOperationState() != $state_fail) { 1072 + break; 1073 + } 1074 + } 1062 1075 1063 1076 $box_view = id(new PHUIObjectBoxView()) 1064 1077 ->setHeaderText(pht('Active Operations'));
+13
src/applications/drydock/query/DrydockRepositoryOperationQuery.php
··· 7 7 private $objectPHIDs; 8 8 private $repositoryPHIDs; 9 9 private $operationStates; 10 + private $operationTypes; 10 11 11 12 public function withIDs(array $ids) { 12 13 $this->ids = $ids; ··· 30 31 31 32 public function withOperationStates(array $states) { 32 33 $this->operationStates = $states; 34 + return $this; 35 + } 36 + 37 + public function withOperationTypes(array $types) { 38 + $this->operationTypes = $types; 33 39 return $this; 34 40 } 35 41 ··· 137 143 $conn, 138 144 'operationState IN (%Ls)', 139 145 $this->operationStates); 146 + } 147 + 148 + if ($this->operationTypes !== null) { 149 + $where[] = qsprintf( 150 + $conn, 151 + 'operationType IN (%Ls)', 152 + $this->operationTypes); 140 153 } 141 154 142 155 return $where;
+4
src/applications/drydock/storage/DrydockRepositoryOperation.php
··· 158 158 return false; 159 159 } 160 160 161 + public function isDone() { 162 + return ($this->getOperationState() === self::STATE_DONE); 163 + } 164 + 161 165 public function getWorkingCopyMerges() { 162 166 return $this->getImplementation()->getWorkingCopyMerges( 163 167 $this);