Merge lp:~jelmer/bzr/more-config-stack-usage into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 6463
Proposed branch: lp:~jelmer/bzr/more-config-stack-usage
Merge into: lp:bzr
Diff against target: 270 lines (+34/-39)
14 files modified
bzrlib/add.py (+1/-3)
bzrlib/commit.py (+1/-1)
bzrlib/commit_signature_commands.py (+3/-3)
bzrlib/config.py (+3/-1)
bzrlib/memorytree.py (+3/-0)
bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py (+1/-1)
bzrlib/plugins/launchpad/test_register.py (+4/-4)
bzrlib/tests/blackbox/test_add.py (+1/-1)
bzrlib/tests/blackbox/test_annotate.py (+2/-1)
bzrlib/tests/test_lockdir.py (+2/-2)
bzrlib/tests/test_msgeditor.py (+1/-4)
bzrlib/tests/test_status.py (+2/-2)
bzrlib/tests/test_transform.py (+1/-1)
bzrlib/transform.py (+9/-15)
To merge this branch: bzr merge lp:~jelmer/bzr/more-config-stack-usage
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+90549@code.launchpad.net

Commit message

Use config stacks in a few more places.

Description of the change

Use config stacks in a few more places.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/add.py'
2--- bzrlib/add.py 2011-12-19 16:41:49 +0000
3+++ bzrlib/add.py 2012-02-06 12:06:21 +0000
4@@ -82,9 +82,7 @@
5 return False
6 opt_name = 'add.maximum_file_size'
7 if self._maxSize is None:
8- # FIXME: We use the branch config as there is no tree config
9- # -- vila 2011-12-16
10- config = tree.branch.get_config_stack()
11+ config = tree.get_config_stack()
12 self._maxSize = config.get(opt_name)
13 if stat_value is None:
14 file_size = os.path.getsize(path);
15
16=== modified file 'bzrlib/commit.py'
17--- bzrlib/commit.py 2011-12-18 12:46:49 +0000
18+++ bzrlib/commit.py 2012-02-06 12:06:21 +0000
19@@ -372,7 +372,7 @@
20 elif self.reporter is None:
21 self.reporter = self._select_reporter()
22 if self.config_stack is None:
23- self.config_stack = self.branch.get_config_stack()
24+ self.config_stack = self.work_tree.get_config_stack()
25
26 self._set_specific_file_ids()
27
28
29=== modified file 'bzrlib/commit_signature_commands.py'
30--- bzrlib/commit_signature_commands.py 2011-12-19 13:23:58 +0000
31+++ bzrlib/commit_signature_commands.py 2012-02-06 12:06:21 +0000
32@@ -59,11 +59,11 @@
33 bzrdir = controldir.ControlDir.open(location)
34 branch = bzrdir.open_branch()
35 repo = branch.repository
36- branch_config = branch.get_config()
37+ branch_config = branch.get_config_stack()
38
39 if committer is None:
40- committer = branch_config.username()
41- gpg_strategy = gpg.GPGStrategy(branch.get_config_stack())
42+ committer = branch_config.get('email')
43+ gpg_strategy = gpg.GPGStrategy(branch_config)
44
45 count = 0
46 repo.lock_write()
47
48=== modified file 'bzrlib/config.py'
49--- bzrlib/config.py 2012-02-03 10:28:47 +0000
50+++ bzrlib/config.py 2012-02-06 12:06:21 +0000
51@@ -55,7 +55,7 @@
52 turns on create_signatures.
53 create_signatures - this option controls whether bzr will always create
54 gpg signatures or not on commits. There is an unused
55- option which in future is expected to work if
56+ option which in future is expected to work if
57 branch settings require signatures.
58 log_format - this option sets the default log format. Possible values are
59 long, short, line, or a plugin can register new formats.
60@@ -2658,6 +2658,8 @@
61 help="""\
62 Whether revisions associated with tags should be fetched.
63 """))
64+option_registry.register_lazy(
65+ 'bzr.transform.orphan_policy', 'bzrlib.transform', 'opt_transform_orphan')
66 option_registry.register(
67 Option('bzr.workingtree.worth_saving_limit', default=10,
68 from_unicode=int_from_store, invalid='warning',
69
70=== modified file 'bzrlib/memorytree.py'
71--- bzrlib/memorytree.py 2011-12-19 13:23:58 +0000
72+++ bzrlib/memorytree.py 2012-02-06 12:06:21 +0000
73@@ -51,6 +51,9 @@
74 self._locks = 0
75 self._lock_mode = None
76
77+ def get_config_stack(self):
78+ return self.branch.get_config_stack()
79+
80 def is_control_filename(self, filename):
81 # Memory tree doesn't have any control filenames
82 return False
83
84=== modified file 'bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py'
85--- bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py 2011-12-21 14:43:39 +0000
86+++ bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py 2012-02-06 12:06:21 +0000
87@@ -186,7 +186,7 @@
88 base_text, True)
89 builder.change_contents('clog-id', other=other_text, this=this_text)
90 merger = builder.make_merger(merge.Merge3Merger, ['clog-id'])
91- merger.this_branch.get_config().set_user_option(
92+ merger.this_branch.get_config_stack().set(
93 'changelog_merge_files', 'ChangeLog')
94 merge_hook_params = merge.MergeFileHookParams(merger, 'clog-id', None,
95 'file', 'file', 'conflict')
96
97=== modified file 'bzrlib/plugins/launchpad/test_register.py'
98--- bzrlib/plugins/launchpad/test_register.py 2011-03-14 10:11:58 +0000
99+++ bzrlib/plugins/launchpad/test_register.py 2012-02-06 12:06:21 +0000
100@@ -329,8 +329,8 @@
101 def test_gather_user_credentials_from_auth_conf(self):
102 auth_path = config.authentication_config_filename()
103 service = LaunchpadService()
104- g_conf = config.GlobalConfig()
105- g_conf.set_user_option('email', 'Test User <test@user.com>')
106+ g_conf = config.GlobalStack()
107+ g_conf.set('email', 'Test User <test@user.com>')
108 f = open(auth_path, 'wb')
109 try:
110 scheme, hostinfo = urlparse.urlsplit(service.service_url)[:2]
111@@ -350,8 +350,8 @@
112 def test_gather_user_credentials_prompts(self):
113 service = LaunchpadService()
114 self.assertIs(None, service.registrant_password)
115- g_conf = config.GlobalConfig()
116- g_conf.set_user_option('email', 'Test User <test@user.com>')
117+ g_conf = config.GlobalStack()
118+ g_conf.set('email', 'Test User <test@user.com>')
119 stdout = tests.StringIOWrapper()
120 stderr = tests.StringIOWrapper()
121 ui.ui_factory = tests.TestUIFactory(stdin='userpass\n',
122
123=== modified file 'bzrlib/tests/blackbox/test_add.py'
124--- bzrlib/tests/blackbox/test_add.py 2012-01-05 17:46:44 +0000
125+++ bzrlib/tests/blackbox/test_add.py 2012-02-06 12:06:21 +0000
126@@ -247,7 +247,7 @@
127 self.build_tree_contents([('small.txt', '0\n')])
128 self.build_tree_contents([('big.txt', '01234567890123456789\n')])
129 self.build_tree_contents([('big2.txt', '01234567890123456789\n')])
130- tree.branch.get_config().set_user_option('add.maximum_file_size', 5)
131+ tree.branch.get_config_stack().set('add.maximum_file_size', 5)
132 out = self.run_bzr('add')[0]
133 results = sorted(out.rstrip('\n').split('\n'))
134 self.assertEquals(['adding small.txt'], results)
135
136=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
137--- bzrlib/tests/blackbox/test_annotate.py 2012-01-05 09:17:34 +0000
138+++ bzrlib/tests/blackbox/test_annotate.py 2012-02-06 12:06:21 +0000
139@@ -233,7 +233,8 @@
140 def test_annotated_edited_merged_file_revnos(self):
141 wt = self._create_merged_file()
142 out, err = self.run_bzr(['annotate', 'file'])
143- email = config.extract_email_address(wt.branch.get_config().username())
144+ email = config.extract_email_address(
145+ wt.branch.get_config_stack().get('email'))
146 self.assertEqual(
147 '3? %-7s | local\n'
148 '1 test@ho | foo\n'
149
150=== modified file 'bzrlib/tests/test_lockdir.py'
151--- bzrlib/tests/test_lockdir.py 2011-12-14 18:27:44 +0000
152+++ bzrlib/tests/test_lockdir.py 2012-02-06 12:06:21 +0000
153@@ -433,9 +433,9 @@
154 self.assertContainsRe(info_list['time_ago'], r'^\d+ seconds? ago$')
155
156 def test_lock_without_email(self):
157- global_config = config.GlobalConfig()
158+ global_config = config.GlobalStack()
159 # Intentionally has no email address
160- global_config.set_user_option('email', 'User Identity')
161+ global_config.set('email', 'User Identity')
162 ld1 = self.get_lock()
163 ld1.create()
164 ld1.lock_write()
165
166=== modified file 'bzrlib/tests/test_msgeditor.py'
167--- bzrlib/tests/test_msgeditor.py 2011-11-16 17:19:13 +0000
168+++ bzrlib/tests/test_msgeditor.py 2012-02-06 12:06:21 +0000
169@@ -26,7 +26,6 @@
170 errors,
171 msgeditor,
172 osutils,
173- tests,
174 trace,
175 )
176 from bzrlib.msgeditor import (
177@@ -81,9 +80,7 @@
178 """)
179
180 def make_multiple_pending_tree(self):
181- from bzrlib import config
182- config.GlobalConfig().set_user_option('email',
183- 'Bilbo Baggins <bb@hobbit.net>')
184+ config.GlobalStack().set('email', 'Bilbo Baggins <bb@hobbit.net>')
185 tree = self.make_branch_and_tree('a')
186 tree.commit('Initial checkin.', timestamp=1230912900, timezone=0)
187 tree2 = tree.bzrdir.clone('b').open_workingtree()
188
189=== modified file 'bzrlib/tests/test_status.py'
190--- bzrlib/tests/test_status.py 2011-11-21 19:27:55 +0000
191+++ bzrlib/tests/test_status.py 2012-02-06 12:06:21 +0000
192@@ -46,7 +46,7 @@
193 self.assertContainsRe(output.getvalue(), 'empty commit')
194
195 def make_multiple_pending_tree(self):
196- config.GlobalConfig().set_user_option('email', 'Joe Foo <joe@foo.com>')
197+ config.GlobalStack().set('email', 'Joe Foo <joe@foo.com>')
198 tree = self.make_branch_and_tree('a')
199 tree.commit('commit 1', timestamp=1196796819, timezone=0)
200 tree2 = tree.bzrdir.clone('b').open_workingtree()
201@@ -102,7 +102,7 @@
202
203 def test_pending_with_ghosts(self):
204 """Test when a pending merge's ancestry includes ghosts."""
205- config.GlobalConfig().set_user_option('email', 'Joe Foo <joe@foo.com>')
206+ config.GlobalStack().set('email', 'Joe Foo <joe@foo.com>')
207 tree = self.make_branch_and_tree('a')
208 tree.commit('empty commit')
209 tree2 = tree.bzrdir.clone('b').open_workingtree()
210
211=== modified file 'bzrlib/tests/test_transform.py'
212--- bzrlib/tests/test_transform.py 2012-01-28 17:52:44 +0000
213+++ bzrlib/tests/test_transform.py 2012-02-06 12:06:21 +0000
214@@ -3713,7 +3713,7 @@
215 self.assertEqual(('deleting parent', 'Not deleting', 'new-1'),
216 remaining_conflicts.pop())
217 self.assertLength(1, warnings)
218- self.assertStartsWith(warnings[0], 'donttouchmypreciouuus')
219+ self.assertStartsWith(warnings[0], 'Value "donttouchmypreciouuus" ')
220
221
222 class TestTransformHooks(tests.TestCaseWithTransport):
223
224=== modified file 'bzrlib/transform.py'
225--- bzrlib/transform.py 2012-01-27 21:45:11 +0000
226+++ bzrlib/transform.py 2012-02-06 12:06:21 +0000
227@@ -22,6 +22,7 @@
228 import time
229
230 from bzrlib import (
231+ config as _mod_config,
232 errors,
233 lazy_import,
234 registry,
235@@ -1405,21 +1406,8 @@
236 delete_any(self._limbo_name(trans_id))
237
238 def new_orphan(self, trans_id, parent_id):
239- # FIXME: There is no tree config, so we use the branch one (it's weird
240- # to define it this way as orphaning can only occur in a working tree,
241- # but that's all we have (for now). It will find the option in
242- # locations.conf or bazaar.conf though) -- vila 20100916
243- conf = self._tree.branch.get_config()
244- conf_var_name = 'bzr.transform.orphan_policy'
245- orphan_policy = conf.get_user_option(conf_var_name)
246- default_policy = orphaning_registry.default_key
247- if orphan_policy is None:
248- orphan_policy = default_policy
249- if orphan_policy not in orphaning_registry:
250- trace.warning('%s (from %s) is not a known policy, defaulting '
251- 'to %s' % (orphan_policy, conf_var_name, default_policy))
252- orphan_policy = default_policy
253- handle_orphan = orphaning_registry.get(orphan_policy)
254+ conf = self._tree.get_config_stack()
255+ handle_orphan = conf.get('bzr.transform.orphan_policy')
256 handle_orphan(self, trans_id, parent_id)
257
258
259@@ -1488,6 +1476,12 @@
260 orphaning_registry._set_default_key('conflict')
261
262
263+opt_transform_orphan = _mod_config.RegistryOption(
264+ 'bzr.transform.orphan_policy', orphaning_registry,
265+ help='Policy for orphaned files during transform operations.',
266+ invalid='warning')
267+
268+
269 class TreeTransform(DiskTreeTransform):
270 """Represent a tree transformation.
271