@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.

Implement Commandeer action in ApplicationTransactions

Summary: Ref T2222. Implements Commandeer on the new stuff.

Test Plan:
{F117768}

{F117769}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222

Differential Revision: https://secure.phabricator.com/D8331

+58 -4
+54 -4
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 90 90 } 91 91 } 92 92 return false; 93 + case DifferentialAction::ACTION_CLAIM: 94 + $actor_phid = $this->getActor()->getPHID(); 95 + return ($actor_phid != $object->getAuthorPHID()); 93 96 } 94 97 } 95 98 ··· 145 148 case DifferentialAction::ACTION_CLOSE: 146 149 $object->setStatus(ArcanistDifferentialRevisionStatus::CLOSED); 147 150 break; 151 + case DifferentialAction::ACTION_CLAIM: 152 + $object->setAuthorPHID($this->getActor()->getPHID()); 153 + break; 148 154 default: 149 155 // TODO: For now, we're just shipping the rest of these through 150 156 // without acting on them. ··· 163 169 $results = parent::expandTransaction($object, $xaction); 164 170 switch ($xaction->getTransactionType()) { 165 171 case DifferentialTransaction::TYPE_ACTION: 172 + 173 + $actor_phid = $this->getActor()->getPHID(); 174 + $type_edge = PhabricatorTransactions::TYPE_EDGE; 175 + $edge_reviewer = PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER; 176 + 166 177 switch ($xaction->getNewValue()) { 178 + case DifferentialAction::ACTION_CLAIM: 179 + // If the user is commandeering, add the previous owner as a 180 + // reviewer and remove the actor. 181 + 182 + $edits = array( 183 + '-' => array( 184 + $actor_phid => $actor_phid, 185 + ), 186 + ); 187 + 188 + $owner_phid = $object->getAuthorPHID(); 189 + if ($owner_phid) { 190 + $reviewer = new DifferentialReviewer( 191 + $owner_phid, 192 + array( 193 + 'status' => DifferentialReviewerStatus::STATUS_ADDED, 194 + )); 195 + 196 + $edits['+'] = array( 197 + $owner_phid => array( 198 + 'data' => $reviewer->getEdgeData(), 199 + ), 200 + ); 201 + } 202 + 203 + $results[] = id(new DifferentialTransaction()) 204 + ->setTransactionType($type_edge) 205 + ->setMetadataValue('edge:type', $edge_reviewer) 206 + ->setIgnoreOnNoEffect(true) 207 + ->setNewValue($edits); 208 + 209 + break; 167 210 case DifferentialAction::ACTION_RESIGN: 168 211 // If the user is resigning, add a separate reviewer edit 169 212 // transaction which removes them as a reviewer. 170 - 171 - $actor_phid = $this->getActor()->getPHID(); 172 - $type_edge = PhabricatorTransactions::TYPE_EDGE; 173 - $edge_reviewer = PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER; 174 213 175 214 $results[] = id(new DifferentialTransaction()) 176 215 ->setTransactionType($type_edge) ··· 265 304 case DifferentialAction::ACTION_RESIGN: 266 305 // You can always resign from a revision if you're a reviewer. If you 267 306 // aren't, this is a no-op rather than invalid. 307 + break; 308 + 309 + case DifferentialAction::ACTION_CLAIM: 310 + // You can claim a revision if you're not the owner. If you are, this 311 + // is a no-op rather than invalid. 312 + 313 + if ($revision_status == $status_closed) { 314 + return pht( 315 + "You can not commandeer this revision because it has already been ". 316 + "closed."); 317 + } 268 318 break; 269 319 270 320 case DifferentialAction::ACTION_ABANDON:
+4
src/applications/differential/storage/DifferentialTransaction.php
··· 147 147 return pht( 148 148 'You can not resign from this revision because you are not '. 149 149 'a reviewer.'); 150 + case DifferentialAction::ACTION_CLAIM: 151 + return pht( 152 + 'You can not commandeer this revision because you already own '. 153 + 'it.'); 150 154 } 151 155 break; 152 156 }