Rev 6422: Migrate more branch options to config stacks. in file:///home/vila/src/bzr/experimental/branch-push-location/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Jan 4 17:12:42 UTC 2012
At file:///home/vila/src/bzr/experimental/branch-push-location/
------------------------------------------------------------
revno: 6422
revision-id: v.ladeuil+lp at free.fr-20120104171242-5k48d5lp90c8ej0v
parent: pqm at pqm.ubuntu.com-20120103174403-a1g6m9e6m95515uk
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: branch-push-location
timestamp: Wed 2012-01-04 18:12:42 +0100
message:
Migrate more branch options to config stacks.
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2012-01-03 13:47:01 +0000
+++ b/bzrlib/branch.py 2012-01-04 17:12:42 +0000
@@ -1187,7 +1187,7 @@
def get_child_submit_format(self):
"""Return the preferred format of submissions to this branch."""
- return self.get_config().get_user_option("child_submit_format")
+ return self.get_config_stack().get('child_submit_format')
def get_submit_branch(self):
"""Return the submit location of the branch.
@@ -1196,7 +1196,7 @@
pattern is that the user can override it by specifying a
location.
"""
- return self.get_config().get_user_option('submit_branch')
+ return self.get_config_stack().get('submit_branch')
def set_submit_branch(self, location):
"""Return the submit location of the branch.
@@ -1205,8 +1205,7 @@
pattern is that the user can override it by specifying a
location.
"""
- self.get_config().set_user_option('submit_branch', location,
- warn_masked=True)
+ self.get_config_stack().set('submit_branch', location)
def get_public_branch(self):
"""Return the public location of the branch.
@@ -1225,9 +1224,8 @@
self._set_config_location('public_branch', location)
def get_push_location(self):
- """Return the None or the location to push this branch to."""
- push_loc = self.get_config().get_user_option('push_location')
- return push_loc
+ """Return None or the location to push this branch to."""
+ return self.get_config_stack().get('push_location')
def set_push_location(self, location):
"""Set a new push location for this branch."""
@@ -3006,7 +3004,7 @@
return self._get_config_location('bound_location', config=conf)
def get_bound_location(self):
- """See Branch.set_push_location."""
+ """See Branch.get_bound_location."""
return self._get_bound_location(True)
def get_old_bound_location(self):
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2012-01-03 12:56:06 +0000
+++ b/bzrlib/config.py 2012-01-04 17:12:42 +0000
@@ -2669,6 +2669,12 @@
present.
'''))
option_registry.register(
+ Option('child_submit_format',
+ help='''The preferred format of submissions to this branch.'''))
+option_registry.register(
+ Option('child_submit_to',
+ help='''Where submissions to this branch are mailed to.'''))
+option_registry.register(
Option('create_signatures', default=SIGN_WHEN_REQUIRED,
from_unicode=signing_policy_from_unicode,
help='''\
@@ -2857,6 +2863,9 @@
This is automatically set by ``bzr send`` and ``bzr merge``, and is also used
by the ``submit:`` revision spec.
"""))
+option_registry.register(
+ Option('submit_to',
+ help='''Where submissions from this branch are mailed to.'''))
class Section(object):
=== modified file 'bzrlib/send.py'
--- a/bzrlib/send.py 2011-12-18 15:28:38 +0000
+++ b/bzrlib/send.py 2012-01-04 17:12:42 +0000
@@ -49,10 +49,9 @@
branch.lock_write()
try:
if output is None:
- config = branch.get_config()
if mail_to is None:
- mail_to = config.get_user_option('submit_to')
- mail_client = config.get_mail_client()
+ mail_to = branch.get_config_stack().get('submit_to')
+ mail_client = branch.get_config().get_mail_client()
if (not getattr(mail_client, 'supports_body', False)
and body is not None):
raise errors.BzrCommandError(gettext(
@@ -87,16 +86,16 @@
possible_transports=possible_transports)
possible_transports.append(submit_branch.bzrdir.root_transport)
if mail_to is None or format is None:
- submit_config = submit_branch.get_config()
if mail_to is None:
- mail_to = submit_config.get_user_option("child_submit_to")
+ mail_to = submit_branch.get_config_stack().get(
+ 'child_submit_to')
if format is None:
formatname = submit_branch.get_child_submit_format()
try:
format = format_registry.get(formatname)
except KeyError:
- raise errors.BzrCommandError(gettext("No such send format '%s'.") %
- formatname)
+ raise errors.BzrCommandError(
+ gettext("No such send format '%s'.") % formatname)
stored_public_branch = branch.get_public_branch()
if public_branch is None:
=== modified file 'bzrlib/tests/blackbox/test_add.py'
--- a/bzrlib/tests/blackbox/test_add.py 2011-08-19 21:01:49 +0000
+++ b/bzrlib/tests/blackbox/test_add.py 2012-01-04 17:12:42 +0000
@@ -239,7 +239,7 @@
out, err = self.run_bzr(["add", "a", "b"], working_dir=u"\xA7")
self.assertEquals(out, "adding a\n" "adding b\n")
self.assertEquals(err, "")
-
+
def test_add_skip_large_files(self):
"""Test skipping files larger than add.maximum_file_size"""
tree = self.make_branch_and_tree('.')
@@ -250,16 +250,13 @@
tree.branch.get_config().set_user_option('add.maximum_file_size', 5)
out = self.run_bzr('add')[0]
results = sorted(out.rstrip('\n').split('\n'))
- self.assertEquals(['adding small.txt'],
- results)
+ self.assertEquals(['adding small.txt'], results)
# named items never skipped, even if over max
out, err = self.run_bzr(["add", "big2.txt"])
results = sorted(out.rstrip('\n').split('\n'))
- self.assertEquals(['adding big2.txt'],
- results)
- self.assertEquals(err, "")
- tree.branch.get_config().set_user_option('add.maximum_file_size', 30)
+ self.assertEquals(['adding big2.txt'], results)
+ self.assertEquals("", err)
+ tree.branch.get_config_stack().set('add.maximum_file_size', 30)
out = self.run_bzr('add')[0]
results = sorted(out.rstrip('\n').split('\n'))
- self.assertEquals(['adding big.txt'],
- results)
+ self.assertEquals(['adding big.txt'], results)
=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
--- a/bzrlib/tests/blackbox/test_annotate.py 2011-12-30 15:26:18 +0000
+++ b/bzrlib/tests/blackbox/test_annotate.py 2012-01-04 17:12:42 +0000
@@ -178,7 +178,7 @@
def test_annotate_edited_file(self):
tree = self._setup_edited_file()
- tree.branch.get_config().set_user_option('email', 'current at host2')
+ tree.branch.get_config_stack().set('email', 'current at host2')
out, err = self.run_bzr('annotate file')
self.assertEqual(
'1 test at ho | foo\n'
@@ -203,7 +203,7 @@
def test_annotate_edited_file_show_ids(self):
tree = self._setup_edited_file()
- tree.branch.get_config().set_user_option('email', 'current at host2')
+ self.overrideEnv('BZR_EMAIL', 'current at host2')
out, err = self.run_bzr('annotate file --show-ids')
self.assertEqual(
' rev1 | foo\n'
=== modified file 'bzrlib/tests/blackbox/test_merge_directive.py'
--- a/bzrlib/tests/blackbox/test_merge_directive.py 2011-12-16 19:18:39 +0000
+++ b/bzrlib/tests/blackbox/test_merge_directive.py 2012-01-04 17:12:42 +0000
@@ -44,8 +44,8 @@
def prepare_merge_directive(self):
self.tree1 = self.make_branch_and_tree('tree1')
self.build_tree_contents([('tree1/file', 'a\nb\nc\nd\n')])
- self.tree1.branch.get_config().set_user_option('email',
- 'J. Random Hacker <jrandom at example.com>')
+ self.tree1.branch.get_config_stack().set(
+ 'email', 'J. Random Hacker <jrandom at example.com>')
self.tree1.add('file')
self.tree1.commit('foo', rev_id='foo-id')
self.tree2 = self.tree1.bzrdir.sprout('tree2').open_workingtree()
=== modified file 'bzrlib/tests/blackbox/test_pull.py'
--- a/bzrlib/tests/blackbox/test_pull.py 2012-01-02 10:24:02 +0000
+++ b/bzrlib/tests/blackbox/test_pull.py 2012-01-04 17:12:42 +0000
@@ -377,8 +377,8 @@
def test_pull_verbose_uses_default_log(self):
tree = self.example_branch('source')
target = self.make_branch_and_tree('target')
- target_config = target.branch.get_config()
- target_config.set_user_option('log_format', 'short')
+ target_config = target.branch.get_config_stack()
+ target_config.set('log_format', 'short')
out = self.run_bzr('pull -v source -d target')[0]
self.assertContainsRe(out, r'\n {4}1 .*\n {6}setup\n')
self.assertNotContainsRe(
=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- a/bzrlib/tests/blackbox/test_send.py 2011-12-14 20:21:52 +0000
+++ b/bzrlib/tests/blackbox/test_send.py 2012-01-04 17:12:42 +0000
@@ -200,7 +200,7 @@
self.run_send([])
self.run_bzr_error(('Unknown mail client: bogus',),
'send -f branch --mail-to jrandom at example.org')
- b.get_config().set_user_option('submit_to', 'jrandom at example.org')
+ b.get_config_stack().set('submit_to', 'jrandom at example.org')
self.run_bzr_error(('Unknown mail client: bogus',),
'send -f branch')
@@ -209,10 +209,8 @@
b = branch.Branch.open('branch')
b.get_config().set_user_option('mail_client', 'bogus')
parent = branch.Branch.open('parent')
- parent.get_config().set_user_option('child_submit_to',
- 'somebody at example.org')
- self.run_bzr_error(('Unknown mail client: bogus',),
- 'send -f branch')
+ parent.get_config_stack().set('child_submit_to', 'somebody at example.org')
+ self.run_bzr_error(('Unknown mail client: bogus',), 'send -f branch')
def test_format(self):
md = self.get_MD(['--format=4'])
@@ -230,12 +228,12 @@
'send -f branch -o- --format=0.999')[0]
def test_format_child_option(self):
- parent_config = branch.Branch.open('parent').get_config()
- parent_config.set_user_option('child_submit_format', '4')
+ parent_config = branch.Branch.open('parent').get_config_stack()
+ parent_config.set('child_submit_format', '4')
md = self.get_MD([])
self.assertIs(merge_directive.MergeDirective2, md.__class__)
- parent_config.set_user_option('child_submit_format', '0.9')
+ parent_config.set('child_submit_format', '0.9')
md = self.get_MD([])
self.assertFormatIs('# Bazaar revision bundle v0.9', md)
@@ -243,7 +241,7 @@
self.assertFormatIs('# Bazaar revision bundle v0.9', md)
self.assertIs(merge_directive.MergeDirective, md.__class__)
- parent_config.set_user_option('child_submit_format', '0.999')
+ parent_config.set('child_submit_format', '0.999')
self.run_bzr_error(["No such send format '0.999'"],
'send -f branch -o-')[0]
=== modified file 'bzrlib/tests/blackbox/test_whoami.py'
--- a/bzrlib/tests/blackbox/test_whoami.py 2011-06-22 09:09:35 +0000
+++ b/bzrlib/tests/blackbox/test_whoami.py 2012-01-04 17:12:42 +0000
@@ -53,8 +53,7 @@
"""branch specific user identity works."""
wt = self.make_branch_and_tree('.')
b = bzrlib.branch.Branch.open('.')
- b.get_config().set_user_option('email',
- 'Branch Identity <branch at identi.ty>')
+ b.get_config_stack().set('email', 'Branch Identity <branch at identi.ty>')
self.assertWhoAmI('Branch Identity <branch at identi.ty>')
self.assertWhoAmI('branch at identi.ty', '--email')
@@ -79,8 +78,8 @@
"""
wt = self.make_branch_and_tree('.')
b = bzrlib.branch.Branch.open('.')
- b.get_config().set_user_option('email', u'Branch Identity \u20ac ' +
- '<branch at identi.ty>')
+ b.get_config_stack().set(
+ 'email', u'Branch Identity \u20ac ' + '<branch at identi.ty>')
self.assertWhoAmI('Branch Identity ? <branch at identi.ty>',
encoding='ascii')
self.assertWhoAmI('branch at identi.ty', '--email',
@@ -108,21 +107,21 @@
def test_whoami_directory(self):
"""Test --directory option."""
wt = self.make_branch_and_tree('subdir')
- c = wt.branch.get_config()
- c.set_user_option('email', 'Branch Identity <branch at identi.ty>')
+ c = wt.branch.get_config_stack()
+ c.set('email', 'Branch Identity <branch at identi.ty>')
self.assertWhoAmI('Branch Identity <branch at identi.ty>',
'--directory', 'subdir')
self.run_bzr(['whoami', '--directory', 'subdir', '--branch',
'Changed Identity <changed at identi.ty>'])
- c = wt.branch.get_config()
+ c = wt.branch.get_config_stack()
self.assertEquals('Changed Identity <changed at identi.ty>',
- c.get_user_option('email'))
+ c.get('email'))
def test_whoami_remote_directory(self):
"""Test --directory option with a remote directory."""
wt = self.make_branch_and_tree('subdir')
- c = wt.branch.get_config()
- c.set_user_option('email', 'Branch Identity <branch at identi.ty>')
+ c = wt.branch.get_config_stack()
+ c.set('email', 'Branch Identity <branch at identi.ty>')
url = self.get_readonly_url() + '/subdir'
self.assertWhoAmI('Branch Identity <branch at identi.ty>',
'--directory', url)
@@ -131,11 +130,16 @@
'Changed Identity <changed at identi.ty>'])
# The identity has been set in the branch config (but not the global
# config)
- c = wt.branch.get_config()
+ c = wt.branch.get_config_stack()
self.assertEquals('Changed Identity <changed at identi.ty>',
- c.get_user_option('email'))
- global_conf = config.GlobalConfig()
- self.assertEquals(None, global_conf.get_user_option('email'))
+ c.get('email'))
+ # Ensuring that the value does not come from the bazaar.conf file
+ # itself requires some isolation setup
+ self.overrideEnv('BZR_EMAIL', None)
+ self.overrideEnv('EMAIL', None)
+ self.overrideAttr(config, '_auto_user_id', lambda: (None, None))
+ global_conf = config.GlobalStack()
+ self.assertEquals(None, global_conf.get('email'))
def test_whoami_nonbranch_directory(self):
"""Test --directory mentioning a non-branch directory."""
=== modified file 'bzrlib/tests/per_branch/test_branch.py'
--- a/bzrlib/tests/per_branch/test_branch.py 2011-10-15 00:10:14 +0000
+++ b/bzrlib/tests/per_branch/test_branch.py 2012-01-04 17:12:42 +0000
@@ -651,7 +651,7 @@
def test_get_child_submit_format(self):
branch = self.get_branch()
- branch.get_config().set_user_option('child_submit_format', '10')
+ branch.get_config_stack().set('child_submit_format', '10')
branch = self.get_branch()
self.assertEqual('10', branch.get_child_submit_format())
=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py 2011-12-30 15:00:07 +0000
+++ b/bzrlib/tests/test_branch.py 2012-01-04 17:12:42 +0000
@@ -356,9 +356,8 @@
self.assertPathDoesNotExist('a/.bzr/branch/parent')
self.assertEqual('http://example.com', branch.get_parent())
branch.set_push_location('sftp://example.com')
- config = branch.get_config()._get_branch_data_config()
- self.assertEqual('sftp://example.com',
- config.get_user_option('push_location'))
+ config = branch.get_config_stack()
+ self.assertEqual('sftp://example.com', config.get('push_location'))
branch.set_bound_location('ftp://example.com')
self.assertPathDoesNotExist('a/.bzr/branch/bound')
self.assertEqual('ftp://example.com', branch.get_bound_location())
=== modified file 'bzrlib/tests/test_merge_directive.py'
--- a/bzrlib/tests/test_merge_directive.py 2011-12-09 13:00:30 +0000
+++ b/bzrlib/tests/test_merge_directive.py 2012-01-04 17:12:42 +0000
@@ -353,8 +353,8 @@
def make_trees(self):
tree_a = self.make_branch_and_tree('tree_a')
- tree_a.branch.get_config().set_user_option('email',
- 'J. Random Hacker <jrandom at example.com>')
+ tree_a.branch.get_config_stack().set(
+ 'email', 'J. Random Hacker <jrandom at example.com>')
self.build_tree_contents([('tree_a/file', 'content_a\ncontent_b\n'),
('tree_a/file_2', 'content_x\rcontent_y\r')])
tree_a.add(['file', 'file_2'])
=== modified file 'bzrlib/tests/test_upgrade.py'
--- a/bzrlib/tests/test_upgrade.py 2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/test_upgrade.py 2012-01-04 17:12:42 +0000
@@ -53,9 +53,8 @@
self.assertEqual('CD', new_branch.last_revision())
self.assertEqual('file:///EF', new_branch.get_parent())
self.assertEqual('file:///GH', new_branch.get_bound_location())
- branch_config = new_branch.get_config()._get_branch_data_config()
- self.assertEqual('file:///IJ',
- branch_config.get_user_option('push_location'))
+ branch_config = new_branch.get_config_stack()
+ self.assertEqual('file:///IJ', branch_config.get('push_location'))
b2 = self.make_branch('branch2', format='knit')
converter = b2.bzrdir._format.get_converter(target)
More information about the bazaar-commits
mailing list