Commit Graph

25 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
f6bf07d36e posix: quote the specified string only when it may have to be quoted
This patch makes "posix.shellquote" examine the specified string and
quote it only when it may have to be quoted for safety, like as the
previous patch for "windows.shellquote".

In fact, on POSIX environment, quoting itself doesn't cause issues
like issue4463. But (almost) equivalent quoting policy can avoid
examining test result differently on POSIX and Windows (even though
showing command line with "%r" causes such examination in
"test-extdiff.t").

The last hunk for "test-extdiff.t" in this patch isn't needed for the
previous patch for "windows.shellquote", because the code path of it
is executed only "#if execbit" (= avoided on Windows).
2014-12-25 23:33:26 +09:00
FUJIWARA Katsunori
1623722bb9 windows: quote the specified string only when it has to be quoted
Before this patch, "windows.shellquote" (as used as "util.shellquote")
always quotes specified strings with double quotation marks, for
external process invocation.

But some problematic applications can't work correctly, when command
line arguments are quoted: see issue4463 for detail.

On the other hand, quoting itself is needed to specify arguments
containing whitespaces and/or some special characters exactly.

This patch makes "windows.shellquote" examine the specified string and
quote it only when it may have to be quoted for safety.
2014-12-25 23:33:26 +09:00
FUJIWARA Katsunori
203706516b extdiff: avoid unexpected quoting arguments for external tools (issue4463)
Before this patch, all command line arguments for external tools are
quoted by the combination of "shlex.split" and "util.shellquote". But
this causes some problems.

  - some problematic commands can't work correctly with quoted arguments

    For example, 'WinMerge /r ....' is OK, but 'WinMerge "/r" ....' is
    NG. See also below for detail about this problem.

        https://bitbucket.org/tortoisehg/thg/issue/3978/

  - quoting itself may change semantics of arguments

    For example, when the environment variable CONCAT="foo bar baz':

      - mydiff $CONCAT   => mydiff foo bar baz   (taking 3 arguments)
      - mydiff "$CONCAT" => mydiff "foo bar baz" (taking only 1 argument)

    For another example, single quoting (= "util.shellquote") on POSIX
    environment prevents shells from expanding environment variables,
    tilde, and so on:

      - mydiff "$HOME" => mydiff /home/foobar
      - mydiff '$HOME' => mydiff $HOME

  - "shlex.split" can't handle some special characters correctly

    It just splits specified command line by whitespaces.

    For example, "echo foo;echo bar" is split into ["echo",
    "foo;echo", "bar"].

On the other hand, if quoting itself is omitted, users can't specify
options including space characters with "--option" at runtime.

The root cause of this issue is that "shlex.split + util.shellquote"
combination loses whether users really want to quote each command line
elements or not, even though these can be quoted arbitrarily in
configurations.

To resolve this problem, this patch does:

  - prevent configurations from being processed by "shlex.split" and
    "util.shellquote"

    only (possibly) "findexe"-ed or "findexternaltool"-ed command path
    is "util.shellquote", because it may contain whitespaces.

  - quote options specified by "--option" via command line at runtime

This patch also makes "dodiff()" take only one "args" argument instead
of "diffcmd" and "diffopts. It also omits applying "util.shellquote"
on "args", because "args" should be already stringified in "extdiff()"
and "mydiff()".

The last hunk for "test-extdiff.t" replaces two whitespaces by single
whitespace, because change of "' '.join()" logic causes omitting
redundant whitespaces.
2014-12-25 23:33:26 +09:00
Yuya Nishihara
ed7051c6c7 tests: write hgrc of more than two lines by using shell heredoc
Here document should be readable than repeating echo commands.
2014-11-04 23:41:46 +09:00
Matt Mackall
462cd9a28d merge with stable 2014-11-03 16:56:32 -06:00
Matt Harbison
41a84ec470 extdiff: allow a preconfigured merge-tool to be invoked
There are three ways to configure an extdiff tool:

    1) cmd.tool = (/path/to/exe optional)
    2) tool = (path/to/exe optional)
    3) tool = sometool someargs

Previously, if no executable is specified in the first two forms, the named tool
must be in $PATH, or the invocation fails.  Since the [merge-tools] section
already has the path to the diff executable, and/or the registry keys to find
the executable on Windows, reuse that configuration for forms 1 and 2 instead of
failing.  We already fallback to [diff-tools] and then [merge-tools] for program
arguments if they aren't specified in the [extdiff] section.

Since this additional lookup only occurs if an executable is not on the $PATH
for the named tool, this is backwards compatible.  For now, we assume the user
knows what he is doing if a path is provided.

This change allows a configuration file like this (assuming beyondcompare3 is
configured in merge-tools), instead of hardcoding system specific a path:

    [extdiff]
    beyondcompare3 =
