Rev 5779: Merge config-section into config-abstract-store in file:///home/vila/src/bzr/experimental/config/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue May 3 07:58:50 UTC 2011
At file:///home/vila/src/bzr/experimental/config/
------------------------------------------------------------
revno: 5779 [merge]
revision-id: v.ladeuil+lp at free.fr-20110503075849-bw16zbtcz3voc3jc
parent: v.ladeuil+lp at free.fr-20110502080448-yjjvkhb2c99es6fy
parent: v.ladeuil+lp at free.fr-20110503074733-wr7auo03nzvmst7r
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-abstract-store
timestamp: Tue 2011-05-03 09:58:49 +0200
message:
Merge config-section into config-abstract-store
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
doc/developers/configuration.txt configuration.txt-20110408142435-korjxxnskvq44sta-1
doc/en/user-guide/configuring_bazaar.txt configuring_bazaar.t-20071128000722-ncxiua259xwbdbg7-1
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-04-12 08:53:24 +0000
+++ b/bzrlib/config.py 2011-05-03 07:58:49 +0000
@@ -2094,11 +2094,12 @@
self._transport.put_file(self._filename, out_file)
-class ReadOnlySection(object):
+class Section(object):
"""A section defines a dict of options.
This is merely a read-only dict which can add some knowledge about the
- options.
+ options. It is *not* a python dict object though and doesn't try to mimic
+ its API.
"""
def __init__(self, section_id, options):
@@ -2109,12 +2110,17 @@
def get(self, name, default=None):
return self.options.get(name, default)
+ def __repr__(self):
+ # Mostly for debugging use
+ return "<%s.%s id=%s>" % (self.__module__, self.__class__.__name__,
+ self.id)
+
_NewlyCreatedOption = object()
"""Was the option created during the MutableSection lifetime"""
-class MutableSection(ReadOnlySection):
+class MutableSection(Section):
"""A section allowing changes and keeping track of the original values."""
def __init__(self, section_id, options):
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-05-02 08:04:48 +0000
+++ b/bzrlib/tests/test_config.py 2011-05-03 07:58:49 +0000
@@ -1814,29 +1814,29 @@
self.assertIs(None, bzrdir_config.get_default_stack_on())
-class TestConfigReadOnlySection(tests.TestCase):
+class TestSection(tests.TestCase):
# FIXME: Parametrize so that all sections produced by Stores run these
# tests -- vila 2011-04-01
def test_get_a_value(self):
a_dict = dict(foo='bar')
- section = config.ReadOnlySection('myID', a_dict)
+ section = config.Section('myID', a_dict)
self.assertEquals('bar', section.get('foo'))
- def test_get_unkown_option(self):
+ def test_get_unknown_option(self):
a_dict = dict()
- section = config.ReadOnlySection('myID', a_dict)
+ section = config.Section('myID', a_dict)
self.assertEquals('out of thin air',
section.get('foo', 'out of thin air'))
def test_options_is_shared(self):
a_dict = dict()
- section = config.ReadOnlySection('myID', a_dict)
+ section = config.Section('myID', a_dict)
self.assertIs(a_dict, section.options)
-class TestConfigMutableSection(tests.TestCase):
+class TestMutableSection(tests.TestCase):
# FIXME: Parametrize so that all sections (including os.environ and the
# ones produced by Stores) run these tests -- vila 2011-04-01
=== modified file 'doc/developers/configuration.txt'
--- a/doc/developers/configuration.txt 2011-04-08 15:55:02 +0000
+++ b/doc/developers/configuration.txt 2011-05-03 07:58:49 +0000
@@ -18,7 +18,7 @@
- you can get, set and remove an option,
- the value is a unicode string.
-MutableSection are needed to set or remove an option, ReadOnlySection should
+MutableSection is needed to set or remove an option, ReadOnlySection should
be used otherwise.
Stores
=== modified file 'doc/en/user-guide/configuring_bazaar.txt'
--- a/doc/en/user-guide/configuring_bazaar.txt 2011-04-08 14:59:29 +0000
+++ b/doc/en/user-guide/configuring_bazaar.txt 2011-05-02 08:15:59 +0000
@@ -41,19 +41,19 @@
-------------------------
As shown in the example above, there are various ways to
-configure Bazaar, they all share some common properties though,
-an option has:
+configure Bazaar, they all share some common properties though.
+An option has:
- a name which is generally a valid python identifier,
-- a value which is a string. In some cases, Bazzar will be able
+- a value which is a string. In some cases, Bazaar will be able
to recognize special values like 'True', 'False' to infer a
boolean type, but basically, as a user, you will always specify
a value as a string.
-Options are grouped in various contexts so their name uniquely
-identify them in this context. When needed, options can be made
-persistent by recording them in a configuration file.
+Options are grouped in various contexts so the option name
+uniquely identifies it in this context. When needed, options can
+be made persistent by recording them in a configuration file.
Configuration files
More information about the bazaar-commits
mailing list