~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_pack_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-04 03:10:00 UTC
  • mfrom: (4927.1.1 merge-2.0-into-devel)
  • Revision ID: pqm@pqm.ubuntu.com-20100104031000-z5cdnjpq7phqxwf2
(andrew) Merge lp:bzr/2.0 into lp:bzr, including fixes for #343218,
        #495000, #495023, #494406 and #498378.

Show diffs side-by-side

added added

removed removed

Lines of Context:
545
545
        finally:
546
546
            tree.unlock()
547
547
 
 
548
    def test_concurrent_pack_during_autopack(self):
 
549
        tree = self.make_branch_and_tree('tree')
 
550
        tree.lock_write()
 
551
        try:
 
552
            for i in xrange(9):
 
553
                tree.commit('rev %d' % (i,))
 
554
            r2 = repository.Repository.open('tree')
 
555
            r2.lock_write()
 
556
            try:
 
557
                # Monkey patch so that pack occurs while the other repo is
 
558
                # autopacking. This is slightly bad, but all current pack
 
559
                # repository implementations have a _pack_collection, and we
 
560
                # test that it gets triggered. So if a future format changes
 
561
                # things, the test will fail rather than succeed accidentally.
 
562
                autopack_count = [0]
 
563
                r1 = tree.branch.repository
 
564
                orig = r1._pack_collection.pack_distribution
 
565
                def trigger_during_auto(*args, **kwargs):
 
566
                    ret = orig(*args, **kwargs)
 
567
                    if not autopack_count[0]:
 
568
                        r2.pack()
 
569
                    autopack_count[0] += 1
 
570
                    return ret
 
571
                r1._pack_collection.pack_distribution = trigger_during_auto
 
572
                tree.commit('autopack-rev')
 
573
                # This triggers 2 autopacks. The first one causes r2.pack() to
 
574
                # fire, but r2 doesn't see the new pack file yet. The
 
575
                # autopack restarts and sees there are 2 files and there
 
576
                # should be only 1 for 10 commits. So it goes ahead and
 
577
                # finishes autopacking.
 
578
                self.assertEqual([2], autopack_count)
 
579
            finally:
 
580
                r2.unlock()
 
581
        finally:
 
582
            tree.unlock()
 
583
 
548
584
    def test_lock_write_does_not_physically_lock(self):
549
585
        repo = self.make_repository('.', format=self.get_format())
550
586
        repo.lock_write()