]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Remind user about 'arc amend' when they try to land a branch onto itself
authorepriestley <git@epriestley.com>
Wed, 23 May 2012 18:40:20 +0000 (11:40 -0700)
committerepriestley <git@epriestley.com>
Wed, 23 May 2012 18:55:30 +0000 (11:55 -0700)
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

index 5a295aa24ff239059c0202c9bb157a648e34144a..bd7e8b65a0eca5ed27ad018d625b80d2ef6f9f15 100644 (file)
@@ -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(