Merge lp:~jelmer/bzr/working-tree-config-stack into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 6454
Proposed branch: lp:~jelmer/bzr/working-tree-config-stack
Merge into: lp:bzr
Diff against target: 101 lines (+21/-6)
5 files modified
bzrlib/tests/per_branch/test_branch.py (+1/-2)
bzrlib/tests/per_workingtree/test_workingtree.py (+8/-2)
bzrlib/workingtree.py (+8/-0)
bzrlib/workingtree_4.py (+1/-2)
doc/en/release-notes/bzr-2.5.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/working-tree-config-stack
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+90525@code.launchpad.net

Commit message

Add WorkingTree.get_config_stack().

Description of the change

Add WorkingTree.get_config_stack() and use it.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

29 + def test_get_config(self):

test_get_config_stack.

64 + def get_config_stack(self):
65 + return self.branch.get_config_stack()

Bah, of course ;) Comment to remind that it's only the branch conf that is
taken into account for now ?

Again, I'm surprised there are no more call sites that needs to migrate from
branch to tree config, but again, this can wait.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/per_branch/test_branch.py'
2--- bzrlib/tests/per_branch/test_branch.py 2012-01-28 00:39:01 +0000
3+++ bzrlib/tests/per_branch/test_branch.py 2012-01-28 16:42:24 +0000
4@@ -22,7 +22,6 @@
5 config,
6 delta as _mod_delta,
7 errors,
8- gpg,
9 merge,
10 osutils,
11 urlutils,
12@@ -529,7 +528,7 @@
13 looked_up_format = registry.get(network_name)
14 self.assertEqual(format.__class__, looked_up_format.__class__)
15
16- def get_get_config_calls(self):
17+ def test_get_config_calls(self):
18 # Smoke test that all branch succeed getting a config
19 br = self.make_branch('.')
20 br.get_config()
21
22=== modified file 'bzrlib/tests/per_workingtree/test_workingtree.py'
23--- bzrlib/tests/per_workingtree/test_workingtree.py 2012-01-25 21:13:15 +0000
24+++ bzrlib/tests/per_workingtree/test_workingtree.py 2012-01-28 16:42:24 +0000
25@@ -121,6 +121,12 @@
26 self.assertEqual(('filename', 'V', 'directory', 'file-id'),
27 result[0][:4])
28
29+ def test_get_config_stack(self):
30+ # Smoke test that all working trees succeed getting a config
31+ wt = self.make_branch_and_tree('.')
32+ conf = wt.get_config_stack()
33+ self.assertIsInstance(conf, config.Stack)
34+
35 def test_open_containing(self):
36 branch = self.make_branch_and_tree('.').branch
37 local_base = urlutils.local_path_from_url(branch.base)
38@@ -1200,7 +1206,7 @@
39
40 def test_set_in_branch(self):
41 wt = self.make_wt_with_worth_saving_limit()
42- conf = config.BranchStack(wt.branch)
43+ conf = wt.get_config_stack()
44 conf.set('bzr.workingtree.worth_saving_limit', '20')
45 self.assertEqual(20, wt._worth_saving_limit())
46 ds = wt.current_dirstate()
47@@ -1208,7 +1214,7 @@
48
49 def test_invalid(self):
50 wt = self.make_wt_with_worth_saving_limit()
51- conf = config.BranchStack(wt.branch)
52+ conf = wt.get_config_stack()
53 conf.set('bzr.workingtree.worth_saving_limit', 'a')
54 # If the config entry is invalid, default to 10
55 warnings = []
56
57=== modified file 'bzrlib/workingtree.py'
58--- bzrlib/workingtree.py 2012-01-28 12:47:17 +0000
59+++ bzrlib/workingtree.py 2012-01-28 16:42:24 +0000
60@@ -261,6 +261,14 @@
61 def supports_views(self):
62 return self.views.supports_views()
63
64+ def get_config_stack(self):
65+ """Retrieve the config stack for this tree.
66+
67+ :return: A ``bzrlib.config.Stack``
68+ """
69+ # For the moment, just provide the branch config stack.
70+ return self.branch.get_config_stack()
71+
72 @staticmethod
73 def open(path=None, _unsupported=False):
74 """Open an existing working tree at path.
75
76=== modified file 'bzrlib/workingtree_4.py'
77--- bzrlib/workingtree_4.py 2012-01-27 20:19:13 +0000
78+++ bzrlib/workingtree_4.py 2012-01-28 16:42:24 +0000
79@@ -255,8 +255,7 @@
80
81 :return: an integer. -1 means never save.
82 """
83- # FIXME: We want a WorkingTreeStack here -- vila 20110812
84- conf = config.BranchStack(self.branch)
85+ conf = self.get_config_stack()
86 return conf.get('bzr.workingtree.worth_saving_limit')
87
88 def filter_unversioned_files(self, paths):
89
90=== modified file 'doc/en/release-notes/bzr-2.5.txt'
91--- doc/en/release-notes/bzr-2.5.txt 2012-01-28 12:47:17 +0000
92+++ doc/en/release-notes/bzr-2.5.txt 2012-01-28 16:42:24 +0000
93@@ -90,6 +90,9 @@
94 * ``ControlDir`` now has a new method ``set_branch_reference`` which can
95 be used for setting branch references. (Jelmer Vernooij)
96
97+* New convenience API method ``WorkingTree.get_config_stack``.
98+ (Jelmer Vernooij)
99+
100 Internals
101 *********
102