49
from brzlib.hooks import Hooks
50
from brzlib.i18n import gettext
49
from breezy.hooks import Hooks
50
from breezy.i18n import gettext
51
51
# Compatibility - Option used to be in commands.
52
from brzlib.option import Option
53
from brzlib.plugin import disable_plugins, load_plugins
54
from brzlib import registry
52
from breezy.option import Option
53
from breezy.plugin import disable_plugins, load_plugins
54
from breezy import registry
57
57
class CommandInfo(object):
165
165
if builtin_command_registry.keys():
168
import brzlib.builtins
169
for cmd_class in _scan_module_for_commands(brzlib.builtins).values():
168
import breezy.builtins
169
for cmd_class in _scan_module_for_commands(breezy.builtins).values():
170
170
builtin_command_registry.register(cmd_class)
171
brzlib.builtins._register_lazy_builtins()
171
breezy.builtins._register_lazy_builtins()
174
174
def _scan_module_for_commands(module):
309
309
# Only do external command lookups when no command is found so far.
310
310
if cmd_or_None is not None:
311
311
return cmd_or_None
312
from brzlib.externalcommand import ExternalCommand
312
from breezy.externalcommand import ExternalCommand
313
313
cmd_obj = ExternalCommand.find_command(cmd_name)
334
334
Commands are the heart of the command-line brz interface.
336
336
The command object mostly handles the mapping of command-line
337
parameters into one or more brzlib operations, and of the results
337
parameters into one or more breezy operations, and of the results
338
338
into textual output.
340
340
Commands normally don't have any state. All their arguments are
560
560
# If this will be rendered as plain text, convert it
562
import brzlib.help_topics
563
result = brzlib.help_topics.help_as_plain_text(result)
562
import breezy.help_topics
563
result = breezy.help_topics.help_as_plain_text(result)
768
768
These are all empty initially, because by default nothing should get
771
Hooks.__init__(self, "brzlib.commands", "Command.hooks")
771
Hooks.__init__(self, "breezy.commands", "Command.hooks")
772
772
self.add_hook('extend_command',
773
773
"Called after creating a command object to allow modifications "
774
774
"such as adding or removing options, docs etc. Called with the "
775
"new brzlib.commands.Command object.", (1, 13))
775
"new breezy.commands.Command object.", (1, 13))
776
776
self.add_hook('get_command',
777
777
"Called when creating a single command. Called with "
778
778
"(cmd_or_None, command_name). get_command should either return "
779
779
"the cmd_or_None parameter, or a replacement Command object that "
780
780
"should be used for the command. Note that the Command.hooks "
781
781
"hooks are core infrastructure. Many users will prefer to use "
782
"brzlib.commands.register_command or plugin_cmds.register_lazy.",
782
"breezy.commands.register_command or plugin_cmds.register_lazy.",
784
784
self.add_hook('get_missing_command',
785
785
"Called when creating a single command if no command could be "
880
880
def apply_coveraged(dirname, the_callable, *args, **kwargs):
881
# Cannot use "import trace", as that would import brzlib.trace instead of
881
# Cannot use "import trace", as that would import breezy.trace instead of
882
882
# the standard library's trace.
883
883
trace = __import__('trace')
943
943
def apply_lsprofiled(filename, the_callable, *args, **kwargs):
944
from brzlib.lsprof import profile
944
from breezy.lsprof import profile
945
945
ret, stats = profile(exception_to_return_code, the_callable,
964
964
If it is unspecified, the global config will be used.
966
966
if config is None:
968
config = brzlib.config.GlobalConfig()
968
config = breezy.config.GlobalConfig()
969
969
alias = config.get_alias(cmd)
971
971
return cmdline.split(alias)
1014
1014
Specify the number of processes that can be run concurrently (selftest).
1016
trace.mutter("breezy version: " + brzlib.__version__)
1016
trace.mutter("breezy version: " + breezy.__version__)
1017
1017
argv = _specified_or_unicode_argv(argv)
1018
1018
trace.mutter("brz arguments: %r", argv)
1062
1062
argv_copy.append(a)
1065
if brzlib.global_state is None:
1066
# FIXME: Workaround for users that imported brzlib but didn't call
1067
# brzlib.initialize -- vila 2012-01-19
1065
if breezy.global_state is None:
1066
# FIXME: Workaround for users that imported breezy but didn't call
1067
# breezy.initialize -- vila 2012-01-19
1068
1068
cmdline_overrides = config.CommandLineStore()
1070
cmdline_overrides = brzlib.global_state.cmdline_overrides
1070
cmdline_overrides = breezy.global_state.cmdline_overrides
1071
1071
cmdline_overrides._from_cmdline(override_config)
1073
1073
debug.set_debug_flags_from_config()
1191
1191
def main(argv=None):
1192
1192
"""Main entry point of command-line interface.
1194
Typically `brzlib.initialize` should be called first.
1194
Typically `breezy.initialize` should be called first.
1196
1196
:param argv: list of unicode command-line arguments similar to sys.argv.
1197
1197
argv[0] is script name usually, it will be ignored.