~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-14 15:22:39 UTC
  • mfrom: (4523.4.21 1.18-lock-warnings)
  • Revision ID: pqm@pqm.ubuntu.com-20090814152239-m0ybwy7vfs32exeh
(jam) Update the test suite to cause failures when we take out
        multiple locks on the same file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
                         shelf_trans_id))
62
62
 
63
63
    def test_shelve_rename(self):
 
64
        self.thisFailsStrictLockCheck()
64
65
        creator = self.prepare_shelve_rename()
65
66
        creator.shelve_rename('foo-id')
66
67
        self.check_shelve_rename(creator)
67
68
 
68
69
    def test_shelve_change_handles_rename(self):
 
70
        self.thisFailsStrictLockCheck()
69
71
        creator = self.prepare_shelve_rename()
70
72
        creator.shelve_change(('rename', 'foo-id', 'foo', 'bar'))
71
73
        self.check_shelve_rename(creator)
95
97
        self.assertEqual('foo/baz', tree.id2path('baz-id'))
96
98
 
97
99
    def test_shelve_move(self):
 
100
        self.thisFailsStrictLockCheck()
98
101
        creator, tree = self.prepare_shelve_move()
99
102
        creator.shelve_rename('baz-id')
100
103
        self.check_shelve_move(creator, tree)
101
104
 
102
105
    def test_shelve_change_handles_move(self):
 
106
        self.thisFailsStrictLockCheck()
103
107
        creator, tree = self.prepare_shelve_move()
104
108
        creator.shelve_change(('rename', 'baz-id', 'foo/baz', 'bar/baz'))
105
109
        self.check_shelve_move(creator, tree)
110
114
        self.assertFileEqual(expected_content, shelf_file)
111
115
 
112
116
    def test_shelve_content_change(self):
 
117
        self.thisFailsStrictLockCheck()
113
118
        tree = self.make_branch_and_tree('.')
114
119
        tree.lock_write()
115
120
        self.addCleanup(tree.unlock)
155
160
            creator.shelf_transform.final_kind(s_bar_trans_id))
156
161
 
157
162
    def test_shelve_creation(self):
 
163
        self.thisFailsStrictLockCheck()
158
164
        creator, tree = self.prepare_shelve_creation()
159
165
        creator.shelve_creation('foo-id')
160
166
        creator.shelve_creation('bar-id')
162
168
        self.check_shelve_creation(creator, tree)
163
169
 
164
170
    def test_shelve_change_handles_creation(self):
 
171
        self.thisFailsStrictLockCheck()
165
172
        creator, tree = self.prepare_shelve_creation()
166
173
        creator.shelve_change(('add file', 'foo-id', 'file', 'foo'))
167
174
        creator.shelve_change(('add file', 'bar-id', 'directory', 'bar'))
194
201
        self.assertEqual(link_target, ptree.get_symlink_target('foo-id'))
195
202
 
196
203
    def test_shelve_symlink_creation(self):
 
204
        self.thisFailsStrictLockCheck()
197
205
        self._test_shelve_symlink_creation('foo', 'bar')
198
206
 
199
207
    def test_shelve_unicode_symlink_creation(self):
200
208
        self.requireFeature(tests.UnicodeFilenameFeature)
 
209
        self.thisFailsStrictLockCheck()
201
210
        self._test_shelve_symlink_creation(u'fo\N{Euro Sign}o',
202
211
                                           u'b\N{Euro Sign}ar')
203
212
 
204
213
    def test_shelve_change_handles_symlink_creation(self):
 
214
        self.thisFailsStrictLockCheck()
205
215
        self._test_shelve_symlink_creation('foo', 'bar', shelve_change=True)
206
216
 
207
217
    def _test_shelve_symlink_target_change(self, link_name,
235
245
        self.assertEqual(new_target, ptree.get_symlink_target('foo-id'))
236
246
 
237
247
    def test_shelve_symlink_target_change(self):
 
248
        self.thisFailsStrictLockCheck()
238
249
        self._test_shelve_symlink_target_change('foo', 'bar', 'baz')
239
250
 
240
251
    def test_shelve_unicode_symlink_target_change(self):
 
252
        self.thisFailsStrictLockCheck()
241
253
        self.requireFeature(tests.UnicodeFilenameFeature)
242
254
        self._test_shelve_symlink_target_change(
243
255
            u'fo\N{Euro Sign}o', u'b\N{Euro Sign}ar', u'b\N{Euro Sign}az')
244
256
 
245
257
    def test_shelve_change_handles_symlink_target_change(self):
 
258
        self.thisFailsStrictLockCheck()
246
259
        self._test_shelve_symlink_target_change('foo', 'bar', 'baz',
247
260
                                                shelve_change=True)
248
261
 
249
262
    def test_shelve_creation_no_contents(self):
 
263
        self.thisFailsStrictLockCheck()
250
264
        tree = self.make_branch_and_tree('.')
251
265
        tree.lock_write()
252
266
        self.addCleanup(tree.unlock)
291
305
        self.assertFileEqual('baz', 'tree/foo/bar')
292
306
 
293
307
    def test_shelve_deletion(self):
 
308
        self.thisFailsStrictLockCheck()
294
309
        creator, tree = self.prepare_shelve_deletion()
295
310
        creator.shelve_deletion('foo-id')
296
311
        creator.shelve_deletion('bar-id')
298
313
        self.check_shelve_deletion(tree)
299
314
 
300
315
    def test_shelve_change_handles_deletion(self):
 
316
        self.thisFailsStrictLockCheck()
301
317
        creator, tree = self.prepare_shelve_deletion()
302
318
        creator.shelve_change(('delete file', 'foo-id', 'directory', 'foo'))
303
319
        creator.shelve_change(('delete file', 'bar-id', 'file', 'foo/bar'))
305
321
        self.check_shelve_deletion(tree)
306
322
 
307
323
    def test_shelve_delete_contents(self):
 
324
        self.thisFailsStrictLockCheck()
308
325
        tree = self.make_branch_and_tree('tree')
309
326
        self.build_tree(['tree/foo',])
310
327
        tree.add('foo', 'foo-id')
338
355
                         creator.shelf_transform._new_contents[s_trans_id])
