Commit Graph

70 Commits

Author SHA1 Message Date
Ed Morley
33ad7df82b extensions: use normpath to allow trailing '\' on Windows (issue4187)
Fixes same issue as 3dadbacb6aa4 but now works on Windows too.

With this patch a trailing backward slash won't prevent the extension from
being found on Windows, and we continue to support any combination of forward
and back slashes within the path.
2014-03-05 09:31:05 +00:00
Matt Mackall
66c8bd54e8 extensions: remove the inotify extension (BC)
This extension has always had correctness issues and has been
unmaintained for years. It is now removed in favor of the third-party
hgwatchman which is maintained and appears to be correct.

Users with inotify enabled in their config files will fall back to
standard status performance.
2014-03-01 16:20:15 -06:00
FUJIWARA Katsunori
495b98fa37 extensions: list up only enabled extensions, if "ui" is specified
Before this patch, "extensions.extensions()" always lists up all
loaded extensions. So, commands handling multiple repositories at a
time like below enable extensions unexpectedly.

  - clone from or push to localhost: extensions enabled only in the
    source are enabled also in the destination

  - pull from localhost: extensions enabled only in the destination
    are enabled also in the source

  - recursive execution in subrepo tree: extensions enabled only in
    the parent or some of siblings in the tree are enabled also in
    others

In addition to it, extensions disabled locally may be enabled
unexpectedly.

This patch checks whether each of extensions should be listed up or
not, if "ui" is specified to "extensions.extensions()", and invokes
"reposetup()" of each extensions only for repositories enabling it.
2013-09-21 21:33:29 +09:00
FUJIWARA Katsunori
af33f66d43 help: use full name of extensions to look up them for keyword search
Before this patch, "hg help -k KEYWORD" fails, if there is the
extension of which name includes ".", because "extensions.load()"
invoked from "help.topicmatch()" fails to look such extension up, even
though it is already loaded in.

"help.topicmatch()" invokes "extensions.load()" with the name gotten
from "extensions.enabled()". The former expects full name of extension
(= key in '[extensions]' section), but the latter returns names
shortened by "split('.')[-1]". This difference causes failure of
looking extension up.

This patch adds "shortname" argument to "extensions.enabled()" to make
it return shortened names only if it is True. "help.topicmatch()"
turns it off to get full name of extensions.

Then, this patch shortens full name of extensions by "split('.')[-1]"
for showing them in the list of extensions.

Shortening is also applied on names gotten from
"extensions.disabled()" but harmless, because it returns only
extensions directly under "hgext" and their names should not include
".".
2013-09-23 20:23:25 +09:00
Kevin Bullock
f74ef64c15 extensions: remove erroneous comment
We actually -do- use the 'ui' argument to print a debug statement.
2013-02-14 13:56:02 -06:00
Angel Ezquerra
4651989f9b extensions: obsolete and remove interhg extension
With the addition of the websub filter extension this extension is no longer
needed. We maintain a sort of backwards compatibility by reading the [interhg]
section and using it as we would use the [websub] section.
2013-02-09 11:00:42 +01:00
Simon Heimberg
8eb4380be9 hooks: print out more information when loading a python hook fails
When loading a python hook with file syntax fails, there is no
information that this happened while loading a hook. When the python
file does not exist even the file name is not printed. (Only that a
file is missing.)

This patch adds this information and a test for loading a non existing file and
a directory not being a python module.
2012-07-06 18:41:25 +02:00
Augie Fackler
52177e47bf extensions.disabled: return {} instead of None no extensions are disabled 2012-05-13 04:06:07 -05:00
Martin Geisler
7724ee63b3 extensions: don't suggest commands from deprecated extensions 2012-05-11 14:00:51 +02:00
Augie Fackler
587cefc90e extensions: fix documentation of disabledcmd return value 2012-05-11 04:33:33 -05:00
Greg Ward
122fc5d49f extensions: print some debug info on import failure
This is handy if hgext.foo exists but has a bogus "import blah":
previously we just discarded the "No module named blah" error. Now at
least you can see it with --debug. Not perfect, but better than
nothing.
2011-10-01 16:42:39 -04:00
Augie Fackler
fdd2f9d735 globally: use safehasattr(x, '__call__') instead of hasattr(x, '__call__') 2011-07-25 16:24:37 -05:00
Yuya Nishihara
5c2b085d52 extensions: make disabled()/disabledext() load prebuilt index if available
__index__ contains a dict of {name: desc} of all extensions.
2011-06-04 20:19:30 +09:00
Yuya Nishihara
e900ecac29 extensions: update doc of enabled() and disabled() according to 96b1098c07ee 2011-06-04 20:01:01 +09:00
Idan Kamara
d5c206ffa2 extensions: raise when trying to find an extension that failed to load
extensions that depend on other extensions (such as record) use this pattern
to check if the dependant extension is available:

    try:
        mq = extensions.find('mq')
    except KeyError:
        return

but since if an error occurs while loading an extension it leaves its entry
in the _extensions map as None, we want to raise in that situation too.

(rather than adding another check if the return value is None)
2011-05-23 23:09:00 +03:00
Matt Mackall
1d5abac148 help: consolidate topic hooks in help.py
This removes loops like cmdutil->revset->help->extensions->cmdutil and
simplifies the code.
2011-05-13 12:57:27 -05:00
Matt Mackall
9fd29f01e9 extensions: move moduledoc to break import loop with help 2011-05-13 11:04:51 -05:00
Matt Mackall
d184ed2af2 extensions: drop maxlength from enabled and disabled
This is a bad/silly API. Instead calculate maxlength in one place in help
it's used and simplify all the callers.
2011-05-13 11:04:51 -05:00
Kevin Gessner
bf8c80ca9d extensions: obsolete and remove parentrevspec extension
As of 48639b58ef80, revsets implements the ^ and ~ operators that this
extension provides, so it's no longer necessary.
2011-04-30 18:27:39 +02:00
Matt Mackall
d27d1fae16 bookmarks: move push/pull command features to core 2011-02-10 13:46:28 -06:00
Matt Mackall
906534053e extensions: add an ignore list for old extensions 2011-02-10 13:46:27 -06:00
Mads Kiilerich
b89ce1b270 extensions: warn about invalid extensions when listing disabled commands
Invalid extensions in hgext/ could in some cases cause a crash when searching
for unknown commands in disabled extensions.

With this change we issue a warning if extracting commands from the extensions
fails. Traceback is available on request.

Reported on https://bugzilla.redhat.com/show_bug.cgi?id=663183 with forest.py.
2010-12-26 00:43:49 +01:00
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