diff --git a/conf/default.conf.php b/conf/default.conf.php index e441e130da..8895942921 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -811,6 +811,10 @@ return array( // only the submitter can close a revision. 'differential.always-allow-close' => false, + // If you set this to true, any user can abandon any revision. If false, only + // the submitter can abandon a revision. + 'differential.always-allow-abandon' => false, + // If you set this to true, any user can reopen a revision so long as it has // been closed. This can be useful if a revision is accidentally closed or // if a developer changes his or her mind after closing a revision. If it is diff --git a/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php b/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php index a0c0f4e914..61832ae125 100644 --- a/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php +++ b/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php @@ -165,6 +165,17 @@ final class PhabricatorDifferentialConfigOptions "where the reviewer is often the actual committer can benefit ". "from turning this option to true. If false, only the submitter ". "can close a revision.")), + $this->newOption('differential.always-allow-abandon', 'bool', false) + ->setBoolOptions( + array( + pht('Allow any user'), + pht('Restrict to submitter'), + )) + ->setSummary(pht('Allows any user to abandon revisions.')) + ->setDescription( + pht( + 'If you set this to true, any user can abandon any revision. If '. + 'false, only the submitter can abandon a revision.')), $this->newOption('differential.allow-reopen', 'bool', false) ->setBoolOptions( array( diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php index c45b4197ac..f92014aeab 100644 --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -553,6 +553,8 @@ final class DifferentialRevisionViewController extends DifferentialController { $allow_self_accept = PhabricatorEnv::getEnvConfig( 'differential.allow-self-accept'); + $always_allow_abandon = PhabricatorEnv::getEnvConfig( + 'differential.always-allow-abandon'); $always_allow_close = PhabricatorEnv::getEnvConfig( 'differential.always-allow-close'); $allow_reopen = PhabricatorEnv::getEnvConfig( @@ -586,17 +588,20 @@ final class DifferentialRevisionViewController extends DifferentialController { } else { switch ($status) { case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW: + $actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon; $actions[DifferentialAction::ACTION_ACCEPT] = true; $actions[DifferentialAction::ACTION_REJECT] = true; $actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer; break; case ArcanistDifferentialRevisionStatus::NEEDS_REVISION: case ArcanistDifferentialRevisionStatus::CHANGES_PLANNED: + $actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon; $actions[DifferentialAction::ACTION_ACCEPT] = true; $actions[DifferentialAction::ACTION_REJECT] = !$viewer_has_rejected; $actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer; break; case ArcanistDifferentialRevisionStatus::ACCEPTED: + $actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon; $actions[DifferentialAction::ACTION_ACCEPT] = !$viewer_has_accepted; $actions[DifferentialAction::ACTION_REJECT] = true; $actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer; diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php index c26899e4ea..221f79d963 100644 --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -789,6 +789,9 @@ final class DifferentialTransactionEditor $actor_phid = $this->getActor()->getPHID(); $actor_is_author = ($author_phid == $actor_phid); + $config_abandon_key = 'differential.always-allow-abandon'; + $always_allow_abandon = PhabricatorEnv::getEnvConfig($config_abandon_key); + $config_close_key = 'differential.always-allow-close'; $always_allow_close = PhabricatorEnv::getEnvConfig($config_close_key); @@ -860,7 +863,7 @@ final class DifferentialTransactionEditor break; case DifferentialAction::ACTION_ABANDON: - if (!$actor_is_author) { + if (!$actor_is_author && !$always_allow_abandon) { return pht( "You can not abandon this revision because you do not own it. ". "You can only abandon revisions you own.");