Commit Graph

158 Commits

Author SHA1 Message Date
Pierre-Yves David
f95a6cfc12 error: Add a hint argument to RepoError
This use the same mechanism than Abort. Except clause stay distinct
because RepoError add "!" at the end of the message.
2011-06-25 02:30:17 +02:00
Idan Kamara
a1bff0c5fe dispatch: set config options on the request repo.ui 2011-06-24 19:44:59 +03:00
Idan Kamara
f0f55bda59 dispatch: return read config options 2011-06-24 19:44:59 +03:00
Idan Kamara
122edf3c57 dispatch: set global options on the request repo.ui
If the request has a repo, and global options such as --verbose are passed,
we need to set those explicitly on the repo.ui.
2011-06-24 19:44:58 +03:00
Idan Kamara
ff97debbbd dispatch: make sure unspecified global ui options don't override old values 2011-06-24 12:16:14 +03:00
Idan Kamara
c368cbab93 dispatch: set descriptors on the request repo.ui 2011-06-24 19:38:28 +03:00
Idan Kamara
22edb918b3 dispatch: pass the correct ui to runcommand
For commands that take a repo, repo.ui is passed as the ui to runcommand.
This restores that behaviour when the request has a repo.
2011-06-24 19:36:44 +03:00
Idan Kamara
848255e076 dispatch: check for None before closing repo
We were trying to call close() if repo == None and req.repo != None.
This can happen when running commands that don't take a repo.
2011-06-24 16:30:43 +03:00
Idan Kamara
27964e7418 dispatch: do not close the request repo
Closing here means we've closed the repo passed to us in the request,
which is not our responsibility.

This is essential for bundlerepo, and possibly other localrepository
subclasses who do something in their close().
2011-06-21 17:08:21 +03:00
David Soria Parra
881ac28f17 i18n: remove translation of debug messages 2011-06-21 18:35:13 +02:00
Martin Geisler
01ba8f6e18 Backed out changeset 48c996bf6ba4
Debug messages should not be translated.
2011-06-21 14:57:17 +02:00
David Soria Parra
81153f2f12 dispatch: translate alias debugging messages 2011-06-21 13:24:19 +02:00
Idan Kamara
5e2d608efc dispatch: write shell alias output to ui out descriptor 2011-06-07 13:39:09 +03:00
Idan Kamara
c2b2fe4489 dispatch: fix for-loop variable name 2011-06-14 20:25:38 +03:00
Idan Kamara
c08a096623 dispatch: assign I/O descriptors from the request to the ui 2011-06-08 14:54:47 +03:00
Idan Kamara
e05ad378b0 dispatch: add I/O descriptors to the request 2011-06-07 13:39:09 +03:00
Idan Kamara
b335d3e278 dispatch: propagate ui command options to the local ui (issue2523)
so the ui object passed to pre/post python hooks has the verbose flag
(and the rest) set correctly
2011-06-13 00:19:26 +03:00
Idan Kamara
a910ab36b8 dispatch: add repo to the request
allows callers of dispatch.dispatch to pass in
an initialized repo object to be used.

-R/--repository overrides the request repo.
2011-06-02 00:43:34 +03:00
Idan Kamara
b9dc5b5bf7 dispatch: use the request to store the ui object
and check if we got one before creating.

note that the contents of the ui object might change after
dispatch() returns (by options passed through --config for example),
to ensure it doesn't, pass a copy() of it.
2011-05-26 00:53:23 +03:00
Idan Kamara
5544ef8f07 dispatch: wrap dispatch related information in a request class
currently only stores the arguments.
2011-05-26 00:44:11 +03:00
Martin Geisler
58a533fee9 help: add -c/--command flag to only show command help (issue2799) 2011-05-10 14:42:53 +02:00
Alexander Solovyov
325788efb7 add positional arguments to non-shell aliases 2011-05-01 12:29:32 +02:00
Dan Villiom Podlaski Christiansen
1eaa37ca32 dispatch: handle IndexErrors 2011-05-01 11:01:57 +02:00
Idan Kamara
762d333ae9 eliminate various naked except clauses 2011-04-23 00:51:25 +03:00
Matt Mackall
a33ce77f33 dispatch: improve repository not found message
This should help clarify what the problem is in various problematic
cases like ssh.
2011-04-20 14:28:40 -05:00
Adrian Buehlmann
3efb31d590 help: do not show full help text for command on option errors
Example

  $ hg clone --jump foo bar
  hg clone: option --jump not recognized
  hg clone [OPTION]... SOURCE [DEST]

  make a copy of an existing repository

  options:

   -U --noupdate           the clone will include an empty working copy (only a
                           repository)
   -u --updaterev REV      revision, tag or branch to check out
   -r --rev REV [+]        include the specified changeset
   -b --branch BRANCH [+]  clone only the specified branch
      --pull               use pull protocol to copy metadata
      --uncompressed       use uncompressed transfer (fast over LAN)
   -e --ssh CMD            specify ssh command to use
      --remotecmd CMD      specify hg command to run on the remote side
      --insecure           do not verify server certificate (ignoring
                           web.cacerts config)

  [+] marked option can be specified multiple times

  use "hg help clone" to show the full help text

Motivation for this change

  If the user already has specified the command, he probably already knows
  the command to some extent. Apparently, he has a problem with the options,
  so we show him just the synopsis with the short help and the details about
  the options, with a hint on the last line how to get the full help text.

Why is Mercurial better with this change?

  Experts who just forgot about the details of an option don't get that
  much text thrown at them, while the newbies still get a hint on the last
  line how to get the full help text.
2011-04-17 11:37:11 +02:00
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