Rev 6156: Migrate dpush_strict, push_strict and send_strict options to the stack based config design, introducing get_config_stack for branches. in file:///home/vila/src/bzr/experimental/migrate-config-options/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Sep 22 12:13:13 UTC 2011
At file:///home/vila/src/bzr/experimental/migrate-config-options/
------------------------------------------------------------
revno: 6156
revision-id: v.ladeuil+lp at free.fr-20110922121312-bm2uww3uaw2dhmfe
parent: pqm at pqm.ubuntu.com-20110921151127-hojrogt4w8w2z6si
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: migrate-config-options
timestamp: Thu 2011-09-22 14:13:12 +0200
message:
Migrate dpush_strict, push_strict and send_strict options to the stack based config design, introducing get_config_stack for branches.
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2011-09-19 15:59:40 +0000
+++ b/bzrlib/branch.py 2011-09-22 12:13:12 +0000
@@ -215,6 +215,16 @@
"""
return _mod_config.BranchConfig(self)
+ def get_config_stack(self):
+ """Get a bzrlib.config.BranchStack for this Branch.
+
+ This can then be used to get and set configuration options for the
+ branch.
+
+ :return: A bzrlib.config.BranchStack.
+ """
+ return _mod_config.BranchStack(self)
+
def _get_config(self):
"""Get the concrete config for just the config in this branch.
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-09-16 11:13:47 +0000
+++ b/bzrlib/config.py 2011-09-22 12:13:12 +0000
@@ -2528,6 +2528,16 @@
Option('default_format', default='2a',
help='Format used when creating branches.'))
option_registry.register(
+ Option('dpush_strict', default=None,
+ from_unicode=bool_from_store,
+ help='''\
+The default value for ``dpush --strict``.
+
+If present, defines the ``--strict`` option default value for checking
+uncommitted changes before pushing into a different VCS without any
+custom bzr metadata.
+'''))
+option_registry.register(
Option('editor',
help='The command called to launch an editor to enter a message.'))
option_registry.register(
@@ -2558,6 +2568,15 @@
help= 'Unicode encoding for output'
' (terminal encoding if not specified).'))
option_registry.register(
+ Option('push_strict', default=None,
+ from_unicode=bool_from_store,
+ help='''\
+The default value for ``push --strict``.
+
+If present, defines the ``--strict`` option default value for checking
+uncommitted changes before sending a merge directive.
+'''))
+option_registry.register(
Option('repository.fdatasync', default=True,
from_unicode=bool_from_store,
help='''\
@@ -2567,6 +2586,15 @@
to physical disk. This is somewhat slower, but means data should not be
lost if the machine crashes. See also dirstate.fdatasync.
'''))
+option_registry.register(
+ Option('send_strict', default=None,
+ from_unicode=bool_from_store,
+ help='''\
+The default value for ``send --strict``.
+
+If present, defines the ``--strict`` option default value for checking
+uncommitted changes before pushing.
+'''))
class Section(object):
=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py 2011-09-06 09:51:45 +0000
+++ b/bzrlib/mutabletree.py 2011-09-22 12:13:12 +0000
@@ -260,7 +260,7 @@
:param more_warning: Details about what is happening.
"""
if strict is None:
- strict = self.branch.get_config().get_user_option_as_bool(opt_name)
+ strict = self.branch.get_config_stack().get(opt_name)
if strict is not False:
err_class = None
if (self.has_changes()):
=== modified file 'bzrlib/tests/blackbox/test_dpush.py'
--- a/bzrlib/tests/blackbox/test_dpush.py 2011-04-16 08:41:33 +0000
+++ b/bzrlib/tests/blackbox/test_dpush.py 2011-09-22 12:13:12 +0000
@@ -146,8 +146,8 @@
def set_config_push_strict(self, value):
# set config var (any of bazaar.conf, locations.conf, branch.conf
# should do)
- conf = self.tree.branch.get_config()
- conf.set_user_option('dpush_strict', value)
+ conf = self.tree.branch.get_config_stack()
+ conf.set('dpush_strict', value)
_default_command = ['dpush', '../to']
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2011-08-31 17:22:53 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2011-09-22 12:13:12 +0000
@@ -676,8 +676,8 @@
def set_config_push_strict(self, value):
# set config var (any of bazaar.conf, locations.conf, branch.conf
# should do)
- conf = self.tree.branch.get_config()
- conf.set_user_option('push_strict', value)
+ conf = self.tree.branch.get_config_stack()
+ conf.set('push_strict', value)
_default_command = ['push', '../to']
_default_wd = 'local'
=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- a/bzrlib/tests/blackbox/test_send.py 2011-09-16 15:37:58 +0000
+++ b/bzrlib/tests/blackbox/test_send.py 2011-09-22 12:13:12 +0000
@@ -296,8 +296,8 @@
def set_config_send_strict(self, value):
# set config var (any of bazaar.conf, locations.conf, branch.conf
# should do)
- conf = self.local_tree.branch.get_config()
- conf.set_user_option('send_strict', value)
+ conf = self.local_tree.branch.get_config_stack()
+ conf.set('send_strict', value)
def assertSendFails(self, args):
out, err = self.run_send(args, rc=3, err_re=self._default_errors)
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-09-21 00:33:17 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-09-22 12:13:12 +0000
@@ -55,6 +55,11 @@
.. Major internal changes, unlikely to be visible to users or plugin
developers, but interesting for bzr developers.
+* ``Branch`` objects can now use a config stack with the newly introduced
+ ``get_config_stack()``. Both ``get_config`` and ``get_config_stack`` can
+ be used for the same branch but it's recommended to stick to one for a
+ given option.
+
Testing
*******
More information about the bazaar-commits
mailing list