Rev 5764: Outline concrete stacks and basic smoke tests. in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Apr 7 20:53:42 UTC 2011


At file:///home/vila/src/bzr/experimental/config/

------------------------------------------------------------
revno: 5764
revision-id: v.ladeuil+lp at free.fr-20110407205342-0tmpemgncvooc0cr
parent: v.ladeuil+lp at free.fr-20110407192936-uj1ai692yobw0kmx
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-concrete-stacks
timestamp: Thu 2011-04-07 22:53:42 +0200
message:
  Outline concrete stacks and basic smoke tests.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-04-07 19:29:36 +0000
+++ b/bzrlib/config.py	2011-04-07 20:53:42 +0000
@@ -2449,6 +2449,38 @@
         section.remove(name)
 
 
+class GlobalStack(ConfigStack):
+
+    def __init__(self):
+        # Get a GlobalStore
+        gstore = GlobalStore()
+        super(GlobalStack, self).__init__([gstore.get_sections],
+                                          gstore.get_mutable_section)
+
+
+class LocationStack(ConfigStack):
+
+    def __init__(self, location):
+        lstore = LocationStore()
+        matcher = LocationMatcher(lstore, location)
+        gstore = GlobalStore()
+        super(LocationStack, self).__init__(
+            [matcher.get_sections, gstore.get_sections],
+            lstore.get_mutable_section)
+
+
+class BranchStack(ConfigStack):
+
+    def __init__(self, branch):
+        bstore = BranchStore(branch)
+        lstore = LocationStore()
+        matcher = LocationMatcher(lstore, branch.base)
+        gstore = GlobalStore()
+        super(BranchStack, self).__init__(
+            [matcher.get_sections, bstore.get_sections, gstore.get_sections],
+            bstore.get_mutable_section)
+
+
 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-07 19:29:36 +0000
+++ b/bzrlib/tests/test_config.py	2011-04-07 20:53:42 +0000
@@ -2165,7 +2165,6 @@
                           [section.extra_path for section in sections])
 
 
-
 class TestConfigStackGet(tests.TestCase):
 
     # FIXME: This should be parametrized for all known ConfigStack or dedicated
@@ -2243,6 +2242,21 @@
         self.assertRaises(KeyError, conf.remove, 'I_do_not_exist')
 
 
+class TestConcreteStacks(tests.TestCaseWithTransport):
+
+    # basic smoke tests
+
+    def test_global_stack(self):
+        stack = config.GlobalStack()
+
+    def test_location_store(self):
+        stack = config.LocationStack('.')
+
+    def test_branch_store(self):
+        b = self.make_branch('.')
+        stack = config.BranchStack(b)
+
+
 class TestConfigGetOptions(tests.TestCaseWithTransport, TestOptionsMixin):
 
     def setUp(self):



More information about the bazaar-commits mailing list