2014-10-31 21:34:55 -04:00
Matt Mackall
68762ac0d2 help: fold repeatable option message into option table header
This will hopefully conserve some limited user attention.
2014-08-12 04:00:42 -05:00
Matt Mackall
540b8eb745 help: tweak --verbose command help hint
We used to have two slightly different message which people wouldn't read...
and then complain that they couldn't find the global options or examples.

So we unify them into one message that's upfront that STUFF IS
INTENTIONALLY HIDDEN and that looks more like our normal hint style.
2014-08-12 03:01:37 -05:00
Michael Fyles
001d1e7cb7 extdiff: quote user-supplied options passed to shell
$ hg extdiff -p cmd -o "name <user@example.com>"
resulted in a shell redirection error (due to the less-than sign),
rather than passing the single option to cmd. This was due to options
not being quoted for passing to the shell, via util.system(). Apply
util.shellquote() to each of the user-specified options (-o) to the
comparison program before they are concatenated and passed to
util.system(). The requested external diff command (-p) and the
files/directories being compared are already quoted correctly.

The discussion at the time of changeset 6654fcb57d92 correctly noted
that this course of action breaks whitespace-separated options specified
for external diff commands in the configuration. The lower part of the
patch corrects this by lexing options read from the configuration file
into separate options rather than reading them all into the first
option.

Update test to cover these conditions.

Related changesets (reverse-chronological):
- 6654fcb57d92 (fix reverted to make configuration file options work)
- c64ec6e8ffa2 (issue fixed but without fix for configuration file)
2012-07-26 11:38:13 +01:00
FUJIWARA Katsunori
477c2590ac help: indicate help omitting if help document is not fully displayed
Before this patch, there is no information about whether help document
is fully displayed or not.

So, some users seem to misunderstand "-v" for "hg help" just as "the
option to show list of global options": experience on "hg help -v" for
some commands not containing verbose containers may strengthen this
misunderstanding.

Such users have less opportunity for noticing omitted help document,
and this may cause insufficient understanding about Mercurial.

This patch indicates help omitting, if help document is not fully
displayed.

For command help, the message below is displayed at the end of help
output, if help document is not fully displayed:

    use "hg -v help xxxx" to show more complete help and the global
    options

and otherwise:

    use "hg -v help xxxx" to show the global options

For topics and extensions help, the message below is displayed, only
if help document is not fully displayed:

    use "hg help -v xxxx" to show more complete help

This allows users to know whether there is any omitted information or
not exactly, and can trigger "hg help -v" invocation.

This patch causes formatting help document twice, to switch messages
one for omitted help, and another for not omitted. This decreases
performance of help document formatting, but it is not mainly focused
at help command invocation, so this wouldn't become problem.
2012-10-18 10:31:15 +09:00
Mads Kiilerich
4f14a0a969 tests: convert some 'hghave execbit' to #if
This enables some new tests for running on windows.
2012-06-10 14:14:05 +02:00
Mads Kiilerich
adfff587c7 tests: use 'hghave execbit' for tests that manipulate x bit in file system 2011-11-07 03:14:54 +01:00
Mads Kiilerich
4838bfb2c4 tests: use 'hghave symlink' for tests using symlinks 2011-11-07 03:14:54 +01:00
Matt Mackall
58c81fa35e help: unify the two -v notes for command help 2011-10-07 16:36:54 -05:00
Matt Mackall
4204f3ffa5 help: use RST to format option lists 2011-09-21 13:00:48 -05:00
Thomas Arendsen Hein
e6dcc5994e merge with stable 2011-04-29 11:10:11 +02:00
Patrick Mezard
2cbeb4b9c6 extdiff: fix broken symlinks handling (issue1909) 2011-04-29 08:04:46 +02:00
Patrick Mezard
9c572be237 test-extdiff: fix 60da34df26da temporary dir output 2011-03-25 16:46:19 +01:00
Mads Kiilerich
3174ff376b tests: remove redundant globs
Many globs now just match $TESTTMP and is no longer needed.
2010-10-08 22:36:10 -05:00
Erik Zielke
512d0992fc tests: removed test names in tests
The name of the test files is replaced with a glob * expression,
thereby the tests does not depend on the filename of the file they are
in.
2010-09-30 09:49:40 +02:00
Matt Mackall
32de98afbd tests: drop final true command from unified tests 2010-09-20 16:00:15 -05:00
Matt Mackall
200e89394d tests: fix a bunch of pointless #s in unified tests 2010-09-17 17:03:08 -05:00
Matt Mackall
08439e0f2d tests: add exit codes to unified tests 2010-09-16 17:51:32 -05:00
Adrian Buehlmann
8f0c161e55 tests: unify test-extdiff 2010-09-15 16:27:39 +02:00
David Wolever
7bd158b865 Updating hgext.extdiff to use revsets 2011-03-15 17:50:02 -04:00