Merge lp:~abentley/bzr/config-cache-bugs into lp:bzr

Proposed by Aaron Bentley on 2012-03-06
Status: Merged
Approved by: Martin Packman on 2012-03-08
Approved revision: 6482
Merged at revision: 6487
Proposed branch: lp:~abentley/bzr/config-cache-bugs
Merge into: lp:bzr
Diff against target: 48 lines (+39/-0)
1 file modified
bzrlib/tests/test_branch.py (+39/-0)
To merge this branch: bzr merge lp:~abentley/bzr/config-cache-bugs
Reviewer Review Type Date Requested Status
Martin Packman (community) 2012-03-06 Approve on 2012-03-08
Review via email: mp+96227@code.launchpad.net

Description of the change

This branch adds tests for some config edge cases; cache coherence and
interoperation of branch.get_config() and branch.get_config_stack().

To post a comment you must log in.
lp:~abentley/bzr/config-cache-bugs updated on 2012-03-08
6482. By Aaron Bentley on 2012-03-08

Updates from review.

Martin Packman (gz) wrote :

Thanks Aaron, the tests look useful.

review: Approve
lp:~abentley/bzr/config-cache-bugs updated on 2012-03-08
6483. By Aaron Bentley on 2012-03-08

Mention bugs in comments.

Aaron Bentley (abentley) wrote :

These tests demonstrate two bugs:
#948344: BranchConfig and BranchStack do not interoperate correctly
#948339: BranchStack caching misbehaves

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/test_branch.py'
2--- bzrlib/tests/test_branch.py 2012-02-23 19:45:15 +0000
3+++ bzrlib/tests/test_branch.py 2012-03-08 15:24:32 +0000
4@@ -694,6 +694,45 @@
5 'Value "not-a-bool" is not valid for "append_revisions_only"',
6 self.warnings[0])
7
8+ def test_use_fresh_values(self):
9+ copy = _mod_branch.Branch.open(self.branch.base)
10+ copy.lock_write()
11+ try:
12+ copy.get_config_stack().set('foo', 'bar')
13+ finally:
14+ copy.unlock()
15+ self.assertFalse(self.branch.is_locked())
16+ result = self.branch.get_config_stack().get('foo')
17+ # Bug: https://bugs.launchpad.net/bzr/+bug/948339
18+ self.expectFailure('Unlocked branches cache their configs',
19+ self.assertEqual, 'bar', result)
20+
21+ def test_set_from_config_get_from_config_stack(self):
22+ self.branch.lock_write()
23+ self.addCleanup(self.branch.unlock)
24+ self.branch.get_config().set_user_option('foo', 'bar')
25+ result = self.branch.get_config_stack().get('foo')
26+ # https://bugs.launchpad.net/bzr/+bug/948344
27+ self.expectFailure('BranchStack uses cache after set_user_option',
28+ self.assertEqual, 'bar', result)
29+
30+ def test_set_from_config_stack_get_from_config(self):
31+ self.branch.lock_write()
32+ self.addCleanup(self.branch.unlock)
33+ self.branch.get_config_stack().set('foo', 'bar')
34+ self.assertEqual('bar',
35+ self.branch.get_config().get_user_option('foo'))
36+
37+ def test_set_delays_write(self):
38+ self.branch.lock_write()
39+ self.addCleanup(self.branch.unlock)
40+ self.branch.get_config_stack().set('foo', 'bar')
41+ copy = _mod_branch.Branch.open(self.branch.base)
42+ result = copy.get_config_stack().get('foo')
43+ # Bug: https://bugs.launchpad.net/bzr/+bug/948339
44+ self.expectFailure("Config writes are not cached.", self.assertIs,
45+ None, result)
46+
47
48 class TestPullResult(tests.TestCase):
49