Rev 5777: Merge config-section-matchers into config-stack resolving conflicts in file:///home/vila/src/bzr/experimental/config/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue May 3 09:58:37 UTC 2011
At file:///home/vila/src/bzr/experimental/config/
------------------------------------------------------------
revno: 5777
revision-id: v.ladeuil+lp at free.fr-20110503095837-1oa5f61t9xol8ewh
parent: v.ladeuil+lp at free.fr-20110503093939-d20z0zvs11tr5sg6
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-stack
timestamp: Tue 2011-05-03 11:58:37 +0200
message:
Merge config-section-matchers into config-stack resolving conflicts
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-05-03 09:39:39 +0000
+++ b/bzrlib/config.py 2011-05-03 09:58:37 +0000
@@ -2444,7 +2444,7 @@
yield section
-class ConfigStack(object):
+class Stack(object):
"""A stack of configurations where an option can be defined"""
def __init__(self, sections=None, get_mutable_section=None):
@@ -2506,6 +2506,10 @@
section = self.get_mutable_section()
section.remove(name)
+ def __repr__(self):
+ # Mostly for debugging use
+ return "<config.%s(%s)>" % (self.__class__.__name__, id(self))
+
class cmd_config(commands.Command):
__doc__ = """Display, set or remove a configuration option.
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-05-03 09:27:10 +0000
+++ b/bzrlib/tests/test_config.py 2011-05-03 09:58:37 +0000
@@ -2186,27 +2186,27 @@
def test_single_config_get(self):
conf = dict(foo='bar')
- conf_stack = config.ConfigStack([conf])
+ conf_stack = config.Stack([conf])
self.assertEquals('bar', conf_stack.get('foo'))
def test_get_first_definition(self):
conf1 = dict(foo='bar')
conf2 = dict(foo='baz')
- conf_stack = config.ConfigStack([conf1, conf2])
+ conf_stack = config.Stack([conf1, conf2])
self.assertEquals('bar', conf_stack.get('foo'))
def test_get_embedded_definition(self):
conf1 = dict(yy='12')
- conf2 = config.ConfigStack([dict(xx='42'), dict(foo='baz')])
- conf_stack = config.ConfigStack([conf1, conf2])
+ conf2 = config.Stack([dict(xx='42'), dict(foo='baz')])
+ conf_stack = config.Stack([conf1, conf2])
self.assertEquals('baz', conf_stack.get('foo'))
def test_get_for_empty_stack(self):
- conf_stack = config.ConfigStack()
+ conf_stack = config.Stack()
self.assertEquals(None, conf_stack.get('foo'))
def test_get_for_empty_section_callable(self):
- conf_stack = config.ConfigStack([lambda : []])
+ conf_stack = config.Stack([lambda : []])
self.assertEquals(None, conf_stack.get('foo'))
@@ -2216,19 +2216,17 @@
# paramerized tests created to avoid bloating -- vila 2011-04-05
def test_simple_set(self):
- store = config.ConfigObjStore(self.get_transport(), 'test.conf')
+ store = config.IniFileStore(self.get_transport(), 'test.conf')
store._load_from_string('foo=bar')
- conf = config.ConfigStack(
- [store.get_sections], store.get_mutable_section)
+ conf = config.Stack([store.get_sections], store.get_mutable_section)
self.assertEquals('bar', conf.get('foo'))
conf.set('foo', 'baz')
# Did we get it back ?
self.assertEquals('baz', conf.get('foo'))
def test_set_creates_a_new_section(self):
- store = config.ConfigObjStore(self.get_transport(), 'test.conf')
- conf = config.ConfigStack(
- [store.get_sections], store.get_mutable_section)
+ store = config.IniFileStore(self.get_transport(), 'test.conf')
+ conf = config.Stack([store.get_sections], store.get_mutable_section)
conf.set('foo', 'baz')
self.assertEquals, 'baz', conf.get('foo')
@@ -2239,19 +2237,17 @@
# paramerized tests created to avoid bloating -- vila 2011-04-06
def test_remove_existing(self):
- store = config.ConfigObjStore(self.get_transport(), 'test.conf')
+ store = config.IniFileStore(self.get_transport(), 'test.conf')
store._load_from_string('foo=bar')
- conf = config.ConfigStack(
- [store.get_sections], store.get_mutable_section)
+ conf = config.Stack([store.get_sections], store.get_mutable_section)
self.assertEquals('bar', conf.get('foo'))
conf.remove('foo')
# Did we get it back ?
self.assertEquals(None, conf.get('foo'))
def test_remove_unknown(self):
- store = config.ConfigObjStore(self.get_transport(), 'test.conf')
- conf = config.ConfigStack(
- [store.get_sections], store.get_mutable_section)
+ store = config.IniFileStore(self.get_transport(), 'test.conf')
+ conf = config.Stack([store.get_sections], store.get_mutable_section)
self.assertRaises(KeyError, conf.remove, 'I_do_not_exist')
More information about the bazaar-commits
mailing list