~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-31 16:28:11 UTC
  • mfrom: (5622.3.15 more-lazy-hooks)
  • Revision ID: pqm@pqm.ubuntu.com-20110331162811-w1uw1lgpr5fiawp5
(jelmer) Support installing lazy hooks for all existing hook points,
 deprecate Hooks.create_hook. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

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