Rev 5052: (robertc) Make bzrlib.commands.run_bzr more extensible and friendly in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sun Feb 21 08:00:06 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5052 [merge]
revision-id: pqm at pqm.ubuntu.com-20100221080005-nf1mkndpk4aflpmq
parent: pqm at pqm.ubuntu.com-20100219043219-d7kxp38y7rew0b5z
parent: robertc at robertcollins.net-20100221072847-8mdadphpnxr6j3xk
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sun 2010-02-21 08:00:05 +0000
message:
(robertc) Make bzrlib.commands.run_bzr more extensible and friendly
to commandant and other external users. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
=== modified file 'NEWS'
--- a/NEWS 2010-02-18 04:59:30 +0000
+++ b/NEWS 2010-02-21 07:09:22 +0000
@@ -97,6 +97,15 @@
* Remove unused ``CommandFailed`` exception.
(Martin Pool)
+Internals
+*********
+
+* ``bzrlib.commands.run_bzr`` is more extensible: callers can supply the
+ functions to load or disable plugins if they wish to use a different
+ plugin mechanism; the --help, --version and no-command name code paths
+ now use the generic pluggable command lookup infrastructure.
+ (Robert Collins)
+
Testing
*******
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2010-02-12 04:02:50 +0000
+++ b/bzrlib/commands.py 2010-02-21 07:28:47 +0000
@@ -55,6 +55,7 @@
from bzrlib.hooks import HookPoint, Hooks
# Compatibility - Option used to be in commands.
from bzrlib.option import Option
+from bzrlib.plugin import disable_plugins, load_plugins
from bzrlib import registry
from bzrlib.symbol_versioning import (
deprecated_function,
@@ -893,15 +894,21 @@
return None
-def run_bzr(argv):
+def run_bzr(argv, load_plugins=load_plugins, disable_plugins=disable_plugins):
"""Execute a command.
- argv
- The command-line arguments, without the program name from argv[0]
- These should already be decoded. All library/test code calling
- run_bzr should be passing valid strings (don't need decoding).
-
- Returns a command status or raises an exception.
+ :param argv: The command-line arguments, without the program name from
+ argv[0] These should already be decoded. All library/test code calling
+ run_bzr should be passing valid strings (don't need decoding).
+ :param load_plugins: What function to call when triggering plugin loading.
+ This function should take no arguments and cause all plugins to be
+ loaded.
+ :param disable_plugins: What function to call when disabling plugin
+ loading. This function should take no arguments and cause all plugin
+ loading to be prohibited (so that code paths in your application that
+ know about some plugins possibly being present will fail to import
+ those plugins even if they are installed.)
+ :return: Returns a command exit code or raises an exception.
Special master options: these must come before the command because
they control how the command is interpreted.
@@ -972,24 +979,20 @@
debug.set_debug_flags_from_config()
+ if not opt_no_plugins:
+ load_plugins()
+ else:
+ disable_plugins()
+
argv = argv_copy
if (not argv):
- from bzrlib.builtins import cmd_help
- cmd_help().run_argv_aliases([])
+ get_cmd_object('help').run_argv_aliases([])
return 0
if argv[0] == '--version':
- from bzrlib.builtins import cmd_version
- cmd_version().run_argv_aliases([])
+ get_cmd_object('version').run_argv_aliases([])
return 0
- if not opt_no_plugins:
- from bzrlib.plugin import load_plugins
- load_plugins()
- else:
- from bzrlib.plugin import disable_plugins
- disable_plugins()
-
alias_argv = None
if not opt_no_aliases:
More information about the bazaar-commits
mailing list