~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-12 15:12:07 UTC
  • mfrom: (6225.2.10 314314-obsolete-packs)
  • Revision ID: pqm@pqm.ubuntu.com-20111212151207-xiz0tu02z1hxrq76
(jelmer) Deal with the obsolete_packs directory being removed from under us.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1082
1082
            sorted(set([osutils.splitext(n)[0] for n in
1083
1083
                        packs._index_transport.list_dir('.')])))
1084
1084
 
 
1085
    def test__obsolete_packs_missing_directory(self):
 
1086
        tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True)
 
1087
        r.control_transport.rmdir('obsolete_packs')
 
1088
        names = packs.names()
 
1089
        pack = packs.get_pack_by_name(names[0])
 
1090
        # Schedule this one for removal
 
1091
        packs._remove_pack_from_memory(pack)
 
1092
        # Now trigger the obsoletion, and ensure that all the remaining files
 
1093
        # are still renamed
 
1094
        packs._obsolete_packs([pack])
 
1095
        self.assertEqual([n + '.pack' for n in names[1:]],
 
1096
                         sorted(packs._pack_transport.list_dir('.')))
 
1097
        # names[0] should not be present in the index anymore
 
1098
        self.assertEqual(names[1:],
 
1099
            sorted(set([osutils.splitext(n)[0] for n in
 
1100
                        packs._index_transport.list_dir('.')])))
 
1101
 
1085
1102
    def test_pack_distribution_zero(self):
1086
1103
        packs = self.get_packs()
1087
1104
        self.assertEqual([0], packs.pack_distribution(0))
1357
1374
        obsolete_names = set([osutils.splitext(n)[0] for n in obsolete_packs])
1358
1375
        self.assertEqual([pack.name], sorted(obsolete_names))
1359
1376
 
 
1377
    def test_pack_no_obsolete_packs_directory(self):
 
1378
        """Bug #314314, don't fail if obsolete_packs directory does
 
1379
        not exist."""
 
1380
        tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True)
 
1381
        r.control_transport.rmdir('obsolete_packs')
 
1382
        packs._clear_obsolete_packs()
1360
1383
 
1361
1384
 
1362
1385
class TestPack(TestCaseWithTransport):