]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add "--revision <id>" flag to "arc land"
authorepriestley <git@epriestley.com>
Sat, 3 Mar 2012 00:47:05 +0000 (16:47 -0800)
committerepriestley <git@epriestley.com>
Sat, 3 Mar 2012 00:47:05 +0000 (16:47 -0800)
Summary: Allow the user to pick a revision explicitly if they think they know what they're doing. Similar to "arc amend --revision", etc.

Test Plan: Obviously compells a meta-test.

Reviewers: btrahan, fratrik

Reviewed By: fratrik

CC: aran, epriestley
Maniphest Tasks: T928

Differential Revision: https://secure.phabricator.com/D1753

src/workflow/land/ArcanistLandWorkflow.php

index 4dbfabb7ae2d7d0c6cc2d50aef0503356058e264..3641dc2fb6ad10c9e524206f20bbcf6a3828db68 100644 (file)
@@ -82,6 +82,11 @@ EOTEXT
                   'project is marked as having an immutable history, this is '.
                   'the default behavior.',
       ),
+      'revision' => array(
+        'param' => 'id',
+        'help'  => 'Use the message from a specific revision, rather than '.
+                   'inferring the revision based on branch content.',
+      ),
       '*' => 'branch',
     );
   }
@@ -171,25 +176,38 @@ EOTEXT
       $repository_api->parseRelativeLocalCommit(array($remote.'/'.$onto));
     }
 
-    $revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
-      $this->getConduit(),
-      array(
-        'authors' => array($this->getUserPHID()),
-      ));
+    $revision_id = $this->getArgument('revision');
+    if ($revision_id) {
+      $revision_id = $this->normalizeRevisionID($revision_id);
+      $revisions = $this->getConduit()->callMethodSynchronous(
+        'differential.query',
+        array(
+          'ids' => array($revision_id),
+        ));
+      if (!$revisions) {
+        throw new ArcanistUsageException("No such revision 'D{$revision_id}'!");
+      }
+    } else {
+      $revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
+        $this->getConduit(),
+        array(
+          'authors' => array($this->getUserPHID()),
+        ));
+    }
 
     if (!count($revisions)) {
       throw new ArcanistUsageException(
         "arc can not identify which revision exists on branch '{$branch}'. ".
         "Update the revision with recent changes to synchronize the branch ".
         "name and hashes, or use 'arc amend' to amend the commit message at ".
-        "HEAD.");
+        "HEAD, or use '--revision <id>' to select a revision explicitly.");
     } else if (count($revisions) > 1) {
       $message =
         "There are multiple revisions on feature branch '{$branch}' which are ".
         "not present on '{$onto}':\n\n".
         $this->renderRevisionList($revisions)."\n".
-        "Separate these revisions onto different branches, or manually land ".
-        "them in '{$onto}'.";
+        "Separate these revisions onto different branches, or use ".
+        "'--revision <id>' to select one.";
       throw new ArcanistUsageException($message);
     }