Commit Graph

145 Commits

Author SHA1 Message Date
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
Simon Heimberg
4b52c68f90 dispatch: ignore if signals can not be set
This happens if the code is executed in a thread.
This patch allows tortoisehg to start the inotify server again.
2010-04-07 02:41:22 +02:00
Matt Mackall
399ebe1c0f Merge with stable 2010-04-19 17:00:02 -05:00
Martin Geisler
5cb99e439d Merge with stable 2010-03-31 17:32:19 +02:00
Alexander Solovyov
3283fbd2f5 expand paths in aliases 2010-03-27 13:39:45 +02:00
Benoit Boissinot
3db7df2869 style: use consistent variable names (*mod) with imports which would shadow 2010-03-11 17:43:44 +01:00
Yuya Nishihara
c01490d7d8 alias: fixes exception when displaying translated help text
__doc__ of aliased command shouldn't cointain non-ASCII characters,
because it'll be gettext-ed later by commands.help_().
Here gettext can raise UnicodeDecodeError.

Once concatenated two translatable strings into one, it become untranslatable.
So this patch moves 'alias for:' from dispatch.cmdalias to commands.help_,
where help texts are translated.

'alias for:' was introduced by 027d5c280eda.
2010-03-01 23:27:44 +09:00
Brendan Cully
3743c1ee43 mq: make init -Q do what qinit -c did 2010-02-08 10:50:00 +01:00
Brodie Rao
91c6eab10f dispatch: provide help for disabled extensions and commands
Before a command is declared unknown, each extension in hgext is searched,
starting with hgext.<cmdname>. If there's a matching command, a help message
suggests the appropriate extension and how to enable it.

Every extension could potentially be imported, but for cases like rebase,
relink, etc. only one extension is imported.

For the case of "hg help disabledext", if the extension is in hgext, the
extension description is read and a similar help suggestion is printed.
No extension import occurs.
2010-02-07 14:01:43 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Nicolas Dumazet
686db2d57f alias: do not crash when aliased command has no usage help text 2009-12-03 14:14:44 +09:00
Bill Schroeder
a75ddfba7d dispatch: better error message for --config option 2009-11-04 13:44:15 -06:00
Benoit Boissinot
80a458a464 pychecker: remove unused local variables 2009-10-31 17:04:46 +01:00
Yuya Nishihara
ac33bbc42b extensions: changed to call extsetup() from extensions.loadall()
previously uisetup() was invoked by extensions.loadall(), but
extsetup() was by _dispatch().

there's no need to split them because we have nothing to do
between uisetup() and extsetup().

this fixes issue1824 indirectly.
2009-10-28 23:55:23 +09:00
Alexander Solovyov
32999e4659 make path expanding more consistent
This expands ~user and $FOO constructs in ui.ignore files, [defaults],
[paths], extension paths, and HGRCPATH files.
2009-10-19 22:19:28 +03:00
Martin Geisler
969ff27288 Merge with crew-stable 2009-09-19 13:55:18 +02:00
Martin Geisler
af0872c777 dispatch: catch ConfigError while constructing ui 2009-09-19 13:52:54 +02:00
Martin Geisler
9f1896c083 do not attempt to translate ui.debug output 2009-09-19 01:15:38 +02:00
Andrey Somov
2ccddf5ead improve code readability 2009-09-09 11:12:36 +02:00
Simon Heimberg
fac4c72eee extensions: pass ui arguement to extsetup if accepted 2009-08-16 00:41:24 +02:00
Martin Geisler
559ff1708d extensions: load and configure extensions in well-defined phases
Extensions are now loaded with a call-graph like this:

  dispatch._dispatch
      extensions.loadall
          extensions.load
                # add foo module to extensions._extensions
          extensions.load
                # add bar module to extensions._extensions

          foo.uisetup(ui)
          bar.uisetup(ui)

      foo.extsetup()
      bar.extsetup()

      commands.table.update(foo.cmdtable)
      commands.table.update(bar.cmdtable)

  hg.repository
      foo.reposetup(ui, repo)
      bar.reposetup(ui, repo)

The uisetup calls could easily be moved out to dispatch._dispatch, but
have been kept in extensions.loadall since at least TortoiseHg calls
extensions.loadall and expects it to call uisetup.

