Rev 6379: (jelmer) Convert 'Branch.append_revisions_only' over to using config stacks. in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Dec 16 14:04:02 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6379 [merge]
revision-id: pqm at pqm.ubuntu.com-20111216140401-s72dizm37u8q660i
parent: pqm at pqm.ubuntu.com-20111215183846-l332p0xr8hy0ekhf
parent: jelmer at samba.org-20111215125956-8mi9ixwtf35zfurg
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2011-12-16 14:04:01 +0000
message:
(jelmer) Convert 'Branch.append_revisions_only' over to using config stacks.
(Jelmer Vernooij)
modified:
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_branch.py test_branch.py-20060116013032-97819aa07b8ab3b5
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2011-12-14 14:09:47 +0000
+++ b/bzrlib/branch.py 2011-12-14 23:43:20 +0000
@@ -663,18 +663,12 @@
"""
if not self._format.supports_set_append_revisions_only():
return False
- return self.get_config(
- ).get_user_option_as_bool('append_revisions_only')
+ return self.get_config_stack().get('append_revisions_only')
def set_append_revisions_only(self, enabled):
if not self._format.supports_set_append_revisions_only():
raise errors.UpgradeRequired(self.user_url)
- if enabled:
- value = 'True'
- else:
- value = 'False'
- self.get_config().set_user_option('append_revisions_only', value,
- warn_masked=True)
+ self.get_config_stack().set('append_revisions_only', enabled)
def set_reference_info(self, file_id, tree_path, branch_location):
"""Set the branch location to use for a tree reference."""
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-12-15 18:38:46 +0000
+++ b/bzrlib/config.py 2011-12-16 14:04:01 +0000
@@ -2533,6 +2533,15 @@
# Registered options in lexicographical order
option_registry.register(
+ Option('append_revisions_only',
+ default=None, from_unicode=bool_from_store, invalid='warning',
+ help='''\
+Whether to only append revisions to the mainline.
+
+If this is set to true, then it is not possible to change the
+existing mainline of the branch.
+'''))
+option_registry.register(
Option('acceptable_keys',
default=None, from_unicode=list_from_store,
help="""\
=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py 2011-12-11 03:39:32 +0000
+++ b/bzrlib/tests/test_branch.py 2011-12-15 12:59:56 +0000
@@ -668,18 +668,18 @@
def setUp(self):
super(TestBranchOptions, self).setUp()
self.branch = self.make_branch('.')
- self.config = self.branch.get_config()
+ self.config_stack = self.branch.get_config_stack()
def check_append_revisions_only(self, expected_value, value=None):
"""Set append_revisions_only in config and check its interpretation."""
if value is not None:
- self.config.set_user_option('append_revisions_only', value)
+ self.config_stack.set('append_revisions_only', value)
self.assertEqual(expected_value,
self.branch.get_append_revisions_only())
def test_valid_append_revisions_only(self):
self.assertEquals(None,
- self.config.get_user_option('append_revisions_only'))
+ self.config_stack.get('append_revisions_only'))
self.check_append_revisions_only(None)
self.check_append_revisions_only(False, 'False')
self.check_append_revisions_only(True, 'True')
@@ -697,7 +697,7 @@
self.check_append_revisions_only(None, 'not-a-bool')
self.assertLength(1, self.warnings)
self.assertEqual(
- 'Value "not-a-bool" is not a boolean for "append_revisions_only"',
+ 'Value "not-a-bool" is not valid for "append_revisions_only"',
self.warnings[0])
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2011-12-14 21:24:07 +0000
+++ b/bzrlib/tests/test_remote.py 2011-12-15 12:59:56 +0000
@@ -175,17 +175,17 @@
def test_remote_branch_set_append_revisions_only(self):
# Make a format 1.9 branch, which supports append_revisions_only
branch = self.make_branch('branch', format='1.9')
- config = branch.get_config()
branch.set_append_revisions_only(True)
+ config = branch.get_config_stack()
self.assertEqual(
- 'True', config.get_user_option('append_revisions_only'))
+ True, config.get('append_revisions_only'))
branch.set_append_revisions_only(False)
+ config = branch.get_config_stack()
self.assertEqual(
- 'False', config.get_user_option('append_revisions_only'))
+ False, config.get('append_revisions_only'))
def test_remote_branch_set_append_revisions_only_upgrade_reqd(self):
branch = self.make_branch('branch', format='knit')
- config = branch.get_config()
self.assertRaises(
errors.UpgradeRequired, branch.set_append_revisions_only, True)
More information about the bazaar-commits
mailing list