~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

Change the _obsolete_packs code to handle files that are already gone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1132
1132
        # check some arbitrary big numbers
1133
1133
        self.assertEqual(25, packs._max_pack_count(112894))
1134
1134
 
 
1135
    def test__obsolete_packs(self):
 
1136
        tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True)
 
1137
        names = packs.names()
 
1138
        pack = packs.get_pack_by_name(names[0])
 
1139
        # Schedule this one for removal
 
1140
        packs._remove_pack_from_memory(pack)
 
1141
        # Simulate a concurrent update by renaming the .pack file and one of
 
1142
        # the indices
 
1143
        packs.transport.rename('packs/%s.pack' % (names[0],),
 
1144
                               'obsolete_packs/%s.pack' % (names[0],))
 
1145
        packs.transport.rename('indices/%s.iix' % (names[0],),
 
1146
                               'obsolete_packs/%s.iix' % (names[0],))
 
1147
        # Now trigger the obsoletion, and ensure that all the remaining files
 
1148
        # are still renamed
 
1149
        packs._obsolete_packs([pack])
 
1150
        self.assertEqual([n + '.pack' for n in names[1:]],
 
1151
                         sorted(packs._pack_transport.list_dir('.')))
 
1152
        # names[0] should not be present in the index anymore
 
1153
        self.assertEqual(names[1:],
 
1154
            sorted(set([osutils.splitext(n)[0] for n in
 
1155
                        packs._index_transport.list_dir('.')])))
 
1156
 
1135
1157
    def test_pack_distribution_zero(self):
1136
1158
        packs = self.get_packs()
1137
1159
        self.assertEqual([0], packs.pack_distribution(0))