Commit Graph

48 Commits

Author SHA1 Message Date
Erik Zielke
1c7a5f9d36 extensions.load: return module
Makes extensions.load return the module that
it has loaded.

This is done so that callers can get information on this module, which
e.g. can be used for generating docs.
2010-10-19 13:43:40 +02:00
Dan Villiom Podlaski Christiansen
11602a3741 extensions: add a few assertions to wrapfunction() and wrapcommand().
Specifically, assert that the given wrapper is callable in both
functions, and assert that the original was also callable in
wrapfunction().
2010-07-09 11:04:00 +02:00
Dan Villiom Podlaski Christiansen
50d47676be extensions: improve language for wrapfunction() docstring. 2010-07-09 11:13:45 +02:00
Dan Villiom Podlaski Christiansen
5987e4e005 extensions: add docstring for wrapcommand(). 2010-07-09 10:57:57 +02:00
Greg Ward
0756f7dc65 extensions: recommend against using wrapfunction for repo methods
Instead, all extensions should use the "dynamic subclass" trick:
subclass repo.__class__ and then replace repo.__class__ with your new
subclass.  This avoids conflicts that happen when one extension uses
wrapfunction and another uses subclassing to extend the same method of
localrepository.
2010-06-15 13:04:22 -04: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
Brodie Rao
b0f0c580fa extensions: refactor disabled() 2010-02-07 11:32:08 +01:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -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
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
Nicolas Dumazet
7eadbe8d42 for calls expecting bool args, pass bool instead of int
str.splitlines and email.message.as_string both expect a bool argument
defaulting at False: replace f(1) by f(True) and f(0) by f()
2009-07-13 09:50:26 +09:00
Cédric Duval
1fafb1baee extensions: remove dead code
enabled used to be a boolean, and somehow that bit of code inadvertently
slipped through during a refactoring. Effectively dead code, as the
condition can never be triggered.
2009-07-04 12:06:33 +02:00
Cédric Duval
1a0b6e0ded extensions: catch OSError when hgext is not accessible (issue1708)
Temporary workaround for issue1708: on win32 with py2exe, hgext is distributed
inside a zipped file (which anyway does not contain the py files from which we
ought to extract the documentation strings), which raises a WindowsError
(subclasses OSError).

This means that on such platforms the list of disabled extensions won't be
available. Real fix postponed for after Mercurial 1.3.
2009-06-29 19:28:54 +02:00
Cédric Duval
295c588e3f extensions: remove import rendered unnecessary by 69a0fe38731b 2009-06-21 20:34:58 +02:00
Cédric Duval
f2fdd668fb extensions: use _order to determine if an extension is enabled 2009-06-21 17:19:34 +02:00
Cédric Duval
18fcf35d02 extensions: check for path existence only when necessary 2009-06-21 17:18:48 +02:00
Dirkjan Ochtman
ac890b2ded extensions: remove now-useless pathdirs() function 2009-06-21 17:35:04 +02:00
Dirkjan Ochtman
173d136a98 extensions: simplify by selecting primary hgext 2009-06-21 16:35:44 +02:00
Cédric Duval
17141a61d0 extensions: move extensions listing functions from mercurial.help
Includes some small fix-ups to comments in enabled() and disabled().
2009-06-21 16:32:00 +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
Alexander Solovyov
86b994e311 extensions loading: don't fail if path to extension ends with a '/' 2009-04-01 12:11:14 +03:00
Alexander Solovyov
609db13729 ability to load hooks from arbitrary python module 2009-03-27 01:28:09 +02:00
Peter Arrenbrecht
ce6e853a0b cleanup: drop enumerate() when index is not used 2009-03-23 13:13:11 +01:00
Matt Mackall
7f3bf9b19d error: move SignalInterrupt
now derived from KeyboardInterrupt to simplify catches
2009-01-12 11:48:05 -06:00
Matt Mackall
648df6f0b1 dispatch: generalize signature checking for extension command wrapping 2008-11-18 16:02:14 -06:00
Dirkjan Ochtman
367d64160c extensions: copy __module__ for wrapped commands 2008-11-14 14:17:42 +01:00
Matt Mackall
26ddb1a665 extensions: add wrapping functions 2008-10-22 17:34:50 -05:00
Benoit Boissinot
7ba2d57a89 Do not try to load extensions twice (issue811) 2008-09-09 14:43:12 +02:00
Joel Rosdahl
4f8012378a Remove unused imports 2008-03-06 22:23:41 +01:00
Jesse Glick
5a5b96808a When failing to load an extension, show where Hg tried to load it from. 2008-03-03 12:46:57 -05:00
Steve Borho
1ddcdfe3e8 Allow explicit disabling of extensions
If the first character of an extension path is '!', the extension
is silently skipped.
2007-09-18 19:53:01 -05: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
Brendan Cully
c8c558a817 Merge with crew-stable 2007-08-09 11:37:47 -07:00
Brendan Cully
38822453d6 Cache extension load failures.
hg commands call extensions.loadall twice, once during dispatch and
once when the repository is instantiated. Without this change, load
caches successful loads, but not unsuccessful, causing errors to be
displayed twice.
2007-08-08 18:04:06 -07:00
Bryan O'Sullivan
f2fb8a0b42 extensions: don't get confused by aliasing between "foo" and "hgext.foo" 2007-07-30 14:53:03 -07:00
Matt Mackall
dc9134201b extensions: untangle some recursive dependencies 2007-07-05 15:37:23 -05:00
Thomas Arendsen Hein
4d29c6dc8e Updated copyright notices and add "and others" to "hg version" 2007-06-19 08:51:34 +02:00
Thomas Arendsen Hein
483231d996 Cleanup of whitespace, indentation and line continuation. 2007-06-19 08:06:37 +02:00
Matt Mackall
8395ca26f3 extensions: pull extension-aware bits out of ui 2007-06-18 13:24:34 -05:00
Thomas Arendsen Hein
75327fd456 merge with main 2007-06-14 11:33:32 +02:00
Brendan Cully
9b610cb44c extensions: fix load of module/__init__.py on OS X 2007-06-13 19:05:20 -07:00
Brendan Cully
e96607cf35 extensions: load modules in module/__init__.py form.
For example, convert=/path/to/convert now works.
2007-06-13 13:46:40 -07:00
Matt Mackall
123d0f2541 extensions: fix lookup of hgext.foo modules 2007-06-13 13:15:53 -05:00
Matt Mackall
42349e08dc extensions: add missing sys import 2007-06-12 10:34:54 -05:00
Matt Mackall
67bd5873db Create a separate module for managing extensions 2007-06-11 21:09:23 -05:00