The extensions.load function called uisetup. It now has an unused ui
argument which has been kept for backwards compatibility.
2009-08-29 00:29:16 +02:00
Dirkjan Ochtman
1d29e68744 change wiki/bts URLs to point to new hostname 2009-06-24 15:32:37 +02:00
Martin Geisler
16155b528f merged with crew 2009-06-21 19:06:57 +02:00
Sune Foldager
f5c1bbf245 translated a bunch of strings to danish 2009-06-20 19:46:01 +02:00
Brendan Cully
5189b36798 Move alias into core 2009-05-30 11:32:23 -07:00
Dirkjan Ochtman
605b944edf kill trailing whitespace 2009-06-19 13:47:50 +02:00
Brodie Rao
bf35ee672b help: don't display bogus help messages for invalid aliases 2009-12-05 23:26:27 -05:00
Henrik Stuart
f8df6b526d Merge with stable 2009-12-03 06:35:39 +01:00
Peter Arrenbrecht
995f74f0cd alias: improve help text for command aliases
Displays the line "alias for: hg ..." with the original command including options,
followed by the command's original help text.
2009-11-11 17:48:00 +01:00
Henri Wiechers
6284050410 dispatch: minor refactoring
Renamed local variable i to entry in _dispatch.
2009-11-13 16:38:27 +02:00
Martin Geisler
ca3bc4a9ab dispatch: remember loaded extensions in a real set 2009-05-07 17:56:57 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Matt Mackall
de487eacda ui: print_exc() -> traceback() 2009-04-26 16:50:44 -05:00
Matt Mackall
be7d59ab85 ui: kill most users of parentui name and arg, replace with .copy() 2009-04-26 16:50:43 -05:00
Matt Mackall
e8b3de6bf8 ui: introduce new config parser 2009-04-23 15:40:10 -05:00
Matt Mackall
0174734c46 ui: kill updateopts
Move setconfig into dispatch._parseconfig
2009-04-23 15:40:10 -05:00
Matt Mackall
ebffe5ccb8 ui: refactor option setting
No more passing options as constructor keywords. Basic options are now
always stored in the overlay for simplicity and consistency.
2009-04-23 15:40:10 -05:00
Nicolas Dumazet
6ebdee6dde profiling: Adding support for kcachegrind output format, using lsprofcalltree 2009-04-08 14:20:57 +02:00
Nicolas Dumazet
f2cfd93c8c profiling: Adding a profiling.format config variable
Allows defining other output formats for profiling.

If an invalid format is given, output a warning and ignore it.
For now, only the standard 'text' value is supported.
2009-04-02 16:01:30 +09:00
Nicolas Dumazet
14ff1a53ae profiling: Adding profiling.output config variable
If specified, outputs profiling data to the said file.
Prints to stderr by default
2009-04-08 14:19:41 +02:00
Nicolas Dumazet
b87b90da60 profiling: dropping hotshot profiling. --profile as a unique profiling option
hotshot was an experimental module, which is broken for Python < 2.5
And even for Python >= 2.5 users, hotshot usage is discouraged: cProfile
(formerly lsprof) should be used instead.
2009-04-08 14:18:20 +02:00
Matt Mackall
642f4d7151 move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.
2009-04-03 14:51:48 -05:00
Peter Arrenbrecht
bc21361ed2 cleanup: drop unused imports 2009-03-23 13:12:07 +01:00
Bill Barry
8ac447bbd7 dispatch: extract command execution block into method
This pulls the pre-command hook/command/post-command hook workflow out of
the method it is in and puts it into its own method so that it potentially
could be exposed for extensions to wrap.
2009-02-12 09:36:15 -07:00
Augie Fackler
7131a2f8b7 fancyopts: Parse options that occur after arguments.
This changes the behavior of qguard in the case of setting negative guards, as -- will now always be required.
Fixes issue1402.
Doc fixes for mq by mpm.
2009-02-10 13:26:00 -06:00
Matt Mackall
3296a955b6 warn if --repository provided for norepo commands 2009-01-28 14:27:44 -06:00
Matt Mackall
104a85dee5 error: move SignatureError 2009-01-12 13:51:43 -06:00
Matt Mackall
9db9afd227 dispatch: sort exception handlers 2009-01-12 13:35:35 -06:00
Matt Mackall
7f3bf9b19d error: move SignalInterrupt
now derived from KeyboardInterrupt to simplify catches
2009-01-12 11:48:05 -06:00
Matt Mackall
e61d364b61 error: move UnknownCommand and AmbiguousCommand 2009-01-12 11:39:38 -06:00
Matt Mackall
534da54d07 error: move UnexpectedOutput (now ResponseError) 2009-01-12 11:28:28 -06:00
Matt Mackall
76c90d50e6 error: move lock errors
rename LockException to LockError
2009-01-12 11:09:14 -06:00
Matt Mackall
e0735a1762 error: move repo errors
rename NoCapability to CapabilityError
2009-01-12 10:42:31 -06:00
Matt Mackall
d3bf622cc2 error: move ParseError 2009-01-11 23:04:24 -06:00
Matt Mackall
d15d559b7c errors: move revlog errors
- create error.py for exception classes to reduce demandloading
- move revlog exceptions to it
- change users to import error and drop revlog import if possible
2009-01-11 22:48:28 -06:00
Matt Mackall
356502607f refactor version code
- simplify version detection code
- move detection code into setup.py
- move version reading function into util.py
- drop version.py code

