1279
1280
self.assertEqual({revs[-1]:(revs[-2],)}, r.get_parent_map([revs[-1]]))
1280
1281
self.assertFalse(packs.reload_pack_names())
1283
def test_reload_pack_names_preserves_pending(self):
1284
# TODO: Update this to also test for pending-deleted names
1285
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True)
1286
# We will add one pack (via start_write_group + insert_record_stream),
1287
# and remove another pack (via _remove_pack_from_memory)
1288
orig_names = packs.names()
1289
orig_at_load = packs._packs_at_load
1290
to_remove_name = iter(orig_names).next()
1291
r.start_write_group()
1292
self.addCleanup(r.abort_write_group)
1293
r.texts.insert_record_stream([versionedfile.FulltextContentFactory(
1294
('text', 'rev'), (), None, 'content\n')])
1295
new_pack = packs._new_pack
1296
self.assertTrue(new_pack.data_inserted())
1298
packs.allocate(new_pack)
1299
packs._new_pack = None
1300
removed_pack = packs.get_pack_by_name(to_remove_name)
1301
packs._remove_pack_from_memory(removed_pack)
1302
names = packs.names()
1303
all_nodes, deleted_nodes, new_nodes = packs._diff_pack_names()
1304
new_names = set([x[0][0] for x in new_nodes])
1305
self.assertEqual(names, sorted([x[0][0] for x in all_nodes]))
1306
self.assertEqual(set(names) - set(orig_names), new_names)
1307
self.assertEqual(set([new_pack.name]), new_names)
1308
self.assertEqual([to_remove_name],
1309
sorted([x[0][0] for x in deleted_nodes]))
1310
packs.reload_pack_names()
1311
reloaded_names = packs.names()
1312
self.assertEqual(orig_at_load, packs._packs_at_load)
1313
self.assertEqual(names, reloaded_names)
1314
all_nodes, deleted_nodes, new_nodes = packs._diff_pack_names()
1315
new_names = set([x[0][0] for x in new_nodes])
1316
self.assertEqual(names, sorted([x[0][0] for x in all_nodes]))
1317
self.assertEqual(set(names) - set(orig_names), new_names)
1318
self.assertEqual(set([new_pack.name]), new_names)
1319
self.assertEqual([to_remove_name],
1320
sorted([x[0][0] for x in deleted_nodes]))
1282
1322
def test_autopack_reloads_and_stops(self):
1283
1323
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True)
1284
1324
# After we have determined what needs to be autopacked, trigger a