]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make --revision switch of amend workflow easier to use
authorMarek Sapota <mareksapota@fb.com>
Tue, 13 Dec 2011 19:38:45 +0000 (11:38 -0800)
committerMarek Sapota <mareksapota@fb.com>
Tue, 13 Dec 2011 19:41:11 +0000 (11:41 -0800)
Summary:
--revision doesn't allow the revision to be prefixed with 'D'.  Also the error
message showed when specified revision doesn't exist is hard to understand.

Test Plan:
Used `arc amend --revision D123`, tried it without 'D' and with a non existing
revision.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1193

src/workflow/amend/ArcanistAmendWorkflow.php

index 0c16e4ba921a83408149c182ef25265386352248..8ae1ea600a19d70a15882550d21742702e1e3130 100644 (file)
@@ -90,7 +90,7 @@ EOTEXT
     }
 
     if ($this->getArgument('revision')) {
-      $revision_id = $this->getArgument('revision');
+      $revision_id = $this->normalizeRevisionID($this->getArgument('revision'));
     } else {
       $log = $repository_api->getGitCommitLog();
       $parser = new ArcanistDiffParser();
@@ -117,12 +117,23 @@ EOTEXT
     // revision in it. Maybe this is worth restoring?
 
     $conduit = $this->getConduit();
-    $message = $conduit->callMethodSynchronous(
-      'differential.getcommitmessage',
-      array(
-        'revision_id' => $revision_id,
-        'edit'        => false,
-      ));
+    try {
+      $message = $conduit->callMethodSynchronous(
+        'differential.getcommitmessage',
+        array(
+          'revision_id' => $revision_id,
+          'edit'        => false,
+        )
+      );
+    } catch (ConduitClientException $ex) {
+      if (strpos($ex->getMessage(), 'ERR_NOT_FOUND') === false) {
+        throw $ex;
+      } else {
+        throw new ArcanistUsageException(
+          "Revision D{$revision_id} does not exist."
+        );
+      }
+    }
 
     if ($is_show) {
       echo $message."\n";