~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-03-07 16:49:22 UTC
  • mfrom: (5685.1.2 revspec-lazy-imports)
  • Revision ID: pqm@pqm.ubuntu.com-20110307164922-h4ny7ro3g0k9bi9e
(jelmer) More lazy loading in bzrlib.revisionspec. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from bzrlib.lazy_import import lazy_import
29
29
lazy_import(globals(), """
 
30
import codecs
30
31
import errno
31
32
import threading
 
33
from warnings import warn
32
34
 
33
35
import bzrlib
34
36
from bzrlib import (
40
42
    osutils,
41
43
    trace,
42
44
    ui,
 
45
    win32utils,
43
46
    )
44
47
""")
45
48
 
46
 
from bzrlib.hooks import Hooks
 
49
from bzrlib.hooks import HookPoint, Hooks
47
50
# Compatibility - Option used to be in commands.
48
51
from bzrlib.option import Option
49
52
from bzrlib.plugin import disable_plugins, load_plugins
772
775
        These are all empty initially, because by default nothing should get
773
776
        notified.
774
777
        """
775
 
        Hooks.__init__(self, "bzrlib.commands", "Command.hooks")
776
 
        self.add_hook('extend_command',
 
778
        Hooks.__init__(self)
 
779
        self.create_hook(HookPoint('extend_command',
777
780
            "Called after creating a command object to allow modifications "
778
781
            "such as adding or removing options, docs etc. Called with the "
779
 
            "new bzrlib.commands.Command object.", (1, 13))
780
 
        self.add_hook('get_command',
 
782
            "new bzrlib.commands.Command object.", (1, 13), None))
 
783
        self.create_hook(HookPoint('get_command',
781
784
            "Called when creating a single command. Called with "
782
785
            "(cmd_or_None, command_name). get_command should either return "
783
786
            "the cmd_or_None parameter, or a replacement Command object that "
784
787
            "should be used for the command. Note that the Command.hooks "
785
788
            "hooks are core infrastructure. Many users will prefer to use "
786
789
            "bzrlib.commands.register_command or plugin_cmds.register_lazy.",
787
 
            (1, 17))
788
 
        self.add_hook('get_missing_command',
 
790
            (1, 17), None))
 
791
        self.create_hook(HookPoint('get_missing_command',
789
792
            "Called when creating a single command if no command could be "
790
793
            "found. Called with (command_name). get_missing_command should "
791
794
            "either return None, or a Command object to be used for the "
792
 
            "command.", (1, 17))
793
 
        self.add_hook('list_commands',
 
795
            "command.", (1, 17), None))
 
796
        self.create_hook(HookPoint('list_commands',
794
797
            "Called when enumerating commands. Called with a set of "
795
798
            "cmd_name strings for all the commands found so far. This set "
796
799
            " is safe to mutate - e.g. to remove a command. "
797
800
            "list_commands should return the updated set of command names.",
798
 
            (1, 17))
 
801
            (1, 17), None))
799
802
 
800
803
Command.hooks = CommandHooks()
801
804