]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Support an 'editor' config in arc
authorepriestley <git@epriestley.com>
Wed, 11 Jul 2012 23:55:11 +0000 (16:55 -0700)
committerepriestley <git@epriestley.com>
Wed, 11 Jul 2012 23:55:11 +0000 (16:55 -0700)
Summary: See D2955. Allow "arc set-config editor ..." to override all other editor settings.

Test Plan: Ran "arc set-config editor 'mate -w'", am typing this in textmate.

Reviewers: btrahan, ezfoxie

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T1309

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

src/workflow/ArcanistBaseWorkflow.php
src/workflow/ArcanistDiffWorkflow.php
src/workflow/ArcanistPatchWorkflow.php

index 222d12558ed795948096693500df8f8b4207eaba..4fe084f85b4a47fde4ba1255ef01d1f0f78b141e 100644 (file)
@@ -1276,4 +1276,15 @@ abstract class ArcanistBaseWorkflow {
     return $value;
   }
 
+  protected function newInteractiveEditor($text) {
+    $editor = new PhutilInteractiveEditor($text);
+
+    $preferred = $this->getWorkingCopy()->getConfigFromAnySource('editor');
+    if ($preferred) {
+      $editor->setPreferredEditor($preferred);
+    }
+
+    return $editor;
+  }
+
 }
index 4fe85c99472533e4d6ab8494e16f6490dc411ccd..b8aab48a6b1617713e7863abf68cc0fd462936a4 100644 (file)
@@ -447,7 +447,7 @@ EOTEXT
 
         $should_edit = $this->getArgument('edit');
         if ($should_edit) {
-          $remote_corpus = id(new PhutilInteractiveEditor($remote_corpus))
+          $remote_corpus = $this->newInteractiveEditor($remote_corpus)
             ->setName('differential-edit-revision-info')
             ->editInteractively();
         }
@@ -1412,7 +1412,7 @@ EOTEXT
       if ($first && $this->getArgument('verbatim') && !$template_is_default) {
         $new_template = $template;
       } else {
-        $new_template = id(new PhutilInteractiveEditor($template))
+        $new_template = $this->newInteractiveEditor($template)
           ->setName('new-commit')
           ->editInteractively();
       }
@@ -1599,7 +1599,7 @@ EOTEXT
       "#  $ arc diff --create\n".
       "\n";
 
-    $comments = id(new PhutilInteractiveEditor($template))
+    $comments = $this->newInteractiveEditor($template)
       ->setName('differential-update-comments')
       ->editInteractively();
 
index 771dfb22230afba382465c05631f53f43b762369..5240c3205c7963958a8be919582121a59cabfc26 100644 (file)
@@ -658,7 +658,7 @@ EOTEXT
         $prompt_message.
         "\n";
 
-      $commit_message = id(new PhutilInteractiveEditor($template))
+      $commit_message = $this->newInteractiveEditor($template)
         ->setName('arcanist-patch-commit-message')
         ->editInteractively();