[PATCH 2 of 2 STABLE V3] extdiff: quote only options specified at runtime (issue4463)

Yuya Nishihara yuya at tcha.org
Sat Dec 6 03:21:02 CST 2014


On Fri, 05 Dec 2014 15:57:59 +0100, Mads Kiilerich wrote:
> On 12/05/2014 01:14 PM, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> > # Date 1417781468 -32400
> > #      Fri Dec 05 21:11:08 2014 +0900
> > # Branch stable
> > # Node ID 1bae72e4e9fc1ad7abdadc848adb9b97d75beddc
> > # Parent  73b764f8fdf2c33ad56795ef2513d9687bd14734
> > extdiff: quote only options specified at runtime (issue4463)
> 
> Instead, couldn't we just let shellquote (on all platforms) just return
> the string itself if it is "safe"? That would also give more clean
> output when inspecting what actually is being run.

If I understand it, the problem begins when extdiff parses shell command
by shlex.split().  shlex.split() discards the information how each argument
is quoted, but it is necessary to process environment variables properly,
for example.

filemerge and shell alias pass the given command string as-is, so only extdiff
behaves differently.

For example,

  % cat .hgrc
  [ui]
  merge = echo

  [extdiff]
  echo =

  [merge-tools]
  echo.args = --opt $OPT '$LIT' $local $base $other
  echo.diffargs = --opt $OPT '$LIT' $parent $child

  % hg merge
  # runs '/bin/echo' --opt $OPT '$LIT' 'foo' 'foo~base' 'foo~other'

  % hg-3.2/hg echo -r0
  # runs 'echo' --opt $OPT $LIT '.../foo' 'foo'

  % hg-3.2.1/hg echo -r0
  # runs 'echo' '--opt' '$OPT' '$LIT' ''.../foo'' ''foo''

Oh, I see another issue. extdiff of hg 3.2.1 can't handle file name with
white spaces.

Maybe extdiff.dodiff() shouldn't accept diffcmd and diffopts separately
so that the caller can avoid unnecessary shlex.split().

Regards,


More information about the Mercurial-devel mailing list