Commit Graph

132 Commits

Author SHA1 Message Date
Adrian Buehlmann
a8a418601f introduce new RequirementError (issue2649)
This improves the misleading error message

  $ hg identify
  abort: there is no Mercurial repository here (.hg not found)!

to the more explicit

  $ hg identify
  abort: requirement 'fake' not supported!

for all commands in commands.optionalrepo, which includes the identify
and serve commands in particular.

This is for the case when a new entry in .hg/requires will be defined
in a future Mercurial release.
2011-02-18 20:25:25 +01:00
Wagner Bruna
297638695f dispatch: fix typo in debug message 2011-02-16 21:02:41 -02:00
Roman Sokolov
ba47cd9ff8 dispatch: use flag cmdalias.shell for detecting shell aliases 2011-02-10 15:41:34 +03:00
Roman Sokolov
00ca6be77b dispatch: debug message for missing arguments in shell alias
Shows debug message if alias definition contains substitution variables,
but insufficient number of arguments supplied.
2011-02-11 03:46:28 +03:00
Roman Sokolov
7a0b42e376 dispatch: support for $ escaping in shell-alias definition
Sigils in shell-alias can be escaped by doubling them.
2011-02-11 03:32:40 +03:00
Adrian Buehlmann
9e0069c080 Make sure bundlerepo doesn't leak temp files (issue2491)
Add empty repository.close() and call it in dispatch.

Remove bundlerepository.__del__(), merging it into bundlerepository.close(),
which overrides repository.close().

http://docs.python.org/reference/datamodel.html says:

"It is not guaranteed that __del__() methods are called for objects that
still exist when the interpreter exits."
2011-02-12 10:58:11 +01:00
Yuya Nishihara
da93c3bd0b url: add --insecure option to bypass verification of ssl certificates
If --insecure specified, it behaves in the same way as no web.cacerts
configured.

Also shows hint for --insecure option when _verifycert() failed. But currently
the hint isn't displayed on SSLError, because it needs a certain level of
changes.
2011-01-29 23:23:24 +09:00
Steve Losh
3171599307 alias: fall back to normal error handling for ambigious commands (fixes issue2475) 2010-11-05 15:54:32 -04:00
Matt Mackall
4d7b056fed traceback: point to BugTracker on the wiki 2010-10-25 13:06:37 -05:00
Martin Geisler
b7a041ed06 dispatch: backout 3b699ee0e66d
The parenthesis may need translation too: Laurens Holst pointed out
that Japanese uses full-width parentheses: () (U+FF08 U+FF09).
2010-10-21 11:23:26 +02:00
Martin Geisler
77ce66fb6a check-code: find trailing whitespace 2010-10-20 10:13:04 +02:00
Steve Losh
0224e99d28 alias: fail gracefully when invalid global options are given (issue2442)
This patch modifies the check for shell aliases to prevent crashing when an invalid
global option is given.

When an invalid global option is given the check will simply return and let the
normal error handling for this case happen.
2010-10-17 13:24:37 -04:00
Brodie Rao
95903377bf dispatch: properly handle relative path aliases used with -R (issue2376)
This ensures the repo config is read relative to the repo root during
dispatch.
2010-10-04 15:07:12 -05:00
Brodie Rao
4236676bfc dispatch: remove superfluous try/except when reading local ui config
ui.readconfig() already handles IOError in this case.
2010-10-04 14:26:38 -05:00
Steve Losh
a6ad45cc76 alias: back up and restore commands.norepo before checking for shell aliases 2010-10-08 16:10:00 -04:00
Steve Losh
0ec78824a3 alias: only allow global options before a shell alias, pass later ones through
This patch refactors the dispatch code to change how arguments to shell aliases
are handled.

A separate "pass" to determine whether a command is a shell alias has been
added. The rough steps dispatch now performs when a command is given are these:

* Parse all arguments up to the command name.

* If any arguments such as --repository or --cwd are given (which could change
  the config file used, and therefore the definition of aliases), they are
  taken into account.

