~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-31 19:00:47 UTC
  • mfrom: (5743.9.5 config-lock-branch)
  • Revision ID: pqm@pqm.ubuntu.com-20110531190047-n1zhm73cb1dnp5hn
(vila) Implement branch config locking. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
def build_branch_store(test):
76
76
    if getattr(test, 'branch', None) is None:
77
77
        test.branch = test.make_branch('branch')
78
 
    return config.BranchStore(test.branch)
 
78
    # Since we can be called to create different stores, we need to build them
 
79
    # from different branch *objects*, even if they point to the same branch on
 
80
    # disk, otherwise tests about conccurent updates won't be able to trigger
 
81
    # LockContention
 
82
    return config.BranchStore(branch.Branch.open('branch'))
79
83
config.test_store_builder_registry.register('branch', build_branch_store)
80
84
 
81
85
 
87
91
def build_branch_stack(test):
88
92
    if getattr(test, 'branch', None) is None:
89
93
        test.branch = test.make_branch('branch')
90
 
    return config.BranchStack(test.branch)
 
94
    # Since we can be called to create different stacks, we need to build them
 
95
    # from different branch *objects*, even if they point to the same branch on
 
96
    # disk, otherwise tests about conccurent updates won't be able to trigger
 
97
    # LockContention
 
98
    return config.BranchStack(branch.Branch.open('branch'))
91
99
config.test_stack_builder_registry.register('branch', build_branch_stack)
92
100
 
93
101
 
2180
2188
        self.addCleanup(after_writing.set)
2181
2189
        t1.start()
2182
2190
        before_writing.wait()
2183
 
        self.assertTrue(c1.store._lock.is_held)
2184
2191
        self.assertRaises(errors.LockContention,
2185
2192
                          c2.set, 'one', 'c2')
2186
2193
        self.assertEquals('c1', c1.get('one'))
2216
2223
       t1.start()
2217
2224
       # Ensure the thread is ready to write
2218
2225
       ready_to_write.wait()
2219
 
       self.assertTrue(c1.store._lock.is_held)
2220
2226
       self.assertEquals('c1', c1.get('one'))
2221
2227
       # If we read during the write, we get the old value
2222
2228
       c2 = self.get_stack(self)