/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Vincent Ladeuil
  • Date: 2011-05-18 19:08:42 UTC
  • mto: (5743.10.3 config-lock-remote)
  • mto: This revision was merged to the branch mainline in revision 5942.
  • Revision ID: v.ladeuil+lp@free.fr-20110518190842-ewbuv400jedn2a16
Properly implement locking for BranchStore by delegating all the lock operations to the branch itself.

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)