Patchwork debuginstall: handle quoted path for editor (issue4316)

login
register
mail settings
Submitter Alexandre Garnier
Date July 31, 2014, 9:45 a.m.
Message ID <CAFFOgCWW-nKEb0VTkjr=O0xNg=ADKE-=WySb2cz167sD9nQ4Ug@mail.gmail.com>
Download mbox | patch
Permalink /patch/5211/
State Accepted
Commit 2122b82b6987c074ce9b4283c5d2b5927701a36c
Headers show

Comments

Alexandre Garnier - July 31, 2014, 9:45 a.m.
# HG changeset patch
# User Alexandre Garnier <zigarn@gmail.com>
# Date 1406799116 -3600
#      Thu Jul 31 10:31:56 2014 +0100
# Branch stable
# Node ID a9dcbf4991fc26c7ba52d3650b4727e8c1b555b1
# Parent  2d8cd3d0e83c7336c0cb45a9f88638363f993848
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.
Matt Mackall - July 31, 2014, 5:39 p.m.
On Thu, 2014-07-31 at 11:45 +0200, Alexandre Garnier wrote:
> # HG changeset patch
> # User Alexandre Garnier <zigarn@gmail.com>
> # Date 1406799116 -3600
> #      Thu Jul 31 10:31:56 2014 +0100
> # Branch stable
> # Node ID a9dcbf4991fc26c7ba52d3650b4727e8c1b555b1
> # Parent  2d8cd3d0e83c7336c0cb45a9f88638363f993848
> debuginstall: handle quoted path for editor (issue4316)

Queued for stable, thanks. Congrats on your first Mercurial patch.

Patch

diff -r 2d8cd3d0e83c -r a9dcbf4991fc mercurial/commands.py
--- a/mercurial/commands.py     Tue Jul 01 23:27:32 2014 -0500
+++ b/mercurial/commands.py     Thu Jul 31 10:31:56 2014 +0100
@@ -8,7 +8,7 @@ 
 from node import hex, bin, nullid, nullrev, short
 from lock import release
 from i18n import _
-import os, re, difflib, time, tempfile, errno
+import os, re, difflib, time, tempfile, errno, shlex
 import sys
 import hg, scmutil, util, revlog, copies, error, bookmarks
 import patch, help, encoding, templatekw, discovery
@@ -2210,7 +2210,7 @@ 
     # editor
     ui.status(_("checking commit editor...\n"))
     editor = ui.geteditor()
-    cmdpath = util.findexe(editor) or util.findexe(editor.split()[0])
+    cmdpath = util.findexe(shlex.split(editor)[0])
     if not cmdpath:
         if editor == 'vi':
             ui.write(_(" No commit editor set and can't find vi in PATH\n"))