* We determine whether the command is a shell alias.

    * If so, execute the alias. The --repo and --cwd arguments are still in effect.
      Any arguments *after* the command name are passed unchanged through to the
      shell command (and interpolated as normal.

    * If the command is *not* a shell alias, the dispatching is effectively "reset"
      and reparsed as normal in its entirety.

The net effect of this patch is to make shell alias commands behave as you
would expect.

Any arguments you give to a shell alias *after* the alias name are passed
through unchanged. This lets you do something like the following:

    [alias]
    filereleased = !$HG log -r 'descendants(adds("$1")) and tagged()' -l1 $2 $3 $4 $5

    $ hg filereleased hgext/bookmarks.py --style compact

Previously the `--style compact` part would fail because Mercurial would
interpret those arguments as arguments to the alias command itself (which
doesn't take any arguments).

Also: running something like `hg -R ~/src/hg-crew filereleased
hgext/bookmarks.py` when `filereleased` is only defined in that repo's config
will now work.

These global arguments can *only* be given to a shell alias *before* the alias
name.  For example, this will *not* work in the above situation:

    $ hg filereleased -R ~/src/hg-crew hgext/bookmarks.py

The reason for this is that you may want to pass arguments like --repository to
the alias (or, more likely, their short versions like -R):

    [alias]
    own = !chown $@ `$HG root`

    $ hg own steve
    $ hg own -R steve
2010-08-24 18:25:33 -04:00
Wagner Bruna
ea2a96f4d4 i18n: unmark untranslatable string 2010-09-13 10:04:41 -03:00
Brodie Rao
9eaf2eb198 alias: on --debug, print expansion when it has invalid arguments 2010-08-27 20:45:18 -04:00
Brodie Rao
edc433c7fd alias: print what command is being shadowed in debug message 2010-08-27 20:45:11 -04:00
Martin Geisler
cb36142754 Merge with stable 2010-08-29 22:55:37 +02:00
Martin Geisler
5f46f16fb7 Lowercase error messages 2010-08-29 22:37:58 +02:00
Matt Mackall
aad5cb0594 merge with stable 2010-08-25 15:20:25 -05:00
Brodie Rao
6c64db37bc alias: make shadowing behavior more consistent (issue2054)
Currently, given an alias like the following:

    [alias]
    summary = summary --remote

The alias might be executed - or it might not - depending on the order
of the cmdtable dict.

This happens because cmdalias gets assigned back to the cmdtable like so:

    cmdtable['summary'] = ...

Yet '^summary|sum' is still in the table, so which one cmdutil.findcmd()
chooses isn't deterministic.

This patch makes cmdalias assign back to '^summary|sum'. It uses the same
cmdtable key lookup that extensions.wrapcommand() does.
2010-08-21 22:48:14 -04:00
Steve Losh
51f95d13a2 aliases: provide more flexible ways to work with shell alias arguments
This patch changes the functionality of shell aliases to add more powerful
options for working with shell alias arguments.

First: the alias name + arguments to a shell alias are set as an HG_ARGS
environment variable, delimited by spaces. This matches the behavior of hooks.

Second: any occurrences of "$@" (without quotes) are replaced with the
arguments, separated by spaces. This happens *before* the alias gets to the shell.

Third: any positive numeric variables ("$1", "$2", etc) are replaced with the
appropriate argument, indexed from 1. "$0" is replaced with the name of the
alias. Any "extra" numeric variables are replaced with an empty string.  This
happens *before* the alias gets to the shell.

These changes allow for more flexible shell aliases:

    [alias]
    echo = !echo $@
    count = !hg log -r "$@" --template='.' | wc -c | sed -e 's/ //g'
    qqueuemv = !mv "`hg root`/.hg/patches-$1" "`hg root`/.hg/patches-$2"

In action:

    $ hg echo foo
    foo

    $ hg count 'branch(default)'
    901

    $ hg count 'branch(stable) and keyword(fixes)'
    102

    $ hg qqueuemv myfeature somefeature
2010-08-18 18:56:44 -04:00
Matt Mackall
5d4700455d log: add logging for commands 2010-08-19 11:14:09 -05:00
Nicolas Dumazet
2476f9eec3 merge with stable 2010-07-31 11:41:58 +09:00
Nicolas Dumazet
576074569c dispatch: trailing whitespace 2010-07-31 11:36:24 +09:00
Matt Mackall
f93eb1deca Merge with crew 2010-07-27 16:03:42 -05:00
Dan Villiom Podlaski Christiansen
c5b2d719bd alias: improved diagnostic when arguments include --cwd, etc.
The logic pre-emptively checks for -R, --repo, --repository and --cwd
in order to give the user a more helpful error message. In addition,
each option is handled invididually, which avoids listing them all in
the error.

Before:

% hg --config alias.broken='push --cwd /dev/null' broken
abort: Option --cwd may not be abbreviated!

After:

% hg --config alias.broken='push --cwd /dev/null' broken
error in definition for alias 'broken': --cwd may only be given on the command line
2010-07-27 14:43:40 +02:00
Matt Mackall
671535ddb7 Merge with stable 2010-07-25 21:20:05 -05:00
Matt Mackall
42d9b2046b Merge with stable 2010-07-25 21:20:05 -05:00
Brodie Rao
11c127f205 alias: ensure checksignature() is applied directly to the command (issue2286)
Aliased commands that received bad arguments would raise TypeError instead of
SignatureError. This only affected commands that weren't wrapped by extensions.
Using util.checksignature() in cmdalias.__call__() ensures SignatureError is
raised correctly.
2010-07-22 15:26:26 -04:00
Mads Kiilerich
cd85e285e0 dispatch: give better error message when cwd doesn't exist (issue2293)
Previous behavior wasn't very helpful:
$ hg st foo
abort: No such file or directory

Now we tell more about what failed:
abort: error getting current working directory: No such file or directory
2010-07-24 00:38:08 +02:00
Patrick Mezard
e250cc89dc dispatch: write Abort hint to stderr too 2010-07-26 22:28:37 +02:00
Martin Geisler
8f362a460f mark ui.warn strings for translation 2010-07-16 14:44:30 +02:00
Martin Geisler
f985c9d777 Merge with stable 2010-07-16 14:45:52 +02:00
Benoit Boissinot
a13fa80461 Abort: add a hint argument, printed in the next line inside parenthesis
discovery was using a custom made message for this purpose
push now returns -1 after aborting, instead of 1 previously
2010-07-15 14:41:22 +02:00
Henrik Stuart
c4714744e5 merge stable to default 2010-07-14 20:41:01 +02:00
Steve Losh
c2cf2592b2 dispatch: add shell aliases
This patch adds git-style "shell aliases" to Mercurial.

Any alias with a definition beginning with a '!' will be treated as a shell
alias. For example:

    [alias]
    echo = !echo
    qempty = !hg qrefresh -X "`hg root`" ; echo Emptied patch "`hg qtop`"

    $ hg echo foo
    foo
    $ hg qempty
    Emptied patch foo
    $
2010-07-07 18:49:43 -04:00
Brodie Rao
6f58bfc15e color/progress: subclass ui instead of using wrapfunction (issue2096)
This resolves the issue of hg cmd --mq not being colorized. This was due
to color wrapping only the instance of ui passed to dispatch._runcommand(),
which isn't the same ui object that mq.mqcommand() receives. After dispatch
calls extensions.loadall(), it makes sure any changes to ui.__class__ in
uisetup are propagated.

progress is updated to wrap ui in the same manner because wrapfunction
doesn't play well when ui.__class__ has been replaced by another extension
(orig will point to the old class method instead of color's).
2010-07-01 19:23:26 -05:00
Mads Kiilerich
5181c38b3b debugger: give a little intro before entering pdb 2010-06-30 17:23:16 +02:00
Mads Kiilerich
9f20fc60d6 debugger: show traceback before entering pdb post-mortem 2010-06-30 17:20:42 +02:00
Chad Dombrova
22bbfbd44a provide pre- and post- hooks with parsed command line arguments.
python hooks are passed two new keyword arguments:
- opts: a dict of options; unsepcified options are set to their default
- pats: a list of arguments

shell hooks receive two new variables containing string representations
of the above data:
- $HG_OPTS
- $HG_PATS

for example, the opts and pats for 'hg -f v1.1' would be:
{'force': True, 'message': '', 'rev': '', 'user': '', 'date': '', 'local': None, 'remove': None, 'mq': None}
['v1.1']
2010-06-10 09:32:19 -07:00
Dirkjan Ochtman
64bb18f0dd cleanups: undefined variables 2010-06-08 09:30:45 +02:00
Matt Mackall
969c51b3cf error: add new ParseError for various parsing errors 2010-06-04 20:57:26 -05:00
Matt Mackall
13c76ff349 error: change ParseError to CommandError 2010-06-04 20:19:53 -05:00
Martin Geisler
efb421d772 Merge with stable 2010-05-21 14:21:27 +02:00
Martin Geisler
b064e04066 dispatch: include Python version in traceback 2010-05-21 13:40:59 +02:00
Martin Geisler
cbc9868177 Merge with stable 2010-05-01 16:15:27 +02:00
Dan Villiom Podlaski Christiansen
16da932a11 dispatch: don't mangle ImportError abort messages
Previously, Mercurial assumed that the last word of the string
representation was the name of the moduled that was imported. This
assmption is incorrect, despite being true for the common case of an
exception raised by the Python VM.

For example, hgsubversion raises an ImportError with a helpful message
if the Subversion bindings were not found. The final word of this
message is not meaningful on its own, and is never the name of a
module.

This patch changes the output printed to be a simple stringification
of the exception instance. In most cases, this will be `abort: No
module named X!' rather than `abort: could not import module X!'.

No functionality change; all tests pass.
2010-04-30 18:11:56 +02:00