/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 breezy/tests/per_branch/test_locking.py

  • Committer: Martin
  • Date: 2018-11-16 19:09:31 UTC
  • mfrom: (7175 work)
  • mto: This revision was merged to the branch mainline in revision 7177.
  • Revision ID: gzlist@googlemail.com-20181116190931-rmh7pk2an1zuecby
Merge trunk to resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
                              ('bc', 'ul', True),
89
89
                              ('r', 'ul', True),
90
90
                              ('rc', 'ul', True),
91
 
                             ], self.locks)
 
91
                              ], self.locks)
92
92
        else:
93
93
            self.assertEqual([('b', 'lr', True),
94
94
                              ('r', 'lr', True),
96
96
                              ('b', 'ul', True),
97
97
                              ('bc', 'ul', True),
98
98
                              ('r', 'ul', True),
99
 
                             ], self.locks)
 
99
                              ], self.locks)
100
100
 
101
101
    def test_02_lock_write(self):
102
102
        # Test that locking occurs in the correct order
122
122
                              ('bc', 'ul', True),
123
123
                              ('r', 'ul', True),
124
124
                              ('rc', 'ul', True),
125
 
                             ], self.locks)
 
125
                              ], self.locks)
126
126
        else:
127
127
            self.assertEqual([('b', 'lw', True),
128
128
                              ('r', 'lw', True),
130
130
                              ('b', 'ul', True),
131
131
                              ('bc', 'ul', True),
132
132
                              ('r', 'ul', True),
133
 
                             ], self.locks)
 
133
                              ], self.locks)
134
134
 
135
135
    def test_03_lock_fail_unlock_repo(self):
136
136
        # Make sure branch.unlock() is called, even if there is a
161
161
                                  ('b', 'ul', True),
162
162
                                  ('bc', 'ul', True),
163
163
                                  ('r', 'ul', False),
164
 
                                 ], self.locks)
 
164
                                  ], self.locks)
165
165
            else:
166
166
                self.assertEqual([('b', 'lw', True),
167
167
                                  ('r', 'lw', True),
169
169
                                  ('b', 'ul', True),
170
170
                                  ('bc', 'ul', True),
171
171
                                  ('r', 'ul', False),
172
 
                                 ], self.locks)
 
172
                                  ], self.locks)
173
173
 
174
174
        finally:
175
175
            # For cleanup purposes, make sure we are unlocked
203
203
                                  ('bc', 'ul', False),
204
204
                                  ('r', 'ul', True),
205
205
                                  ('rc', 'ul', True),
206
 
                                 ], self.locks)
 
206
                                  ], self.locks)
207
207
            else:
208
208
                self.assertEqual([('b', 'lw', True),
209
209
                                  ('r', 'lw', True),
210
210
                                  ('bc', 'lw', True),
211
211
                                  ('b', 'ul', True),
212
212
                                  ('bc', 'ul', False),
213
 
                                 ], self.locks)
 
213
                                  ], self.locks)
214
214
 
215
215
        finally:
216
216
            # For cleanup purposes, make sure we are unlocked
227
227
 
228
228
        self.assertEqual([('b', 'lr', True),
229
229
                          ('r', 'lr', False),
230
 
                         ], self.locks)
 
230
                          ], self.locks)
231
231
 
232
232
    def test_06_lock_write_fail_repo(self):
233
233
        # Test that the branch is not locked if it cannot lock the repository
240
240
 
241
241
        self.assertEqual([('b', 'lw', True),
242
242
                          ('r', 'lw', False),
243
 
                         ], self.locks)
 
243
                          ], self.locks)
244
244
 
245
245
    def test_07_lock_read_fail_control(self):
246
246
        # Test the repository is unlocked if we can't lock self
258
258
                              ('bc', 'lr', False),
259
259
                              ('r', 'ul', True),
260
260
                              ('rc', 'ul', True),
261
 
                             ], self.locks)
 
261
                              ], self.locks)
262
262
        else:
263
263
            self.assertEqual([('b', 'lr', True),
264
264
                              ('r', 'lr', True),
265
265
                              ('bc', 'lr', False),
266
266
                              ('r', 'ul', True),
267
 
                             ], self.locks)
 
267
                              ], self.locks)
268
268
 
269
269
    def test_08_lock_write_fail_control(self):
270
270
        # Test the repository is unlocked if we can't lock self
281
281
                              ('bc', 'lw', False),
282
282
                              ('r', 'ul', True),
283
283
                              ('rc', 'ul', True),
284
 
                             ], self.locks)
 
284
                              ], self.locks)
285
285
        else:
286
286
            self.assertEqual([('b', 'lw', True),
287
287
                              ('r', 'lw', True),
288
288
                              ('bc', 'lw', False),
289
289
                              ('r', 'ul', True),
290
 
                             ], self.locks)
 
290
                              ], self.locks)
291
291
 
292
292
    def test_lock_write_returns_None_refuses_token(self):
293
293
        branch = self.make_branch('b')
366
366
            new_branch.repository = branch.repository
367
367
            new_branch.lock_write(token=lock.token)
368
368
            new_branch.unlock()
369
 
            self.assertTrue(branch.get_physical_lock_status()) #XXX
 
369
            self.assertTrue(branch.get_physical_lock_status())  # XXX
370
370
 
371
371
    def test_lock_write_with_token_fails_when_unlocked(self):
372
372
        # First, lock and then unlock to get superficially valid tokens.  This
523
523
        branch.lock_write()
524
524
        branch.unlock()
525
525
        self.assertRaises(errors.LockNotHeld, branch.repository.unlock)
526