[PATCH STABLE] extdiff: quote only options specified at runtime (issue4463)
Matt Mackall
mpm at selenic.com
Mon Dec 1 18:13:15 CST 2014
On Tue, 2014-12-02 at 02:44 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1417454278 -32400
> # Tue Dec 02 02:17:58 2014 +0900
> # Branch stable
> # Node ID d887d27304009d1cac05a1db4399f69d1778c5f0
> # Parent edf29f9c15f0f171847f4c7a8184cca4e95c8b31
> extdiff: quote only options specified at runtime (issue4463)
>
> For arguments and options including white spaces, changeset
> 72a89cf86fcd introduced fully quoting on all command line arguments
> and options for external diff command.
>
> But this causes unexpected behavior of extdiff with WinMerge, because
> WinMerge can't work correctly, when command line options in Windows
> standard style are quoted: for example, 'WinMerge /r ....' is OK, but
> 'WinMerge "/r" ....' is NG).
Presumably this is no good because WinMerge doesn't use the standard
argument parser in Microsoft's C runtime (the thing that gives argc and
argv to main()) and instead uses the raw single-string lpCmdLine passed
to WinMain... and then does its own broken parsing that doesn't handle
quoting on things that aren't filenames. Sigh.
I'm more than a little worried that we're putting this sort of obscure
knowledge in a special function in a weird extension and not somewhere
in util.
> +def _splitcmdline(cmdline):
> + '''Split diff command line configuration into command path and options
> +
> + This returns ``(commandpath, options)`` tuple. ``options`` is a
> + list, but each command line options specified in ``cmdline`` are
> + not splitted. So, ``len(options)`` is 0 or 1.
Seems silly for it to be a list then?
> + stream = cStringIO.StringIO(cmdline)
> + # according to "shlex.split" implementation, ``posix`` is True
> + # even on Windows
> + lex = shlex.shlex(stream, posix=True)
This function accepts strings, no need to mess with StringIO.
Since it's getting late, looks like this has to wait for 3.2.3.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list