Make git-cl more accurately imitate git's editor selection process, and respect $VISUAL.

It is somewhat surprising when git-cl, which acts as a git subcommand, launches
a different editor. In particular, git has a config option (core.editor) which
specifies the editor that should be used. Since we already respect $GIT_EDITOR,
it makes sense for git-cl to respect core.editor and $VISUAL as well.

R=maruel@chromium.org
BUG=237504

Review URL: https://chromiumcodereview.appspot.com/14854003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@198101 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index 73d9595..bb907f2 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -114,6 +114,11 @@
             cls._git_upload_calls())
 
   @classmethod
+  def _upload_no_rev_calls(cls, similarity, find_copies):
+    return (cls._git_base_calls(similarity, find_copies) +
+            cls._git_upload_no_rev_calls())
+
+  @classmethod
   def _git_base_calls(cls, similarity, find_copies):
     if similarity is None:
       similarity = '50'
@@ -175,8 +180,15 @@
     ]
 
   @classmethod
+  def _git_upload_no_rev_calls(cls):
+    return [
+      ((['git', '--no-pager', 'config', 'core.editor'],), ''),
+    ]
+
+  @classmethod
   def _git_upload_calls(cls):
     return [
+      ((['git', '--no-pager', 'config', 'core.editor'],), ''),
       ((['git', '--no-pager', 'config', 'rietveld.cc'],), ''),
       ((['git', '--no-pager', 'config', 'branch.master.base-url'],), ''),
       ((['git', '--no-pager',
@@ -358,7 +370,7 @@
       find_copies = None
 
     self.calls = self._upload_calls(similarity, find_copies)
-    def RunEditor(desc, _):
+    def RunEditor(desc, _, **kwargs):
       self.assertEquals(
           '# Enter a description of the change.\n'
           '# This will be displayed on the codereview site.\n'
@@ -450,8 +462,8 @@
 
     mock = FileMock()
     try:
-      self.calls = self._git_base_calls(None, None)
-      def RunEditor(desc, _):
+      self.calls = self._upload_no_rev_calls(None, None)
+      def RunEditor(desc, _, **kwargs):
         return desc
       self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor)
       self.mock(sys, 'stderr', mock)