From 833ae9c152a01d916c7b8b174c8a0b6d3e682ee9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 23 May 2012 11:40:20 -0700 Subject: [PATCH] Remind user about 'arc amend' when they try to land a branch onto itself Summary: If you develop in "master" and try to "arc land", you get an error. You can reasonably "arc amend" in this situation, most of the time. Give the user an explicit pointer. Test Plan: $ arc land master Usage Exception: You can not land a branch onto itself -- you are trying to land 'master' onto 'master'. For more information on how to push changes, see 'Pushing and Closing Revisions' in 'Arcanist User Guide: arc diff' in the documentation. You may be able to 'arc amend' instead. Reviewers: csilvers, btrahan Reviewed By: csilvers CC: aran Differential Revision: https://secure.phabricator.com/D2547 --- src/workflow/land/ArcanistLandWorkflow.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/workflow/land/ArcanistLandWorkflow.php b/src/workflow/land/ArcanistLandWorkflow.php index 5a295aa2..bd7e8b65 100644 --- a/src/workflow/land/ArcanistLandWorkflow.php +++ b/src/workflow/land/ArcanistLandWorkflow.php @@ -141,12 +141,18 @@ EOTEXT $remote = $this->getArgument('remote', 'origin'); $onto = $this->getArgument('onto', $onto_default); + $is_immutable = $this->isHistoryImmutable(); + if ($onto == $branch) { - throw new ArcanistUsageException( + $message = "You can not land a branch onto itself -- you are trying to land ". "'{$branch}' onto '{$onto}'. For more information on how to push ". "changes, see 'Pushing and Closing Revisions' in ". - "'Arcanist User Guide: arc diff' in the documentation."); + "'Arcanist User Guide: arc diff' in the documentation."; + if (!$is_immutable) { + $message .= " You may be able to 'arc amend' instead."; + } + throw new ArcanistUsageException($message); } if ($this->getArgument('merge')) { @@ -154,7 +160,7 @@ EOTEXT } else if ($this->getArgument('squash')) { $use_squash = true; } else { - $use_squash = !$this->isHistoryImmutable(); + $use_squash = !$is_immutable; } list($err) = $repository_api->execManualLocal(