229
235
:param upload_suffix: An optional suffix to be given to any temporary
230
236
files created during the pack creation. e.g '.autopack'
231
237
:param file_mode: An optional file mode to create the new files with.
238
:param index_builder_class: Required keyword parameter - the class of
239
index builder to use.
240
:param index_class: Required keyword parameter - the class of index
233
243
# The relative locations of the packs are constrained, but all are
234
244
# passed in because the caller has them, so as to avoid object churn.
235
245
Pack.__init__(self,
236
246
# Revisions: parents list, no text compression.
237
InMemoryGraphIndex(reference_lists=1),
247
index_builder_class(reference_lists=1),
238
248
# Inventory: We want to map compression only, but currently the
239
249
# knit code hasn't been updated enough to understand that, so we
240
250
# have a regular 2-list index giving parents and compression
242
InMemoryGraphIndex(reference_lists=2),
252
index_builder_class(reference_lists=2),
243
253
# Texts: compression and per file graph, for all fileids - so two
244
254
# reference lists and two elements in the key tuple.
245
InMemoryGraphIndex(reference_lists=2, key_elements=2),
255
index_builder_class(reference_lists=2, key_elements=2),
246
256
# Signatures: Just blobs to store, no compression, no parents
248
InMemoryGraphIndex(reference_lists=0),
258
index_builder_class(reference_lists=0),
260
# When we make readonly indices, we need this.
261
self.index_class = index_class
250
262
# where should the new pack be opened
251
263
self.upload_transport = upload_transport
252
264
# where are indices written out to
592
604
return NewPack(self._pack_collection._upload_transport,
593
605
self._pack_collection._index_transport,
594
606
self._pack_collection._pack_transport, upload_suffix=self.suffix,
595
file_mode=self._pack_collection.repo.bzrdir._get_file_mode())
607
file_mode=self._pack_collection.repo.bzrdir._get_file_mode(),
608
index_builder_class=self._pack_collection._index_builder_class,
609
index_class=self._pack_collection._index_class)
597
611
def _copy_revision_texts(self):
598
612
"""Copy revision data to the new pack."""
1114
1128
:param upload_transport: Addresses the directory into which packs are written
1115
1129
while they're being created.
1116
1130
:param pack_transport: Addresses the directory of existing complete packs.
1131
:param index_builder_class: The index builder class to use.
1132
:param index_class: The index class to use.
1118
1134
self.repo = repo
1119
1135
self.transport = transport
1120
1136
self._index_transport = index_transport
1121
1137
self._upload_transport = upload_transport
1122
1138
self._pack_transport = pack_transport
1139
self._index_builder_class = index_builder_class
1140
self._index_class = index_class
1123
1141
self._suffix_offsets = {'.rix': 0, '.iix': 1, '.tix': 2, '.six': 3}
1124
1142
self.packs = []
1125
1143
# name:Pack mapping
1360
1378
detect updates from others during our write operation.
1361
1379
:return: An iterator of the index contents.
1363
return GraphIndex(self.transport, 'pack-names', None
1381
return self._index_class(self.transport, 'pack-names', None
1364
1382
).iter_all_entries()
1366
1384
def _make_index(self, name, suffix):
1367
1385
size_offset = self._suffix_offsets[suffix]
1368
1386
index_name = name + suffix
1369
1387
index_size = self._names[name][size_offset]
1388
return self._index_class(
1371
1389
self._index_transport, index_name, index_size)
1373
1391
def _max_pack_count(self, total_revisions):
1608
1626
raise errors.NotWriteLocked(self)
1609
1627
self._new_pack = NewPack(self._upload_transport, self._index_transport,
1610
1628
self._pack_transport, upload_suffix='.pack',
1611
file_mode=self.repo.bzrdir._get_file_mode())
1629
file_mode=self.repo.bzrdir._get_file_mode(),
1630
index_builder_class=self._index_builder_class,
1631
index_class=self._index_class)
1612
1632
# allow writing: queue writes to a new index
1613
1633
self.revision_index.add_writable_index(self._new_pack.revision_index,
1614
1634
self._new_pack)
1683
1703
self._pack_collection = RepositoryPackCollection(self, self._transport,
1684
1704
index_transport,
1685
1705
self._transport.clone('upload'),
1686
self._transport.clone('packs'))
1706
self._transport.clone('packs'),
1707
_format.index_builder_class,
1708
_format.index_class)
1687
1709
self.inventories = KnitVersionedFiles(
1688
1710
_KnitGraphIndex(self._pack_collection.inventory_index.combined_index,
1689
1711
add_callback=self._pack_collection.inventory_index.add_callback,
2251
2300
"""See RepositoryFormat.get_format_description()."""
2252
2301
return ("Development repository format, currently the same as "
2253
2302
"pack-0.92-subtree with external reference support.\n")
2305
class RepositoryFormatPackDevelopment2(RepositoryFormatPack):
2306
"""A no-subtrees development repository.
2308
This format should be retained until the second release after bzr 1.7.
2310
This is pack-1.6.1 with B+Tree indices.
2313
repository_class = KnitPackRepository
2314
_commit_builder_class = PackCommitBuilder
2315
_serializer = xml5.serializer_v5
2316
supports_external_lookups = True
2317
# What index classes to use
2318
index_builder_class = BTreeBuilder
2319
index_class = BTreeGraphIndex
2321
def _get_matching_bzrdir(self):
2322
return bzrdir.format_registry.make_bzrdir('development2')
2324
def _ignore_setting_bzrdir(self, format):
2327
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2329
def get_format_string(self):
2330
"""See RepositoryFormat.get_format_string()."""
2331
return "Bazaar development format 2 (needs bzr.dev from before 1.8)\n"
2333
def get_format_description(self):
2334
"""See RepositoryFormat.get_format_description()."""
2335
return ("Development repository format, currently the same as "
2336
"pack-1.6.1 with B+Trees.\n")
2338
def check_conversion_target(self, target_format):
2342
class RepositoryFormatPackDevelopment2Subtree(RepositoryFormatPack):
2343
"""A subtrees development repository.
2345
This format should be retained until the second release after bzr 1.7.
2347
pack-1.6.1-subtree with B+Tree indices.
2350
repository_class = KnitPackRepository
2351
_commit_builder_class = PackRootCommitBuilder
2352
rich_root_data = True
2353
supports_tree_reference = True
2354
_serializer = xml7.serializer_v7
2355
supports_external_lookups = True
2356
# What index classes to use
2357
index_builder_class = BTreeBuilder
2358
index_class = BTreeGraphIndex
2360
def _get_matching_bzrdir(self):
2361
return bzrdir.format_registry.make_bzrdir(
2362
'development2-subtree')
2364
def _ignore_setting_bzrdir(self, format):
2367
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2369
def check_conversion_target(self, target_format):
2370
if not target_format.rich_root_data:
2371
raise errors.BadConversionTarget(
2372
'Does not support rich root data.', target_format)
2373
if not getattr(target_format, 'supports_tree_reference', False):
2374
raise errors.BadConversionTarget(
2375
'Does not support nested trees', target_format)
2377
def get_format_string(self):
2378
"""See RepositoryFormat.get_format_string()."""
2379
return ("Bazaar development format 2 with subtree support "
2380
"(needs bzr.dev from before 1.8)\n")
2382
def get_format_description(self):
2383
"""See RepositoryFormat.get_format_description()."""
2384
return ("Development repository format, currently the same as "
2385
"pack-1.6.1-subtree with B+Tree indices.\n")