Skip to content

Commit 1e2a592

Browse files
joshuaspenceepriestley
authored and
epriestley
committedJun 2, 2014
Expose "Abandon Revision" to non-authors with a config flag.
Summary: Fixes T4720. Allows non-authors to permanently reject a differential by exposing the "Abandon Revision" action via a configuration flag. Test Plan: {F161434} Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T4720 Differential Revision: https://secure.phabricator.com/D9306
1 parent 8ea9935 commit 1e2a592

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed
 

‎conf/default.conf.php

+4
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,10 @@
811811
// only the submitter can close a revision.
812812
'differential.always-allow-close' => false,
813813

814+
// If you set this to true, any user can abandon any revision. If false, only
815+
// the submitter can abandon a revision.
816+
'differential.always-allow-abandon' => false,
817+
814818
// If you set this to true, any user can reopen a revision so long as it has
815819
// been closed. This can be useful if a revision is accidentally closed or
816820
// if a developer changes his or her mind after closing a revision. If it is

‎src/applications/differential/config/PhabricatorDifferentialConfigOptions.php

+11
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ public function getOptions() {
165165
"where the reviewer is often the actual committer can benefit ".
166166
"from turning this option to true. If false, only the submitter ".
167167
"can close a revision.")),
168+
$this->newOption('differential.always-allow-abandon', 'bool', false)
169+
->setBoolOptions(
170+
array(
171+
pht('Allow any user'),
172+
pht('Restrict to submitter'),
173+
))
174+
->setSummary(pht('Allows any user to abandon revisions.'))
175+
->setDescription(
176+
pht(
177+
'If you set this to true, any user can abandon any revision. If '.
178+
'false, only the submitter can abandon a revision.')),
168179
$this->newOption('differential.allow-reopen', 'bool', false)
169180
->setBoolOptions(
170181
array(

‎src/applications/differential/controller/DifferentialRevisionViewController.php

+5
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ private function getRevisionCommentActions(DifferentialRevision $revision) {
553553

554554
$allow_self_accept = PhabricatorEnv::getEnvConfig(
555555
'differential.allow-self-accept');
556+
$always_allow_abandon = PhabricatorEnv::getEnvConfig(
557+
'differential.always-allow-abandon');
556558
$always_allow_close = PhabricatorEnv::getEnvConfig(
557559
'differential.always-allow-close');
558560
$allow_reopen = PhabricatorEnv::getEnvConfig(
@@ -586,17 +588,20 @@ private function getRevisionCommentActions(DifferentialRevision $revision) {
586588
} else {
587589
switch ($status) {
588590
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
591+
$actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon;
589592
$actions[DifferentialAction::ACTION_ACCEPT] = true;
590593
$actions[DifferentialAction::ACTION_REJECT] = true;
591594
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
592595
break;
593596
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
594597
case ArcanistDifferentialRevisionStatus::CHANGES_PLANNED:
598+
$actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon;
595599
$actions[DifferentialAction::ACTION_ACCEPT] = true;
596600
$actions[DifferentialAction::ACTION_REJECT] = !$viewer_has_rejected;
597601
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
598602
break;
599603
case ArcanistDifferentialRevisionStatus::ACCEPTED:
604+
$actions[DifferentialAction::ACTION_ABANDON] = $always_allow_abandon;
600605
$actions[DifferentialAction::ACTION_ACCEPT] = !$viewer_has_accepted;
601606
$actions[DifferentialAction::ACTION_REJECT] = true;
602607
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;

‎src/applications/differential/editor/DifferentialTransactionEditor.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,9 @@ private function validateDifferentialAction(
789789
$actor_phid = $this->getActor()->getPHID();
790790
$actor_is_author = ($author_phid == $actor_phid);
791791

792+
$config_abandon_key = 'differential.always-allow-abandon';
793+
$always_allow_abandon = PhabricatorEnv::getEnvConfig($config_abandon_key);
794+
792795
$config_close_key = 'differential.always-allow-close';
793796
$always_allow_close = PhabricatorEnv::getEnvConfig($config_close_key);
794797

@@ -860,7 +863,7 @@ private function validateDifferentialAction(
860863
break;
861864

862865
case DifferentialAction::ACTION_ABANDON:
863-
if (!$actor_is_author) {
866+
if (!$actor_is_author && !$always_allow_abandon) {
864867
return pht(
865868
"You can not abandon this revision because you do not own it. ".
866869
"You can only abandon revisions you own.");

0 commit comments

Comments
 (0)
Failed to load comments.