Rev 5756: Trivial implementations for stores with smoke tests. in file:///home/vila/src/bzr/experimental/config/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Apr 5 10:53:01 UTC 2011
At file:///home/vila/src/bzr/experimental/config/
------------------------------------------------------------
revno: 5756
revision-id: v.ladeuil+lp at free.fr-20110405105300-kxhqe3dwo14x0xx4
parent: v.ladeuil+lp at free.fr-20110404173437-qksec0538jc7496g
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-concrete-stores
timestamp: Tue 2011-04-05 12:53:00 +0200
message:
Trivial implementations for stores with smoke tests.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-04-04 17:34:37 +0000
+++ b/bzrlib/config.py 2011-04-05 10:53:00 +0000
@@ -2029,6 +2029,7 @@
self.orig[name] = self.get(name, None)
del self.options[name]
+
class Store(object):
"""Abstract interface to persistent storage for configuration options."""
@@ -2138,6 +2139,32 @@
section[name] = value
+# FIXME: global, bazaar, shouldn't that be 'user' instead or even
+# 'user_defaults' as opposed to 'user_overrides', 'system_defaults'
+# (/etc/bzr/bazaar.conf) and 'system_overrides' ? -- vila 2011-04-05
+class GlobalStore(ConfigObjStore):
+
+ def __init__(self, possible_transports=None):
+ t = transport.get_transport(config_dir(),
+ possible_transports=possible_transports)
+ super(GlobalStore, self).__init__(t, 'bazaar.conf')
+
+
+class LocationStore(ConfigObjStore):
+
+ def __init__(self, possible_transports=None):
+ t = transport.get_transport(config_dir(),
+ possible_transports=possible_transports)
+ super(LocationStore, self).__init__(transport, 'locations.conf')
+
+
+class BranchStore(ConfigObjStore):
+
+ def __init__(self, branch):
+ super(BranchStore, self).__init__(branch.control_transport,
+ 'branch.conf')
+
+
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-04-04 17:34:37 +0000
+++ b/bzrlib/tests/test_config.py 2011-04-05 10:53:00 +0000
@@ -2000,6 +2000,18 @@
self.assertFileEqual('[baz]\nfoo = bar\n', 'foo.conf')
+class TestConfigObjStore(tests.TestCaseWithTransport):
+
+ def test_global_store(self):
+ store = config.GlobalStore()
+
+ def test_location_store(self):
+ store = config.LocationStore()
+
+ def test_branch_store(self):
+ b = self.make_branch('.')
+ store = config.BranchStore(b)
+
class TestConfigGetOptions(tests.TestCaseWithTransport, TestOptionsMixin):
def setUp(self):
More information about the bazaar-commits
mailing list