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
396
397
sys.stdout is forced to be a binary stream, and line-endings
397
398
will not mangled.
400
A string indicating the real name under which this command was
401
invoked, before expansion of aliases.
402
(This may be None if the command was constructed and run in-process.)
404
400
:cvar hooks: An instance of CommandHooks.
406
401
:ivar __doc__: The help shown by 'bzr help command' for this command.
407
402
This is set by assigning explicitly to __doc__ so that -OO can
697
691
return self.run(**all_cmd_args)
699
693
# reset it, so that other commands run in the same process won't
700
# inherit state. Before we reset it, log any activity, so that it
701
# gets properly tracked.
702
ui.ui_factory.log_transport_activity(
703
display=('bytes' in debug.debug_flags))
704
695
trace.set_verbosity_level(0)
706
697
def _setup_run(self):
785
772
These are all empty initially, because by default nothing should get
788
Hooks.__init__(self, "bzrlib.commands", "Command.hooks")
789
self.add_hook('extend_command',
776
self.create_hook(HookPoint('extend_command',
790
777
"Called after creating a command object to allow modifications "
791
778
"such as adding or removing options, docs etc. Called with the "
792
"new bzrlib.commands.Command object.", (1, 13))
793
self.add_hook('get_command',
779
"new bzrlib.commands.Command object.", (1, 13), None))
780
self.create_hook(HookPoint('get_command',
794
781
"Called when creating a single command. Called with "
795
782
"(cmd_or_None, command_name). get_command should either return "
796
783
"the cmd_or_None parameter, or a replacement Command object that "
797
784
"should be used for the command. Note that the Command.hooks "
798
785
"hooks are core infrastructure. Many users will prefer to use "
799
786
"bzrlib.commands.register_command or plugin_cmds.register_lazy.",
801
self.add_hook('get_missing_command',
788
self.create_hook(HookPoint('get_missing_command',
802
789
"Called when creating a single command if no command could be "
803
790
"found. Called with (command_name). get_missing_command should "
804
791
"either return None, or a Command object to be used for the "
806
self.add_hook('list_commands',
792
"command.", (1, 17), None))
793
self.create_hook(HookPoint('list_commands',
807
794
"Called when enumerating commands. Called with a set of "
808
795
"cmd_name strings for all the commands found so far. This set "
809
796
" is safe to mutate - e.g. to remove a command. "
810
797
"list_commands should return the updated set of command names.",
813
800
Command.hooks = CommandHooks()
1044
1031
Specify the number of processes that can be run concurrently (selftest).
1046
1033
trace.mutter("bazaar version: " + bzrlib.__version__)
1047
argv = _specified_or_unicode_argv(argv)
1048
1035
trace.mutter("bzr arguments: %r", argv)
1050
1037
opt_lsprof = opt_profile = opt_no_plugins = opt_builtin = \
1213
1200
:return: exit code of bzr command.
1215
if argv is not None:
1202
argv = _specified_or_unicode_argv(argv)
1217
1203
_register_builtin_commands()
1218
1204
ret = run_bzr_catch_errors(argv)
1205
bzrlib.ui.ui_factory.log_transport_activity(
1206
display=('bytes' in debug.debug_flags))
1219
1207
trace.mutter("return code %d", ret)