changeset 36236:564dec70b50c

debugcommands: print out the editor that was searched for (post shlexsplit) A user was in #mercurial and had the following settings in their hgrc: [ui] editor = C:\home\npp\notepad++.exe -multiInst -nosession After shlexsplit, the first argument was mangled into C:homenppnotepad++.exe, which was quite unlikely to exist. It took many back-and-forths to identify that adding " characters around the exe would fix the issue; we were thinking that it's because something was incorrectly *not* splitting and adding/moving the " characters fixed the split boundaries, but when testing afterward it appears that it's just mangled. I considered adding an informational if pycompat.iswindows and \ in the string about this issue, but was worried that might have too many false positives and did not do so at this time. Differential Revision: https://phab.mercurial-scm.org/D1808
author Kyle Lippincott <spectral@google.com>
date Thu, 04 Jan 2018 16:29:07 -0800
parents d879aab17786
children b39f0fdb0338
files mercurial/debugcommands.py tests/test-install.t
diffstat 2 files changed, 35 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Fri Feb 16 17:24:31 2018 -0500
+++ b/mercurial/debugcommands.py	Thu Jan 04 16:29:07 2018 -0800
@@ -1240,16 +1240,17 @@
     # editor
     editor = ui.geteditor()
     editor = util.expandpath(editor)
-    fm.write('editor', _("checking commit editor... (%s)\n"), editor)
-    cmdpath = util.findexe(pycompat.shlexsplit(editor)[0])
+    editorbin = pycompat.shlexsplit(editor)[0]
+    fm.write('editor', _("checking commit editor... (%s)\n"), editorbin)
+    cmdpath = util.findexe(editorbin)
     fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
                  _(" No commit editor set and can't find %s in PATH\n"
                    " (specify a commit editor in your configuration"
-                   " file)\n"), not cmdpath and editor == 'vi' and editor)
+                   " file)\n"), not cmdpath and editor == 'vi' and editorbin)
     fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound',
                  _(" Can't find editor '%s' in PATH\n"
                    " (specify a commit editor in your configuration"
-                   " file)\n"), not cmdpath and editor)
+                   " file)\n"), not cmdpath and editorbin)
     if not cmdpath and editor != 'vi':
         problems += 1
 
--- a/tests/test-install.t	Fri Feb 16 17:24:31 2018 -0500
+++ b/tests/test-install.t	Thu Jan 04 16:29:07 2018 -0800
@@ -17,7 +17,7 @@
   checking "re2" regexp engine \((available|missing)\) (re)
   checking templates (*mercurial?templates)... (glob)
   checking default template (*mercurial?templates?map-cmdline.default) (glob)
-  checking commit editor... (* -c "import sys; sys.exit(0)") (glob)
+  checking commit editor... (*) (glob)
   checking username (test)
   no problems detected
 
@@ -31,7 +31,7 @@
     "defaulttemplate": "*mercurial?templates?map-cmdline.default", (glob)
     "defaulttemplateerror": null,
     "defaulttemplatenotfound": "default",
-    "editor": "* -c \"import sys; sys.exit(0)\"", (glob)
+    "editor": "*", (glob)
     "editornotfound": false,
     "encoding": "ascii",
     "encodingerror": null,
@@ -72,7 +72,7 @@
   checking "re2" regexp engine \((available|missing)\) (re)
   checking templates (*mercurial?templates)... (glob)
   checking default template (*mercurial?templates?map-cmdline.default) (glob)
-  checking commit editor... (* -c "import sys; sys.exit(0)") (glob)
+  checking commit editor... (*) (glob)
   checking username...
    no username supplied
    (specify a username in your configuration file)
@@ -120,6 +120,33 @@
   checking username (test)
   no problems detected
 
+print out the binary post-shlexsplit in the error message when commit editor is
+not found (this is intentionally using backslashes to mimic a windows usecase).
+  $ HGEDITOR="c:\foo\bar\baz.exe -y -z" hg debuginstall
+  checking encoding (ascii)...
+  checking Python executable (*) (glob)
+  checking Python version (*) (glob)
+  checking Python lib (*lib*)... (glob)
+  checking Python security support (*) (glob)
+    TLS 1.2 not supported by Python install; network connections lack modern security (?)
+    SNI not supported by Python install; may have connectivity issues with some servers (?)
+  checking Mercurial version (*) (glob)
+  checking Mercurial custom build (*) (glob)
+  checking module policy (*) (glob)
+  checking installed modules (*mercurial)... (glob)
+  checking registered compression engines (*zlib*) (glob)
+  checking available compression engines (*zlib*) (glob)
+  checking available compression engines for wire protocol (*zlib*) (glob)
+  checking "re2" regexp engine \((available|missing)\) (re)
+  checking templates (*mercurial?templates)... (glob)
+  checking default template (*mercurial?templates?map-cmdline.default) (glob)
+  checking commit editor... (c:foobarbaz.exe)
+   Can't find editor 'c:foobarbaz.exe' in PATH
+   (specify a commit editor in your configuration file)
+  checking username (test)
+  1 problems detected, please check your install!
+  [1]
+
 #if test-repo
   $ . "$TESTDIR/helpers-testrepo.sh"