[PATCH] debuginstall: handle quoted path for editor (issue4316)

Alexandre Garnier zigarn at gmail.com
Tue Jul 29 16:01:31 CDT 2014


# HG changeset patch
# User Alexandre Garnier <zigarn at gmail.com>
# Date 1406665496 -7200
#      Tue Jul 29 22:24:56 2014 +0200
# Branch stable
# Node ID b817183e354981f9088a85dea76dbc865c013d3a
# Parent  ad56fc55cbc3870d257e163469c687088627283b
debuginstall: handle quoted path for editor (issue4316)

When using an editor path with spaces and options, you can set 'ui.editor'
to '"/path to your/editor" -opt' and it works fine but 'hg debuginstall'
is complaining about it because it simply splits the editor and
tests presence of '"/path'.
Now correctly parse 'ui.editor' string by handling quoted path.

diff -r ad56fc55cbc3 -r b817183e3549 mercurial/commands.py
--- a/mercurial/commands.py	Mon Jul 28 10:05:17 2014 +0200
+++ b/mercurial/commands.py	Tue Jul 29 22:24:56 2014 +0200
@@ -2248,7 +2248,9 @@
     # editor
     ui.status(_("checking commit editor...\n"))
     editor = ui.geteditor()
-    cmdpath = util.findexe(editor) or util.findexe(editor.split()[0])
+    cmdpath = (util.findexe(editor) or util.findexe(editor.split()[0])
+      or util.findexe(re.search(r'^"?([^"]+)"?(?:\s+.*)?', editor).group(1))
+      or util.findexe(re.search(r"^'?([^']+)'?(?:\s+.*)?", editor).group(1)))
     if not cmdpath:
         if editor == 'vi':
             ui.write(_(" No commit editor set and can't find vi in PATH\n"))


More information about the Mercurial-devel mailing list