From 11c9994134935ea6358f7714e5d4d4297a617b9c Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 12 Feb 2018 13:01:02 -0800 Subject: [PATCH] Allow "arc diff --plan-changes" to work with drafts enabled Summary: See PHI346. Ref T13054. If you have prototypes enabled on the server but use `master` / `stable` on the client and run `arc diff --plan-changes`, the transition is rejected because "Draft -> Changes Planned" isn't currently a legal transition. Allow this transition if not coming from the web UI (to keep it out of the dropdown). Test Plan: - Ran `arc diff --plan-changes` on `master`, got a "Changes Planned" revision instead of a validation error. - Ran `arc diff` without `--plan-changes`, got a draft, verified that "Plan Changes" still doesn't appear in the action dropdown. Maniphest Tasks: T13054 Differential Revision: https://secure.phabricator.com/D19067 --- ...DifferentialRevisionPlanChangesTransaction.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php b/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php index 231adc5bf8..e53426c8ba 100644 --- a/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php +++ b/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php @@ -57,8 +57,19 @@ final class DifferentialRevisionPlanChangesTransaction protected function validateAction($object, PhabricatorUser $viewer) { if ($object->isDraft()) { - throw new Exception( - pht('You can not plan changes to a draft revision.')); + + // See PHI346. Until the "Draft" state fully unprototypes, allow drafts + // to be moved to "changes planned" via the API. This preserves the + // behavior of "arc diff --plan-changes". We still prevent this + // transition from the web UI. + // TODO: Remove this once drafts leave prototype. + + $editor = $this->getEditor(); + $type_web = PhabricatorWebContentSource::SOURCECONST; + if ($editor->getContentSource()->getSource() == $type_web) { + throw new Exception( + pht('You can not plan changes to a draft revision.')); + } } if ($object->isChangePlanned()) {