Rev 6466: (jelmer) Migrate launchpad plugin configuration to config stacks API. in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Feb 7 13:46:17 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6466 [merge]
revision-id: pqm at pqm.ubuntu.com-20120207134616-4f26nutrmui7s5xp
parent: pqm at pqm.ubuntu.com-20120207131840-0whz346qm1ikv3pp
parent: jelmer at samba.org-20120207125907-8nq0ng38wwmnucfy
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2012-02-07 13:46:16 +0000
message:
(jelmer) Migrate launchpad plugin configuration to config stacks API.
(Jelmer Vernooij)
modified:
bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
bzrlib/plugins/launchpad/account.py account.py-20071011033320-50y6vfftywf4yllw-1
bzrlib/plugins/launchpad/test_account.py test_account.py-20071011033320-50y6vfftywf4yllw-2
bzrlib/plugins/launchpad/test_lp_api_lite.py test_lp_api_lite.py-20110713114529-lurqfgc09yifvs3u-1
=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- a/bzrlib/plugins/launchpad/__init__.py 2011-12-18 12:46:49 +0000
+++ b/bzrlib/plugins/launchpad/__init__.py 2012-02-07 12:59:07 +0000
@@ -54,6 +54,7 @@
from bzrlib import (
branch as _mod_branch,
bzrdir,
+ config as _mod_config,
lazy_regex,
# Since we are a built-in plugin we share the bzrlib version
version_info,
@@ -72,9 +73,9 @@
)
from bzrlib.help_topics import topic_registry
from bzrlib.option import (
- Option,
- ListOption,
-)
+ Option,
+ ListOption,
+ )
class cmd_register_branch(Command):
@@ -507,11 +508,9 @@
info = _get_package_branch_info(the_branch.base)
if info is None:
return
- c = the_branch.get_config()
- verbosity = c.get_user_option('launchpad.packaging_verbosity')
- if verbosity is not None:
- verbosity = verbosity.lower()
- if verbosity == 'off':
+ c = the_branch.get_config_stack()
+ verbosity = c.get('launchpad.packaging_verbosity')
+ if not verbosity:
trace.mutter('not checking %s because verbosity is turned off'
% (the_branch.base,))
return
@@ -577,3 +576,15 @@
topic_registry.register('launchpad',
_launchpad_help,
'Using Bazaar with Launchpad.net')
+
+_mod_config.option_registry.register(
+ _mod_config.Option('launchpad.packaging_verbosity', default=True,
+ from_unicode=_mod_config.bool_from_store,
+ help="""\
+Whether to warn if a UDD package import branch is accessed that is out of date.
+
+Setting this option to 'off' will disable verbosity.
+"""))
+_mod_config.option_registry.register(
+ _mod_config.Option('launchpad_username', default=None,
+ help="The username to login with when conneting to Launchpad."))
=== modified file 'bzrlib/plugins/launchpad/account.py'
--- a/bzrlib/plugins/launchpad/account.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/plugins/launchpad/account.py 2012-02-07 01:30:56 +0000
@@ -27,7 +27,7 @@
trace,
transport,
)
-from bzrlib.config import AuthenticationConfig, GlobalConfig
+from bzrlib.config import AuthenticationConfig, GlobalStack
from bzrlib.i18n import gettext
LAUNCHPAD_BASE = 'https://launchpad.net/'
@@ -55,9 +55,9 @@
disagree about username.
"""
if _config is None:
- _config = GlobalConfig()
+ _config = GlobalStack()
- username = _config.get_user_option('launchpad_username')
+ username = _config.get('launchpad_username')
if username is not None:
auth = AuthenticationConfig()
auth_username = _get_auth_user(auth)
@@ -72,8 +72,8 @@
def _set_global_option(username, _config=None):
if _config is None:
- _config = GlobalConfig()
- _config.set_user_option('launchpad_username', username)
+ _config = GlobalStack()
+ _config.set('launchpad_username', username)
def set_lp_login(username, _config=None):
=== modified file 'bzrlib/plugins/launchpad/test_account.py'
--- a/bzrlib/plugins/launchpad/test_account.py 2010-08-30 07:34:11 +0000
+++ b/bzrlib/plugins/launchpad/test_account.py 2012-02-07 01:30:56 +0000
@@ -16,8 +16,6 @@
"""Tests for Launchpad user ID management functions."""
-from cStringIO import StringIO
-
from bzrlib import config
from bzrlib.tests import TestCaseInTempDir, TestCaseWithMemoryTransport
from bzrlib.plugins.launchpad import account
@@ -25,29 +23,25 @@
class LaunchpadAccountTests(TestCaseInTempDir):
- def setup_config(self, text):
- my_config = config.GlobalConfig.from_string(text)
- return my_config
-
def test_get_lp_login_unconfigured(self):
# Test that get_lp_login() returns None if no username has
# been configured.
- my_config = self.setup_config('')
+ my_config = config.MemoryStack('')
self.assertEqual(None, account.get_lp_login(my_config))
def test_get_lp_login(self):
# Test that get_lp_login() returns the configured username
- my_config = self.setup_config(
+ my_config = config.MemoryStack(
'[DEFAULT]\nlaunchpad_username=test-user\n')
self.assertEqual('test-user', account.get_lp_login(my_config))
def test_set_lp_login(self):
# Test that set_lp_login() updates the config file.
- my_config = self.setup_config('')
- self.assertEqual(None, my_config.get_user_option('launchpad_username'))
+ my_config = config.MemoryStack('')
+ self.assertEqual(None, my_config.get('launchpad_username'))
account.set_lp_login('test-user', my_config)
self.assertEqual(
- 'test-user', my_config.get_user_option('launchpad_username'))
+ 'test-user', my_config.get('launchpad_username'))
def test_unknown_launchpad_username(self):
# Test formatting of UnknownLaunchpadUsername exception
=== modified file 'bzrlib/plugins/launchpad/test_lp_api_lite.py'
--- a/bzrlib/plugins/launchpad/test_lp_api_lite.py 2011-08-21 09:24:01 +0000
+++ b/bzrlib/plugins/launchpad/test_lp_api_lite.py 2012-02-07 01:30:56 +0000
@@ -425,8 +425,8 @@
lambda x: ('ubuntu', 'natty', 'bzr'))
self.overrideAttr(lp_api_lite, 'LatestPublication',
lambda *args: self.fail('Tried to query launchpad'))
- c = self.branch.get_config()
- c.set_user_option('launchpad.packaging_verbosity', 'off')
+ c = self.branch.get_config_stack()
+ c.set('launchpad.packaging_verbosity', 'off')
orig_log_len = len(self.get_log())
launchpad._check_is_up_to_date(self.branch)
new_content = self.get_log()[orig_log_len:]
More information about the bazaar-commits
mailing list