~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: 2010-02-21 08:00:05 UTC
  • mfrom: (5051.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100221080005-nf1mkndpk4aflpmq
(robertc) Make bzrlib.commands.run_bzr more extensible and friendly
        to commandant and other external users. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
from bzrlib.hooks import HookPoint, Hooks
56
56
# Compatibility - Option used to be in commands.
57
57
from bzrlib.option import Option
 
58
from bzrlib.plugin import disable_plugins, load_plugins
58
59
from bzrlib import registry
59
60
from bzrlib.symbol_versioning import (
60
61
    deprecated_function,
893
894
    return None
894
895
 
895
896
 
896
 
def run_bzr(argv):
 
897
def run_bzr(argv, load_plugins=load_plugins, disable_plugins=disable_plugins):
897
898
    """Execute a command.
898
899
 
899
 
    argv
900
 
       The command-line arguments, without the program name from argv[0]
901
 
       These should already be decoded. All library/test code calling
902
 
       run_bzr should be passing valid strings (don't need decoding).
903
 
 
904
 
    Returns a command status or raises an exception.
 
900
    :param argv: The command-line arguments, without the program name from
 
901
        argv[0] These should already be decoded. All library/test code calling
 
902
        run_bzr should be passing valid strings (don't need decoding).
 
903
    :param load_plugins: What function to call when triggering plugin loading.
 
904
        This function should take no arguments and cause all plugins to be
 
905
        loaded.
 
906
    :param disable_plugins: What function to call when disabling plugin
 
907
        loading. This function should take no arguments and cause all plugin
 
908
        loading to be prohibited (so that code paths in your application that
 
909
        know about some plugins possibly being present will fail to import
 
910
        those plugins even if they are installed.)
 
911
    :return: Returns a command exit code or raises an exception.
905
912
 
906
913
    Special master options: these must come before the command because
907
914
    they control how the command is interpreted.
972
979
 
973
980
    debug.set_debug_flags_from_config()
974
981
 
 
982
    if not opt_no_plugins:
 
983
        load_plugins()
 
984
    else:
 
985
        disable_plugins()
 
986
 
975
987
    argv = argv_copy
976
988
    if (not argv):
977
 
        from bzrlib.builtins import cmd_help
978
 
        cmd_help().run_argv_aliases([])
 
989
        get_cmd_object('help').run_argv_aliases([])
979
990
        return 0
980
991
 
981
992
    if argv[0] == '--version':
982
 
        from bzrlib.builtins import cmd_version
983
 
        cmd_version().run_argv_aliases([])
 
993
        get_cmd_object('version').run_argv_aliases([])
984
994
        return 0
985
995
 
986
 
    if not opt_no_plugins:
987
 
        from bzrlib.plugin import load_plugins
988
 
        load_plugins()
989
 
    else:
990
 
        from bzrlib.plugin import disable_plugins
991
 
        disable_plugins()
992
 
 
993
996
    alias_argv = None
994
997
 
995
998
    if not opt_no_aliases: