Rev 6463: (jelmer) Use config stacks in a few more places. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Feb 6 12:27:29 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6463 [merge]
revision-id: pqm at pqm.ubuntu.com-20120206122727-bq0phmt80bmlvvx7
parent: pqm at pqm.ubuntu.com-20120203105942-zq9f2k9i5a2akbvu
parent: jelmer at samba.org-20120206115842-lf34o233ut2vbrn1
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2012-02-06 12:27:27 +0000
message:
(jelmer) Use config stacks in a few more places. (Jelmer Vernooij)
modified:
bzrlib/add.py add.py-20050323030017-3a77d63feda58e33
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/commit_signature_commands.py sign_my_commits.py-20060215152201-5a6363365180e671
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/memorytree.py memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py test_changelog_merge-20110310080015-9c3muqni567c1qux-3
bzrlib/plugins/launchpad/test_register.py test_register.py-20060315182712-40f5dda945c829a8
bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
bzrlib/tests/blackbox/test_annotate.py testannotate.py-20051013044000-457f44801bfa9d39
bzrlib/tests/test_lockdir.py test_lockdir.py-20060220222025-33d4221569a3d600
bzrlib/tests/test_msgeditor.py test_msgeditor.py-20051202041359-920315ec6011ee51
bzrlib/tests/test_status.py test_status.py-20060516190614-fbf6432e4a6e8aa5
bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
=== modified file 'bzrlib/add.py'
--- a/bzrlib/add.py 2011-12-19 16:41:49 +0000
+++ b/bzrlib/add.py 2012-01-28 17:36:39 +0000
@@ -82,9 +82,7 @@
return False
opt_name = 'add.maximum_file_size'
if self._maxSize is None:
- # FIXME: We use the branch config as there is no tree config
- # -- vila 2011-12-16
- config = tree.branch.get_config_stack()
+ config = tree.get_config_stack()
self._maxSize = config.get(opt_name)
if stat_value is None:
file_size = os.path.getsize(path);
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py 2011-12-18 12:46:49 +0000
+++ b/bzrlib/commit.py 2012-01-28 17:36:39 +0000
@@ -372,7 +372,7 @@
elif self.reporter is None:
self.reporter = self._select_reporter()
if self.config_stack is None:
- self.config_stack = self.branch.get_config_stack()
+ self.config_stack = self.work_tree.get_config_stack()
self._set_specific_file_ids()
=== modified file 'bzrlib/commit_signature_commands.py'
--- a/bzrlib/commit_signature_commands.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/commit_signature_commands.py 2012-01-28 17:36:39 +0000
@@ -59,11 +59,11 @@
bzrdir = controldir.ControlDir.open(location)
branch = bzrdir.open_branch()
repo = branch.repository
- branch_config = branch.get_config()
+ branch_config = branch.get_config_stack()
if committer is None:
- committer = branch_config.username()
- gpg_strategy = gpg.GPGStrategy(branch.get_config_stack())
+ committer = branch_config.get('email')
+ gpg_strategy = gpg.GPGStrategy(branch_config)
count = 0
repo.lock_write()
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2012-02-03 10:28:47 +0000
+++ b/bzrlib/config.py 2012-02-06 11:58:42 +0000
@@ -55,7 +55,7 @@
turns on create_signatures.
create_signatures - this option controls whether bzr will always create
gpg signatures or not on commits. There is an unused
- option which in future is expected to work if
+ option which in future is expected to work if
branch settings require signatures.
log_format - this option sets the default log format. Possible values are
long, short, line, or a plugin can register new formats.
@@ -2658,6 +2658,8 @@
help="""\
Whether revisions associated with tags should be fetched.
"""))
+option_registry.register_lazy(
+ 'bzr.transform.orphan_policy', 'bzrlib.transform', 'opt_transform_orphan')
option_registry.register(
Option('bzr.workingtree.worth_saving_limit', default=10,
from_unicode=int_from_store, invalid='warning',
=== modified file 'bzrlib/memorytree.py'
--- a/bzrlib/memorytree.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/memorytree.py 2012-02-06 11:58:42 +0000
@@ -51,6 +51,9 @@
self._locks = 0
self._lock_mode = None
+ def get_config_stack(self):
+ return self.branch.get_config_stack()
+
def is_control_filename(self, filename):
# Memory tree doesn't have any control filenames
return False
=== modified file 'bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py'
--- a/bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py 2011-12-21 14:43:39 +0000
+++ b/bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py 2012-01-27 22:18:07 +0000
@@ -186,7 +186,7 @@
base_text, True)
builder.change_contents('clog-id', other=other_text, this=this_text)
merger = builder.make_merger(merge.Merge3Merger, ['clog-id'])
- merger.this_branch.get_config().set_user_option(
+ merger.this_branch.get_config_stack().set(
'changelog_merge_files', 'ChangeLog')
merge_hook_params = merge.MergeFileHookParams(merger, 'clog-id', None,
'file', 'file', 'conflict')
=== modified file 'bzrlib/plugins/launchpad/test_register.py'
--- a/bzrlib/plugins/launchpad/test_register.py 2011-03-14 10:11:58 +0000
+++ b/bzrlib/plugins/launchpad/test_register.py 2012-01-27 22:09:19 +0000
@@ -329,8 +329,8 @@
def test_gather_user_credentials_from_auth_conf(self):
auth_path = config.authentication_config_filename()
service = LaunchpadService()
- g_conf = config.GlobalConfig()
- g_conf.set_user_option('email', 'Test User <test at user.com>')
+ g_conf = config.GlobalStack()
+ g_conf.set('email', 'Test User <test at user.com>')
f = open(auth_path, 'wb')
try:
scheme, hostinfo = urlparse.urlsplit(service.service_url)[:2]
@@ -350,8 +350,8 @@
def test_gather_user_credentials_prompts(self):
service = LaunchpadService()
self.assertIs(None, service.registrant_password)
- g_conf = config.GlobalConfig()
- g_conf.set_user_option('email', 'Test User <test at user.com>')
+ g_conf = config.GlobalStack()
+ g_conf.set('email', 'Test User <test at user.com>')
stdout = tests.StringIOWrapper()
stderr = tests.StringIOWrapper()
ui.ui_factory = tests.TestUIFactory(stdin='userpass\n',
=== modified file 'bzrlib/tests/blackbox/test_add.py'
--- a/bzrlib/tests/blackbox/test_add.py 2012-01-05 17:46:44 +0000
+++ b/bzrlib/tests/blackbox/test_add.py 2012-01-27 22:09:19 +0000
@@ -247,7 +247,7 @@
self.build_tree_contents([('small.txt', '0\n')])
self.build_tree_contents([('big.txt', '01234567890123456789\n')])
self.build_tree_contents([('big2.txt', '01234567890123456789\n')])
- tree.branch.get_config().set_user_option('add.maximum_file_size', 5)
+ tree.branch.get_config_stack().set('add.maximum_file_size', 5)
out = self.run_bzr('add')[0]
results = sorted(out.rstrip('\n').split('\n'))
self.assertEquals(['adding small.txt'], results)
=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
--- a/bzrlib/tests/blackbox/test_annotate.py 2012-01-05 09:17:34 +0000
+++ b/bzrlib/tests/blackbox/test_annotate.py 2012-01-27 22:09:19 +0000
@@ -233,7 +233,8 @@
def test_annotated_edited_merged_file_revnos(self):
wt = self._create_merged_file()
out, err = self.run_bzr(['annotate', 'file'])
- email = config.extract_email_address(wt.branch.get_config().username())
+ email = config.extract_email_address(
+ wt.branch.get_config_stack().get('email'))
self.assertEqual(
'3? %-7s | local\n'
'1 test at ho | foo\n'
=== modified file 'bzrlib/tests/test_lockdir.py'
--- a/bzrlib/tests/test_lockdir.py 2011-12-14 18:27:44 +0000
+++ b/bzrlib/tests/test_lockdir.py 2012-01-27 22:09:19 +0000
@@ -433,9 +433,9 @@
self.assertContainsRe(info_list['time_ago'], r'^\d+ seconds? ago$')
def test_lock_without_email(self):
- global_config = config.GlobalConfig()
+ global_config = config.GlobalStack()
# Intentionally has no email address
- global_config.set_user_option('email', 'User Identity')
+ global_config.set('email', 'User Identity')
ld1 = self.get_lock()
ld1.create()
ld1.lock_write()
=== modified file 'bzrlib/tests/test_msgeditor.py'
--- a/bzrlib/tests/test_msgeditor.py 2011-11-16 17:19:13 +0000
+++ b/bzrlib/tests/test_msgeditor.py 2012-02-06 11:58:42 +0000
@@ -26,7 +26,6 @@
errors,
msgeditor,
osutils,
- tests,
trace,
)
from bzrlib.msgeditor import (
@@ -81,9 +80,7 @@
""")
def make_multiple_pending_tree(self):
- from bzrlib import config
- config.GlobalConfig().set_user_option('email',
- 'Bilbo Baggins <bb at hobbit.net>')
+ config.GlobalStack().set('email', 'Bilbo Baggins <bb at hobbit.net>')
tree = self.make_branch_and_tree('a')
tree.commit('Initial checkin.', timestamp=1230912900, timezone=0)
tree2 = tree.bzrdir.clone('b').open_workingtree()
=== modified file 'bzrlib/tests/test_status.py'
--- a/bzrlib/tests/test_status.py 2011-11-21 19:27:55 +0000
+++ b/bzrlib/tests/test_status.py 2012-01-27 22:09:19 +0000
@@ -46,7 +46,7 @@
self.assertContainsRe(output.getvalue(), 'empty commit')
def make_multiple_pending_tree(self):
- config.GlobalConfig().set_user_option('email', 'Joe Foo <joe at foo.com>')
+ config.GlobalStack().set('email', 'Joe Foo <joe at foo.com>')
tree = self.make_branch_and_tree('a')
tree.commit('commit 1', timestamp=1196796819, timezone=0)
tree2 = tree.bzrdir.clone('b').open_workingtree()
@@ -102,7 +102,7 @@
def test_pending_with_ghosts(self):
"""Test when a pending merge's ancestry includes ghosts."""
- config.GlobalConfig().set_user_option('email', 'Joe Foo <joe at foo.com>')
+ config.GlobalStack().set('email', 'Joe Foo <joe at foo.com>')
tree = self.make_branch_and_tree('a')
tree.commit('empty commit')
tree2 = tree.bzrdir.clone('b').open_workingtree()
=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py 2012-01-28 17:52:44 +0000
+++ b/bzrlib/tests/test_transform.py 2012-02-06 11:58:42 +0000
@@ -3713,7 +3713,7 @@
self.assertEqual(('deleting parent', 'Not deleting', 'new-1'),
remaining_conflicts.pop())
self.assertLength(1, warnings)
- self.assertStartsWith(warnings[0], 'donttouchmypreciouuus')
+ self.assertStartsWith(warnings[0], 'Value "donttouchmypreciouuus" ')
class TestTransformHooks(tests.TestCaseWithTransport):
=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py 2012-01-27 21:45:11 +0000
+++ b/bzrlib/transform.py 2012-01-28 17:39:06 +0000
@@ -22,6 +22,7 @@
import time
from bzrlib import (
+ config as _mod_config,
errors,
lazy_import,
registry,
@@ -1405,21 +1406,8 @@
delete_any(self._limbo_name(trans_id))
def new_orphan(self, trans_id, parent_id):
- # FIXME: There is no tree config, so we use the branch one (it's weird
- # to define it this way as orphaning can only occur in a working tree,
- # but that's all we have (for now). It will find the option in
- # locations.conf or bazaar.conf though) -- vila 20100916
- conf = self._tree.branch.get_config()
- conf_var_name = 'bzr.transform.orphan_policy'
- orphan_policy = conf.get_user_option(conf_var_name)
- default_policy = orphaning_registry.default_key
- if orphan_policy is None:
- orphan_policy = default_policy
- if orphan_policy not in orphaning_registry:
- trace.warning('%s (from %s) is not a known policy, defaulting '
- 'to %s' % (orphan_policy, conf_var_name, default_policy))
- orphan_policy = default_policy
- handle_orphan = orphaning_registry.get(orphan_policy)
+ conf = self._tree.get_config_stack()
+ handle_orphan = conf.get('bzr.transform.orphan_policy')
handle_orphan(self, trans_id, parent_id)
@@ -1488,6 +1476,12 @@
orphaning_registry._set_default_key('conflict')
+opt_transform_orphan = _mod_config.RegistryOption(
+ 'bzr.transform.orphan_policy', orphaning_registry,
+ help='Policy for orphaned files during transform operations.',
+ invalid='warning')
+
+
class TreeTransform(DiskTreeTransform):
"""Represent a tree transformation.
More information about the bazaar-commits
mailing list