Differential D19835 Diff 47374 src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | public function generateNewValue($object, $value) { | ||||
return $actor->getPHID(); | return $actor->getPHID(); | ||||
} | } | ||||
public function applyInternalEffects($object, $value) { | public function applyInternalEffects($object, $value) { | ||||
$object->setAuthorPHID($value); | $object->setAuthorPHID($value); | ||||
} | } | ||||
protected function validateAction($object, PhabricatorUser $viewer) { | protected function validateAction($object, PhabricatorUser $viewer) { | ||||
if ($object->isClosed()) { | // If a revision has already landed, we generally want to discourage | ||||
// reopening and reusing it since this tends to create a big mess (users | |||||
// should create a new revision instead). Thus, we stop you from | |||||
// commandeering closed revisions. | |||||
// See PHI985. If the revision was abandoned, there's no peril in allowing | |||||
// the commandeer since the change (likely) never actually landed. So | |||||
// it's okay to commandeer abandoned revisions. | |||||
if ($object->isClosed() && !$object->isAbandoned()) { | |||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'You can not commandeer this revision because it has already '. | 'You can not commandeer this revision because it has already '. | ||||
'been closed. You can only commandeer open revisions.')); | 'been closed. You can only commandeer open or abandoned '. | ||||
'revisions.')); | |||||
} | } | ||||
if ($this->isViewerRevisionAuthor($object, $viewer)) { | if ($this->isViewerRevisionAuthor($object, $viewer)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'You can not commandeer this revision because you are already '. | 'You can not commandeer this revision because you are already '. | ||||
'the author.')); | 'the author.')); | ||||
} | } | ||||
Show All 24 Lines |