Rev 5367: Merge simplify-test-config-building into lockable-config-files resolving conflicts in file:///home/vila/src/bzr/bugs/525571-lock-bazaar-conf-files/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Sat Aug 28 20:50:42 BST 2010
At file:///home/vila/src/bzr/bugs/525571-lock-bazaar-conf-files/
------------------------------------------------------------
revno: 5367 [merge]
revision-id: v.ladeuil+lp at free.fr-20100828195041-zary73f5fgnqb5cd
parent: v.ladeuil+lp at free.fr-20100824094106-2pd55tl364hyobd9
parent: v.ladeuil+lp at free.fr-20100828165636-8e2wziacdpog1adg
fixes bug(s): https://launchpad.net/bugs/525571
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: lockable-config-files
timestamp: Sat 2010-08-28 21:50:41 +0200
message:
Merge simplify-test-config-building into lockable-config-files resolving conflicts
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/plugins/launchpad/test_account.py test_account.py-20071011033320-50y6vfftywf4yllw-2
bzrlib/tests/test_commands.py test_command.py-20051019190109-3b17be0f52eaa7a8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
bzrlib/tests/test_smtp_connection.py test_smtp_connection-20070618204509-wuyxc0r0ztrecv7e-1
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2010-08-24 08:10:06 +0000
+++ b/NEWS 2010-08-28 19:50:41 +0000
@@ -145,8 +145,8 @@
API Changes
***********
-* Configuration files should now use the ``from_bytes`` constructor the
- rather than the ``file`` parameter of the ``_get_parser`` method. The
+* ``IniBaseConfig`` objects should now use the ``from_string`` constructor
+ the rather than the ``file`` parameter of the ``_get_parser`` method. The
later has been deprecated. (Vincent Ladeuil)
* InventoryEntry instances now raise AttributeError if you try to assign
@@ -161,10 +161,6 @@
* InventoryEntry objects no longer have ``_put_in_tar`` or
``_put_on_disk`` methods. (Andrew Bennetts)
-* The ``configIniBaseConfig`` constructor now accepts a ``_content``
- private parameter for tests that want to provide a config file content.
- (Vincent Ladeuil)
-
* The ``get_filename`` parameter in the ``config.IniBaseConfig``
constructor has been deprecated, use the ``file_name`` parameter instead.
(Vincent Ladeuil)
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2010-08-24 09:41:06 +0000
+++ b/bzrlib/config.py 2010-08-28 19:50:41 +0000
@@ -377,20 +377,20 @@
self._parser = None
@classmethod
- def from_bytes(cls, unicode_bytes, file_name=None):
- """Create a config object from bytes.
+ def from_string(cls, str_or_unicode, file_name=None):
+ """Create a config object from a string.
- :param unicode_bytes: A string representing the file content. This will
+ :param str_or_unicode: A string representing the file content. This will
be utf-8 encoded.
:param file_name: The configuration file path.
"""
conf = cls(file_name=file_name)
- conf._create_from_bytes(unicode_bytes)
+ conf._create_from_string(str_or_unicode)
return conf
- def _create_from_bytes(self, unicode_bytes):
- self._content = StringIO(unicode_bytes.encode('utf-8'))
+ def _create_from_string(self, str_or_unicode):
+ self._content = StringIO(str_or_unicode.encode('utf-8'))
def _get_parser(self, file=symbol_versioning.DEPRECATED_PARAMETER):
if self._parser is not None:
@@ -604,14 +604,14 @@
super(GlobalConfig, self).__init__(file_name=config_filename())
@classmethod
- def from_bytes(cls, unicode_bytes):
- """Create a config object from bytes.
+ def from_string(cls, str_or_unicode):
+ """Create a config object from a string.
- :param unicode_bytes: A string representing the file content. This will
- be utf-8 encoded.
+ :param str_or_unicode: A string representing the file content. This
+ will be utf-8 encoded.
"""
conf = cls()
- conf._create_from_bytes(unicode_bytes)
+ conf._create_from_string(str_or_unicode)
return conf
def get_editor(self):
@@ -664,16 +664,16 @@
self.location = location
@classmethod
- def from_bytes(cls, unicode_bytes, location):
- """Create a config object from bytes.
+ def from_string(cls, str_or_unicode, location):
+ """Create a config object from s string.
- :param unicode_bytes: A string representing the file content. This will
+ :param str_or_unicode: A string representing the file content. This will
be utf-8 encoded.
:param location: The location url to filter the configuration.
"""
conf = cls(location)
- conf._create_from_bytes(unicode_bytes)
+ conf._create_from_string(str_or_unicode)
return conf
def _get_matching_sections(self):
=== modified file 'bzrlib/plugins/launchpad/test_account.py'
--- a/bzrlib/plugins/launchpad/test_account.py 2010-08-24 08:05:12 +0000
+++ b/bzrlib/plugins/launchpad/test_account.py 2010-08-28 16:56:36 +0000
@@ -26,7 +26,7 @@
class LaunchpadAccountTests(TestCaseInTempDir):
def setup_config(self, text):
- my_config = config.GlobalConfig.from_bytes(text)
+ my_config = config.GlobalConfig.from_string(text)
return my_config
def test_get_lp_login_unconfigured(self):
=== modified file 'bzrlib/tests/test_commands.py'
--- a/bzrlib/tests/test_commands.py 2010-08-24 08:05:12 +0000
+++ b/bzrlib/tests/test_commands.py 2010-08-28 16:56:36 +0000
@@ -95,7 +95,7 @@
class TestGetAlias(tests.TestCase):
def _get_config(self, config_text):
- my_config = config.GlobalConfig.from_bytes(config_text)
+ my_config = config.GlobalConfig.from_string(config_text)
return my_config
def test_simple(self):
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2010-08-24 09:41:06 +0000
+++ b/bzrlib/tests/test_config.py 2010-08-28 19:50:41 +0000
@@ -395,7 +395,7 @@
class TestIniConfig(tests.TestCaseInTempDir):
def make_config_parser(self, s):
- conf = config.IniBasedConfig.from_bytes(s)
+ conf = config.IniBasedConfig.from_string(s)
return conf, conf._get_parser()
@@ -405,11 +405,11 @@
my_config = config.IniBasedConfig()
def test_from_fp(self):
- my_config = config.IniBasedConfig.from_bytes(sample_config_text)
+ my_config = config.IniBasedConfig.from_string(sample_config_text)
self.assertIsInstance(my_config._get_parser(), configobj.ConfigObj)
def test_cached(self):
- my_config = config.IniBasedConfig.from_bytes(sample_config_text)
+ my_config = config.IniBasedConfig.from_string(sample_config_text)
parser = my_config._get_parser()
self.failUnless(my_config._get_parser() is parser)
@@ -436,7 +436,7 @@
def test_get_parser_file_parameter_is_deprecated_(self):
config_file = StringIO(sample_config_text.encode('utf-8'))
- conf = config.IniBasedConfig.from_bytes(sample_config_text)
+ conf = config.IniBasedConfig.from_string(sample_config_text)
conf = self.callDeprecated([
'IniBasedConfig._get_parser(file=xxx) was deprecated in 2.3.'
' Use IniBasedConfig(_content=xxx) instead.'],
@@ -450,15 +450,15 @@
class TestIniBaseConfigOnDisk(tests.TestCaseInTempDir):
def test_cannot_reload_without_name(self):
- conf = config.IniBasedConfig.from_bytes(sample_config_text)
+ conf = config.IniBasedConfig.from_string(sample_config_text)
self.assertRaises(AssertionError, conf.reload)
def test_reload_see_new_value(self):
- c1 = config.IniBasedConfig.from_bytes('editor=vim\n',
- file_name='./test/conf')
+ c1 = config.IniBasedConfig.from_string('editor=vim\n',
+ file_name='./test/conf')
c1._write_config_file()
- c2 = config.IniBasedConfig.from_bytes('editor=emacs\n',
- file_name='./test/conf')
+ c2 = config.IniBasedConfig.from_string('editor=emacs\n',
+ file_name='./test/conf')
c2._write_config_file()
self.assertEqual('vim', c1.get_user_option('editor'))
self.assertEqual('emacs', c2.get_user_option('editor'))
@@ -483,7 +483,7 @@
return self.config_class(*self.config_args)
def create_config(self, content):
- c = self.config_class.from_bytes(content, *self.config_args)
+ c = self.config_class.from_string(content, *self.config_args)
c.lock_write()
c._write_config_file()
c.unlock()
@@ -781,7 +781,7 @@
class TestGlobalConfigItems(tests.TestCase):
def test_user_id(self):
- my_config = config.GlobalConfig.from_bytes(sample_config_text)
+ my_config = config.GlobalConfig.from_string(sample_config_text)
self.assertEqual(u"Erik B\u00e5gfors <erik at bagfors.nu>",
my_config._get_user_id())
@@ -790,11 +790,11 @@
self.assertEqual(None, my_config._get_user_id())
def test_configured_editor(self):
- my_config = config.GlobalConfig.from_bytes(sample_config_text)
+ my_config = config.GlobalConfig.from_string(sample_config_text)
self.assertEqual("vim", my_config.get_editor())
def test_signatures_always(self):
- my_config = config.GlobalConfig.from_bytes(sample_always_signatures)
+ my_config = config.GlobalConfig.from_string(sample_always_signatures)
self.assertEqual(config.CHECK_NEVER,
my_config.signature_checking())
self.assertEqual(config.SIGN_ALWAYS,
@@ -802,7 +802,7 @@
self.assertEqual(True, my_config.signature_needed())
def test_signatures_if_possible(self):
- my_config = config.GlobalConfig.from_bytes(sample_maybe_signatures)
+ my_config = config.GlobalConfig.from_string(sample_maybe_signatures)
self.assertEqual(config.CHECK_NEVER,
my_config.signature_checking())
self.assertEqual(config.SIGN_WHEN_REQUIRED,
@@ -810,7 +810,7 @@
self.assertEqual(False, my_config.signature_needed())
def test_signatures_ignore(self):
- my_config = config.GlobalConfig.from_bytes(sample_ignore_signatures)
+ my_config = config.GlobalConfig.from_string(sample_ignore_signatures)
self.assertEqual(config.CHECK_ALWAYS,
my_config.signature_checking())
self.assertEqual(config.SIGN_NEVER,
@@ -818,7 +818,7 @@
self.assertEqual(False, my_config.signature_needed())
def _get_sample_config(self):
- my_config = config.GlobalConfig.from_bytes(sample_config_text)
+ my_config = config.GlobalConfig.from_string(sample_config_text)
return my_config
def test_gpg_signing_command(self):
@@ -1167,11 +1167,11 @@
global_config = sample_config_text
config.ensure_config_dir_exists()
- my_global_config = config.GlobalConfig.from_bytes(global_config)
+ my_global_config = config.GlobalConfig.from_string(global_config)
my_global_config.lock_write()
my_global_config._write_config_file()
my_global_config.unlock()
- my_location_config = config.LocationConfig.from_bytes(
+ my_location_config = config.LocationConfig.from_string(
sample_branches_text, my_branch.base)
my_location_config.lock_write()
my_location_config._write_config_file()
@@ -1247,13 +1247,13 @@
location_config=None, branch_data_config=None):
my_branch = FakeBranch(location)
if global_config is not None:
- my_global_config = config.GlobalConfig.from_bytes(global_config)
+ my_global_config = config.GlobalConfig.from_string(global_config)
config.ensure_config_dir_exists()
my_global_config.lock_write()
my_global_config._write_config_file()
my_global_config.unlock()
if location_config is not None:
- my_location_config = config.LocationConfig.from_bytes(
+ my_location_config = config.LocationConfig.from_string(
location_config, my_branch.base)
config.ensure_config_dir_exists()
my_location_config.lock_write()
=== modified file 'bzrlib/tests/test_smtp_connection.py'
--- a/bzrlib/tests/test_smtp_connection.py 2010-08-24 08:05:12 +0000
+++ b/bzrlib/tests/test_smtp_connection.py 2010-08-28 16:56:36 +0000
@@ -91,7 +91,7 @@
class TestSMTPConnection(tests.TestCaseInTempDir):
def get_connection(self, text, smtp_factory=None):
- my_config = config.GlobalConfig.from_bytes(text)
+ my_config = config.GlobalConfig.from_string(text)
return smtp_connection.SMTPConnection(my_config,
_smtp_factory=smtp_factory)
More information about the bazaar-commits
mailing list