339
356
 
340
357
    def test_shelve_change_kind(self):
 
358
        self.thisFailsStrictLockCheck()
341
359
        creator = self.prepare_shelve_change_kind()
342
360
        creator.shelve_content_change('foo-id')
343
361
        creator.transform()
344
362
        self.check_shelve_change_kind(creator)
345
363
 
346
364
    def test_shelve_change_handles_change_kind(self):
 
365
        self.thisFailsStrictLockCheck()
347
366
        creator = self.prepare_shelve_change_kind()
348
367
        creator.shelve_change(('change kind', 'foo-id', 'file', 'directory',
349
368
                               'foo'))
351
370
        self.check_shelve_change_kind(creator)
352
371
 
353
372
    def test_shelve_change_unknown_change(self):
 
373
        self.thisFailsStrictLockCheck()
354
374
        tree = self.make_branch_and_tree('tree')
355
375
        creator = shelf.ShelfCreator(tree, tree.basis_tree())
356
376
        self.addCleanup(creator.finalize)
358
378
        self.assertEqual('Unknown change kind: "unknown"', str(e))
359
379
 
360
380
    def test_shelve_unversion(self):
 
381
        self.thisFailsStrictLockCheck()
361
382
        tree = self.make_branch_and_tree('tree')
362
383
        self.build_tree(['tree/foo',])
363
384
        tree.add('foo', 'foo-id')
372
393
        self.failUnlessExists('tree/foo')
373
394
 
374
395
    def test_shelve_serialization(self):
 
396
        self.thisFailsStrictLockCheck()
375
397
        tree = self.make_branch_and_tree('.')
376
398
        creator = shelf.ShelfCreator(tree, tree.basis_tree())
377
399
        self.addCleanup(creator.finalize)
384
406
        self.assertFileEqual(EMPTY_SHELF, 'shelf')
385
407
 
386
408
    def test_write_shelf(self):
 
409
        self.thisFailsStrictLockCheck()
387
410
        tree = self.make_branch_and_tree('tree')
388
411
        self.build_tree(['tree/foo'])
389
412
        tree.add('foo', 'foo-id')
410
433
        tt.deserialize(records)
411
434
 
412
435
    def test_shelve_unversioned(self):
 
436
        self.thisFailsStrictLockCheck()
413
437
        tree = self.make_branch_and_tree('tree')
414
438
        self.assertRaises(errors.PathsNotVersionedError,
415
439
                          shelf.ShelfCreator, tree, tree.basis_tree(), ['foo'])
427
451
class TestUnshelver(tests.TestCaseWithTransport):
428
452
 
429
453
    def test_make_merger(self):
 
454
        self.thisFailsStrictLockCheck()
430
455
        tree = self.make_branch_and_tree('tree')
431
456
        tree.commit('first commit')
432
457
        self.build_tree_contents([('tree/foo', 'bar')])
449
474
            shelf_file.close()
450
475
 
451
476
    def test_unshelve_changed(self):
 
477
        self.thisFailsStrictLockCheck()
452
478
        tree = self.make_branch_and_tree('tree')
453
479
        tree.lock_write()
454
480
        self.addCleanup(tree.unlock)
471
497
        self.assertFileEqual('z\na\nb\nd\n', 'tree/foo')
472
498
 
473
499
    def test_unshelve_deleted(self):
 
500
        self.thisFailsStrictLockCheck()
474
501
        tree = self.make_branch_and_tree('tree')
475
502
        tree.lock_write()
476
503
        self.addCleanup(tree.unlock)
500
527
        self.assertFalse('bar-id' in tree)
501
528
 
502
529
    def test_unshelve_base(self):
 
530
        self.thisFailsStrictLockCheck()
503
531
        tree = self.make_branch_and_tree('tree')
504
532
        tree.lock_write()
505
533
        self.addCleanup(tree.unlock)
520
548
        self.assertEqual('rev1', unshelver.base_tree.get_revision_id())
521
549
 
522
550
    def test_unshelve_serialization(self):
 
551
        self.thisFailsStrictLockCheck()
523
552
        tree = self.make_branch_and_tree('.')
524
553
        self.build_tree_contents([('shelf', EMPTY_SHELF)])
525
554
        shelf_file = open('shelf', 'rb')
527
556
        unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
528
557
 
529
558
    def test_corrupt_shelf(self):
 
559
        self.thisFailsStrictLockCheck()
530
560
        tree = self.make_branch_and_tree('.')
531
561
        self.build_tree_contents([('shelf', EMPTY_SHELF.replace('metadata',
532
562
                                                                'foo'))])