Rev 6129: Implement a config stack registry and use it. in file:///home/vila/src/bzr/bugs/832036-stack-registry/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Sep 7 09:02:47 UTC 2011


At file:///home/vila/src/bzr/bugs/832036-stack-registry/

------------------------------------------------------------
revno: 6129
revision-id: v.ladeuil+lp at free.fr-20110907090247-g0ea7shcdybapsyq
parent: v.ladeuil+lp at free.fr-20110906180930-n7pbe223hg750ys3
fixes bug(s): https://launchpad.net/bugs/832036
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 832036-stack-registry
timestamp: Wed 2011-09-07 11:02:47 +0200
message:
  Implement a config stack registry and use it.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-09-06 18:09:30 +0000
+++ b/bzrlib/config.py	2011-09-07 09:02:47 +0000
@@ -3287,7 +3287,7 @@
         bstore)
     return stack
 
-# Neeed for 'default_stack_on location' which is the only option defined in
+# Neeed for 'default_stack_on location' which is the *only* option defined in
 # 'control.conf'. This stack is not yet used in bzrdir.py -- vila 2011-09-06
 def control_only_stack(bzrdir):
     """Create a stack for the control options *only*.
@@ -3303,9 +3303,9 @@
     return stack
 
 
-# Needed for 'stacked_on_location' only which use a hack that could be removed
-# when each config file is read only once. This stack is not yet used in
-# branch.py -- vila 2011-09-06
+# Needed for 'stacked_on_location' *only* which use a hack that could be
+# removed when each config file is read only once. This stack is not yet used
+# in branch.py -- vila 2011-09-06
 def branch_only_stack(branch):
     """Create a stack for the branch options *only*.
 

=== modified file 'doc/developers/configuration.txt'
--- a/doc/developers/configuration.txt	2011-08-19 14:10:32 +0000
+++ b/doc/developers/configuration.txt	2011-09-07 09:02:47 +0000
@@ -122,9 +122,27 @@
 is one, then the *user* should be able to decide and in this case a new
 ``Stack`` can be created cheaply.
 
+StackRegistry
+-------------
+
+All config stacks should be obtained from ``config.stacks`` which provides
+stack factories for various contexts.
+
+Each factory is registered under a name so plugins can override them as they
+see fit.
+
+Each factory defines its own context as a set of parameters that should be
+provided to build a stack.
+
 Different stacks can be created for different purposes, the existing
-``GlobalStack``, ``LocationStack`` and ``BranchStack`` can be used as basis
-or examples. These classes are the only ones that should be used in code,
-``Stores`` can be used to build them but shouldn't be used otherwise, ditto
-for sections. Again, the associated tests could and should be used against the
-created stacks.
+``global_stack``, ``location_stack``, ``branch_stack`` and so on can be used
+as basis or examples. 
+
+Such factory methods can use ``Stores``, ``SectionMatcher`` or ``Sections``
+objects to build their stack (they are the only intended consumer) but these
+objects shouldn't be used otherwise.
+
+There are parameterized tests intended to exercise these factories and their
+resulting stacks (see ``config.test_stack_builder_registry`` and the tests
+that use them in ``bzrlib/tests/test_config.py``). Using them should help
+implementing such factories.

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-09-02 12:45:36 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-09-07 09:02:47 +0000
@@ -92,6 +92,9 @@
 * bzr now ships with translations for command help.  (Jonathan
   Riddell, INADA Naoki, #83941)
 
+* The ``config.stacks`` registry provides a way to get a config stack
+  factory for various contexts. (Vincent Ladeuil, #832036)
+
 Improvements
 ************
 



More information about the bazaar-commits mailing list