~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_pack_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-11-27 08:26:50 UTC
  • mfrom: (3860.1.1 153786-retry)
  • Revision ID: pqm@pqm.ubuntu.com-20081127082650-adzra5ok5apue0gl
(mbp, for jam) retry when pack operations fail

Show diffs side-by-side

added added

removed removed

Lines of Context:
420
420
        finally:
421
421
            tree.unlock()
422
422
 
 
423
    def test_concurrent_pack_during_get_record_reloads(self):
 
424
        tree = self.make_branch_and_tree('tree')
 
425
        tree.lock_write()
 
426
        try:
 
427
            rev1 = tree.commit('one')
 
428
            rev2 = tree.commit('two')
 
429
            keys = [(rev1,), (rev2,)]
 
430
            r2 = repository.Repository.open('tree')
 
431
            r2.lock_read()
 
432
            try:
 
433
                # At this point, we will start grabbing a record stream, and
 
434
                # trigger a repack mid-way
 
435
                packed = False
 
436
                result = {}
 
437
                record_stream = r2.revisions.get_record_stream(keys,
 
438
                                    'unordered', False)
 
439
                for record in record_stream:
 
440
                    result[record.key] = record
 
441
                    if not packed:
 
442
                        tree.branch.repository.pack()
 
443
                        packed = True
 
444
                # The first record will be found in the original location, but
 
445
                # after the pack, we have to reload to find the next record
 
446
                self.assertEqual(sorted(keys), sorted(result.keys()))
 
447
            finally:
 
448
                r2.unlock()
 
449
        finally:
 
450
            tree.unlock()
 
451
 
423
452
    def test_lock_write_does_not_physically_lock(self):
424
453
        repo = self.make_repository('.', format=self.get_format())
425
454
        repo.lock_write()