111
112
self.assertFalse(t.has('knits'))
112
113
# revision-indexes file-container directory
113
114
self.assertEqual([],
114
list(GraphIndex(t, 'pack-names', None).iter_all_entries()))
115
list(self.index_class(t, 'pack-names', None).iter_all_entries()))
115
116
self.assertTrue(S_ISDIR(t.stat('packs').st_mode))
116
117
self.assertTrue(S_ISDIR(t.stat('upload').st_mode))
117
118
self.assertTrue(S_ISDIR(t.stat('indices').st_mode))
152
153
tree = self.make_branch_and_tree('.', format=format)
153
154
trans = tree.branch.repository.bzrdir.get_repository_transport(None)
154
155
self.assertEqual([],
155
list(GraphIndex(trans, 'pack-names', None).iter_all_entries()))
156
list(self.index_class(trans, 'pack-names', None).iter_all_entries()))
156
157
tree.commit('foobarbaz')
157
index = GraphIndex(trans, 'pack-names', None)
158
index = self.index_class(trans, 'pack-names', None)
158
159
index_nodes = list(index.iter_all_entries())
159
160
self.assertEqual(1, len(index_nodes))
160
161
node = index_nodes[0]
173
174
tree1.branch.repository.fetch(tree2.branch.repository)
174
175
trans = tree1.branch.repository.bzrdir.get_repository_transport(None)
175
176
self.assertEqual([],
176
list(GraphIndex(trans, 'pack-names', None).iter_all_entries()))
177
list(self.index_class(trans, 'pack-names', None).iter_all_entries()))
178
179
def test_commit_across_pack_shape_boundary_autopacks(self):
179
180
format = self.get_format()
187
188
for x in range(9):
188
189
tree.commit('commit %s' % x)
189
190
# there should be 9 packs:
190
index = GraphIndex(trans, 'pack-names', None)
191
index = self.index_class(trans, 'pack-names', None)
191
192
self.assertEqual(9, len(list(index.iter_all_entries())))
192
193
# insert some files in obsolete_packs which should be removed by pack.
193
194
trans.put_bytes('obsolete_packs/foo', '123')
194
195
trans.put_bytes('obsolete_packs/bar', '321')
195
196
# committing one more should coalesce to 1 of 10.
196
197
tree.commit('commit triggering pack')
197
index = GraphIndex(trans, 'pack-names', None)
198
index = self.index_class(trans, 'pack-names', None)
198
199
self.assertEqual(1, len(list(index.iter_all_entries())))
199
200
# packing should not damage data
200
201
tree = tree.bzrdir.open_workingtree()
210
211
large_pack_name = list(index.iter_all_entries())[0][1][0]
211
212
# finally, committing again should not touch the large pack.
212
213
tree.commit('commit not triggering pack')
213
index = GraphIndex(trans, 'pack-names', None)
214
index = self.index_class(trans, 'pack-names', None)
214
215
self.assertEqual(2, len(list(index.iter_all_entries())))
215
216
pack_names = [node[1][0] for node in index.iter_all_entries()]
216
217
self.assertTrue(large_pack_name in pack_names)
239
240
tree.commit('more work')
240
241
tree.branch.repository.pack()
241
242
# there should be 1 pack:
242
index = GraphIndex(trans, 'pack-names', None)
243
index = self.index_class(trans, 'pack-names', None)
243
244
self.assertEqual(1, len(list(index.iter_all_entries())))
244
245
self.assertEqual(2, len(tree.branch.repository.all_revision_ids()))
581
582
for x in range(9):
582
583
tree.commit('commit %s' % x)
583
584
# there should be 9 packs:
584
index = GraphIndex(trans, 'pack-names', None)
585
index = self.index_class(trans, 'pack-names', None)
585
586
self.assertEqual(9, len(list(index.iter_all_entries())))
586
587
# committing one more should coalesce to 1 of 10.
587
588
tree.commit('commit triggering pack')
588
index = GraphIndex(trans, 'pack-names', None)
589
index = self.index_class(trans, 'pack-names', None)
589
590
self.assertEqual(1, len(list(index.iter_all_entries())))
590
591
# packing should not damage data
591
592
tree = tree.bzrdir.open_workingtree()
601
602
large_pack_name = list(index.iter_all_entries())[0][1][0]
602
603
# finally, committing again should not touch the large pack.
603
604
tree.commit('commit not triggering pack')
604
index = GraphIndex(trans, 'pack-names', None)
605
index = self.index_class(trans, 'pack-names', None)
605
606
self.assertEqual(2, len(list(index.iter_all_entries())))
606
607
pack_names = [node[1][0] for node in index.iter_all_entries()]
607
608
self.assertTrue(large_pack_name in pack_names)
613
614
scenarios_params = [
614
615
dict(format_name='pack-0.92',
615
616
format_string="Bazaar pack repository format 1 (needs bzr 0.92)\n",
616
format_supports_external_lookups=False),
617
format_supports_external_lookups=False,
618
index_class=GraphIndex),
617
619
dict(format_name='pack-0.92-subtree',
618
620
format_string="Bazaar pack repository format 1 "
619
621
"with subtree support (needs bzr 0.92)\n",
620
format_supports_external_lookups=False),
622
format_supports_external_lookups=False,
623
index_class=GraphIndex),
621
624
dict(format_name='1.6',
622
625
format_string="Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n",
623
format_supports_external_lookups=True),
626
format_supports_external_lookups=True,
627
index_class=GraphIndex),
624
628
dict(format_name='1.6.1-rich-root',
625
629
format_string="Bazaar RepositoryFormatKnitPack5RichRoot "
627
format_supports_external_lookups=True),
628
dict(format_name='development',
629
format_string="Bazaar development format 1 "
630
"(needs bzr.dev from before 1.6)\n",
631
format_supports_external_lookups=True),
632
dict(format_name='development-subtree',
633
format_string="Bazaar development format 1 "
634
"with subtree support (needs bzr.dev from before 1.6)\n",
635
format_supports_external_lookups=True),
631
format_supports_external_lookups=True,
632
index_class=GraphIndex),
633
dict(format_name='development2',
634
format_string="Bazaar development format 2 "
635
"(needs bzr.dev from before 1.8)\n",
636
format_supports_external_lookups=True,
637
index_class=BTreeGraphIndex),
638
dict(format_name='development2-subtree',
639
format_string="Bazaar development format 2 "
640
"with subtree support (needs bzr.dev from before 1.8)\n",
641
format_supports_external_lookups=True,
642
index_class=BTreeGraphIndex),
637
644
adapter = tests.TestScenarioApplier()
638
645
# name of the scenario is the format name