1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
1
# Copyright (C) 2008-2011 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
44
44
GroupCompressVersionedFiles,
46
46
from bzrlib.repofmt.pack_repo import (
51
51
PackRootCommitBuilder,
52
52
RepositoryPackCollection,
53
53
RepositoryFormatPack,
57
from bzrlib.repository import (
57
60
from bzrlib.static_tuple import StaticTuple
352
355
"""Build a VersionedFiles instance on top of this group of packs."""
353
356
index_name = index_name + '_index'
354
357
index_to_pack = {}
355
access = knit._DirectPackAccess(index_to_pack,
356
reload_func=self._reload_func)
358
access = _DirectPackAccess(index_to_pack,
359
reload_func=self._reload_func)
359
362
if self.new_pack is None:
421
424
inventory_keys = source_vf.keys()
422
425
missing_inventories = set(self.revision_keys).difference(inventory_keys)
423
426
if missing_inventories:
424
missing_inventories = sorted(missing_inventories)
425
raise ValueError('We are missing inventories for revisions: %s'
426
% (missing_inventories,))
427
# Go back to the original repo, to see if these are really missing
428
# https://bugs.launchpad.net/bzr/+bug/437003
429
# If we are packing a subset of the repo, it is fine to just have
430
# the data in another Pack file, which is not included in this pack
432
inv_index = self._pack_collection.repo.inventories._index
433
pmap = inv_index.get_parent_map(missing_inventories)
434
really_missing = missing_inventories.difference(pmap)
436
missing_inventories = sorted(really_missing)
437
raise ValueError('We are missing inventories for revisions: %s'
438
% (missing_inventories,))
427
439
self._copy_stream(source_vf, target_vf, inventory_keys,
428
440
'inventories', self._get_filtered_inv_stream, 2)
823
class CHKInventoryRepository(KnitPackRepository):
824
"""subclass of KnitPackRepository that uses CHK based inventories."""
835
class CHKInventoryRepository(PackRepository):
836
"""subclass of PackRepository that uses CHK based inventories."""
826
838
def __init__(self, _format, a_bzrdir, control_files, _commit_builder_class,
828
840
"""Overridden to change pack collection class."""
829
KnitPackRepository.__init__(self, _format, a_bzrdir, control_files,
841
super(CHKInventoryRepository, self).__init__(_format, a_bzrdir, control_files,
830
842
_commit_builder_class, _serializer)
831
# and now replace everything it did :)
832
843
index_transport = self._transport.clone('indices')
833
844
self._pack_collection = GCRepositoryPackCollection(self,
834
845
self._transport, index_transport,
1138
1149
return super(CHKInventoryRepository, self)._get_source(to_format)
1141
class GroupCHKStreamSource(KnitPackStreamSource):
1152
class GroupCHKStreamSource(StreamSource):
1142
1153
"""Used when both the source and target repo are GroupCHK repos."""
1144
1155
def __init__(self, from_repository, to_format):
1231
1242
self._chk_p_id_roots = None
1232
1243
yield 'chk_bytes', _get_parent_id_basename_to_file_id_pages()
1245
def _get_text_stream(self):
1246
# Note: We know we don't have to handle adding root keys, because both
1247
# the source and target are the identical network name.
1248
text_stream = self.from_repository.texts.get_record_stream(
1249
self._text_keys, self._text_fetch_order, False)
1250
return ('texts', text_stream)
1234
1252
def get_stream(self, search):
1235
1253
def wrap_and_count(pb, rc, stream):
1236
1254
"""Yield records from stream while showing progress."""
1344
class RepositoryFormatCHK1(RepositoryFormatPack):
1345
"""A hashed CHK+group compress pack repository."""
1360
class RepositoryFormat2a(RepositoryFormatPack):
1361
"""A CHK repository that uses the bencode revision serializer."""
1347
1363
repository_class = CHKInventoryRepository
1348
1364
supports_external_lookups = True
1349
1365
supports_chks = True
1350
# For right now, setting this to True gives us InterModel1And2 rather
1351
# than InterDifferingSerializer
1352
1366
_commit_builder_class = PackRootCommitBuilder
1353
1367
rich_root_data = True
1354
_serializer = chk_serializer.chk_serializer_255_bigpage
1368
_serializer = chk_serializer.chk_bencode_serializer
1355
1369
_commit_inv_deltas = True
1356
1370
# What index classes to use
1357
1371
index_builder_class = BTreeBuilder
1368
1382
pack_compresses = True
1370
1384
def _get_matching_bzrdir(self):
1371
return bzrdir.format_registry.make_bzrdir('development6-rich-root')
1373
def _ignore_setting_bzrdir(self, format):
1376
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
1378
def get_format_string(self):
1379
"""See RepositoryFormat.get_format_string()."""
1380
return ('Bazaar development format - group compression and chk inventory'
1381
' (needs bzr.dev from 1.14)\n')
1383
def get_format_description(self):
1384
"""See RepositoryFormat.get_format_description()."""
1385
return ("Development repository format - rich roots, group compression"
1386
" and chk inventories")
1389
class RepositoryFormatCHK2(RepositoryFormatCHK1):
1390
"""A CHK repository that uses the bencode revision serializer."""
1392
_serializer = chk_serializer.chk_bencode_serializer
1394
def _get_matching_bzrdir(self):
1395
return bzrdir.format_registry.make_bzrdir('development7-rich-root')
1397
def _ignore_setting_bzrdir(self, format):
1400
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
1402
def get_format_string(self):
1403
"""See RepositoryFormat.get_format_string()."""
1404
return ('Bazaar development format - chk repository with bencode '
1405
'revision serialization (needs bzr.dev from 1.16)\n')
1408
class RepositoryFormat2a(RepositoryFormatCHK2):
1409
"""A CHK repository that uses the bencode revision serializer.
1411
This is the same as RepositoryFormatCHK2 but with a public name.
1414
_serializer = chk_serializer.chk_bencode_serializer
1416
def _get_matching_bzrdir(self):
1417
1385
return bzrdir.format_registry.make_bzrdir('2a')
1419
1387
def _ignore_setting_bzrdir(self, format):