/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 18:10:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521181028-zn04pdfw0od9hfj3
Rename brzlib => breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import os
27
27
import sys
28
28
 
29
 
from brzlib.lazy_import import lazy_import
 
29
from breezy.lazy_import import lazy_import
30
30
lazy_import(globals(), """
31
31
import errno
32
32
import threading
33
33
 
34
 
import brzlib
35
 
from brzlib import (
 
34
import breezy
 
35
from breezy import (
36
36
    config,
37
37
    cleanup,
38
38
    cmdline,
46
46
    )
47
47
""")
48
48
 
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
55
55
 
56
56
 
57
57
class CommandInfo(object):
165
165
    if builtin_command_registry.keys():
166
166
        # only load once
167
167
        return
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()
172
172
 
173
173
 
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)
314
314
    if cmd_obj:
315
315
        return cmd_obj
334
334
    Commands are the heart of the command-line brz interface.
335
335
 
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.
339
339
 
340
340
    Commands normally don't have any state.  All their arguments are
559
559
 
560
560
        # If this will be rendered as plain text, convert it
561
561
        if plain:
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)
564
564
        return result
565
565
 
566
566
    @staticmethod
768
768
        These are all empty initially, because by default nothing should get
769
769
        notified.
770
770
        """
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.",
783
783
            (1, 17))
784
784
        self.add_hook('get_missing_command',
785
785
            "Called when creating a single command if no command could be "
878
878
    return argdict
879
879
 
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')
884
884
 
941
941
 
942
942
 
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,
946
946
                         *args, **kwargs)
947
947
    stats.sort()
964
964
        If it is unspecified, the global config will be used.
965
965
    """
966
966
    if config is None:
967
 
        import brzlib.config
968
 
        config = brzlib.config.GlobalConfig()
 
967
        import breezy.config
 
968
        config = breezy.config.GlobalConfig()
969
969
    alias = config.get_alias(cmd)
970
970
    if (alias):
971
971
        return cmdline.split(alias)
1013
1013
    --concurrency
1014
1014
        Specify the number of processes that can be run concurrently (selftest).
1015
1015
    """
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)
1019
1019
 
1062
1062
            argv_copy.append(a)
1063
1063
        i += 1
1064
1064
 
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()
1069
1069
    else:
1070
 
        cmdline_overrides = brzlib.global_state.cmdline_overrides
 
1070
        cmdline_overrides = breezy.global_state.cmdline_overrides
1071
1071
    cmdline_overrides._from_cmdline(override_config)
1072
1072
 
1073
1073
    debug.set_debug_flags_from_config()
1191
1191
def main(argv=None):
1192
1192
    """Main entry point of command-line interface.
1193
1193
 
1194
 
    Typically `brzlib.initialize` should be called first.
 
1194
    Typically `breezy.initialize` should be called first.
1195
1195
 
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.