]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make --auto creates actually work in SVN and HG
authorepriestley <git@epriestley.com>
Tue, 10 Apr 2012 19:06:41 +0000 (12:06 -0700)
committerepriestley <git@epriestley.com>
Tue, 10 Apr 2012 19:06:41 +0000 (12:06 -0700)
Summary:
--auto doesn't work right now on the implicit --create pathway in SVN and HG because we hit these conditions.

Also improve a message.

Test Plan: Ran "arc diff" in unaffiliated working copies in HG and SVN.

Reviewers: svemir, btrahan, vrana, jungejason

Reviewed By: svemir

CC: aran
Differential Revision: https://secure.phabricator.com/D2187

src/workflow/diff/ArcanistDiffWorkflow.php

index 27eeeef082b76c6e5cd675ce9628f019cfd660e7..67dddc604eb8f85b0ff78f58c5b24dce5372f084 100644 (file)
@@ -289,6 +289,24 @@ EOTEXT
           'hg',
         ),
       ),
+      'verbatim' => array(
+        'help' => 'Try to use the working copy commit message verbatim when '.
+                  'creating a revision, without prompting to edit it.',
+        'supports' => array(
+          'hg',
+          'git',
+        ),
+        'conflicts' => array(
+          'use-commit-message'  => true,
+          'update'              => true,
+          'only'                => true,
+          'preview'             => true,
+          'raw'                 => true,
+          'raw-command'         => true,
+          'message'             => true,
+          'message-file'        => true,
+        ),
+      ),
       '*' => 'paths',
     );
   }
@@ -521,15 +539,6 @@ EOTEXT
       return true;
     }
 
-    $repository_api = $this->getRepositoryAPI();
-    if ($repository_api instanceof ArcanistSubversionAPI) {
-      return true;
-    }
-
-    if ($repository_api instanceof ArcanistMercurialAPI) {
-      return true;
-    }
-
     if ($this->isHistoryImmutable()) {
       return true;
     }
@@ -1205,7 +1214,7 @@ EOTEXT
         $is_update = $revision['id'];
       } else {
         throw new ArcanistUsageException(
-          "There are several revisions in the specified commit range:\n\n".
+          "There are several revisions which match the working copy:\n\n".
           $this->renderRevisionList($revisions)."\n".
           "Use '--update' to choose one, or '--create' to create a new ".
           "revision.");
@@ -1313,6 +1322,7 @@ EOTEXT
     }
 
     $done = false;
+    $first = true;
     while (!$done) {
       $template = rtrim($template)."\n\n";
       foreach ($issues as $issue) {
@@ -1320,13 +1330,17 @@ EOTEXT
       }
       $template .= "\n";
 
-      $new_template = id(new PhutilInteractiveEditor($template))
-        ->setName('new-commit')
-        ->editInteractively();
+      if ($first && $this->getArgument('verbatim') && !$template_is_default) {
+        $new_template = $template;
+      } else {
+        $new_template = id(new PhutilInteractiveEditor($template))
+          ->setName('new-commit')
+          ->editInteractively();
+      }
+      $first = false;
 
       if ($template_is_default && ($new_template == $template)) {
-        throw new ArcanistUsageException(
-          "Template not edited.");
+        throw new ArcanistUsageException("Template not edited.");
       }
 
       $template = preg_replace('/^\s*#.*$/m', '', $new_template);