This makes hg more closely follow its own recommendation of how to deal with
versioning your builds: use hg id in your build script.
2009-01-10 18:02:38 -06:00
Benoit Boissinot
4668c151a4 use inst.args instead of using __getitem__ directly
DeprecationWarning: __getitem__ not supported for exception classes in 3.x;
use args attribute
2008-12-06 15:57:11 +01:00
Matt Mackall
648df6f0b1 dispatch: generalize signature checking for extension command wrapping 2008-11-18 16:02:14 -06:00
Benoit Boissinot
ea7fe6dacc remove unused variables 2008-10-28 19:25:26 +01:00
Thomas Arendsen Hein
ba25030ab6 Minor cleanup: Add missing space forgotten in recent change. 2008-10-23 19:27:25 +02:00
Matt Mackall
bebeb261d5 findcmd: have dispatch look up strict flag 2008-10-22 17:34:08 -05:00
Benoit Boissinot
ebcbcef11c merge with -stable 2008-09-06 17:04:01 +02:00
Benoit Boissinot
61cdb0bdd6 show extensions loaded on traceback 2008-09-05 10:00:57 +02:00
Benoit Boissinot
d179cdfe82 a socket error might be a tuple or a singleton 2008-09-06 00:45:13 +02:00
Joel Rosdahl
c26213193c Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg 2008-03-06 22:51:16 +01:00
Joel Rosdahl
5dae3059a0 Expand import * to allow Pyflakes to find problems 2008-03-06 22:23:26 +01:00
Jesse Glick
d21d195944 Infer a --repository argument from command arguments when reasonable.
In particular: if invoked without -R from a CWD not inside a repo, having been
passed one or more file paths as command arguments, where the nearest enclosing
repo of all of those paths is the same, quietly infer a -R option for that repo.
Otherwise abort with an error message as before.
2008-01-25 04:11:32 -05:00
Thomas Arendsen Hein
6f399a19b1 merge backout 2008-02-18 19:21:33 +01:00
Thomas Arendsen Hein
4d33c02751 Backed out changeset 8105fa3c7347 (see issue971/msg5317) 2008-02-18 19:20:22 +01:00
Bryan O'Sullivan
dfa3e1ea9b profiling: allow CGI and FastCGI to be profiled 2008-02-01 13:09:45 -08:00
Matt Mackall
d743a8c08a hooks: fix pre- and post- hooks specified in .hg/hgrc
We were looking up hooks in the wrong ui object. Also, we weren't
handling hooks to commands without a repo.
2008-01-18 09:03:17 -06:00
Kirill Smelkov
e928c8fcaf dispatch: allow extensions to provide setup code
we'll need this soon, when record extension will optionally depend
on mq early -- when preparing cmdtable.

Also, if accepted, ExtensionHowto wiki should be updated as well.
2008-01-10 12:07:18 +03:00
Peter Arrenbrecht
18fb9f5e5e Fix income/pull with bundle and -R (issue 820).
Uses ui.setconfig() to tell bundlerepo where the main repo is. This is
needed for when the --repository option is used.

Adds tests to test-bundle and a new test script
test-mq-pull-from-bundle, which plays out the situation that initially
made me detect this bug

(hg -R .hg/patches pull ../bundle.hg).
2007-12-18 14:11:13 -06:00
Matt Mackall
2b6b8e4e67 dispatch: report OOM rather than traceback 2007-12-10 10:23:45 -06:00
Matt Mackall
ad28be7c23 i18n: fix complaints from pygettext 2007-11-20 15:54:25 -06:00
Alexis S. L. Carvalho
e073cf982f Set bundle.mainreporoot only after checking that it's a local repo
Fixes issue977.
2008-02-14 18:08:16 -02:00
Bryan O'Sullivan
b945cf7339 profile: expand PID in output file name 2008-02-01 13:31:46 -08:00
Alexis S. L. Carvalho
d11dad17a3 Remove demandimport.enable from dispatch.py 2007-08-18 14:25:55 -03:00
Alexis S. L. Carvalho
0f222fbdf3 Move enabling of demandimport to dispatch.py
This avoids loading many modules before enabling demandimport.
2007-08-17 17:33:27 -03:00
Alexis S. L. Carvalho
dc23a7db18 Move cmdtable and reposetup handling out of extensions.py
A new function (extensions.extensions) allows the code that is
interested in those attributes to handle them directly.

This allows some cleanups of extensions.py.  Notably, we can
remove the extensions.commandtable hack.

It also makes it easier to add standard extension attributes,
like a "hgwebsetup" function or a "helptable" dict that augments
the data in help.py, etc.
2007-08-17 17:33:27 -03:00
Matt Mackall
c08427e0e8 dispatch: move command dispatching into its own module
- move command dispatching functions from commands and cmdutil to dispatch
- change findcmd to take a table argument
- remove circular import of commands in cmdutil
- privatize helper functions in dispatch
2007-08-15 16:55:13 -05:00