605
606
def __init__(self, *args, **kwargs):
606
607
super(GCCHKCanonicalizingPacker, self).__init__(*args, **kwargs)
607
608
self._data_changed = False
609
610
def _exhaust_stream(self, source_vf, keys, message, vf_to_stream, pb_offset):
610
611
"""Create and exhaust a stream, but don't insert it.
612
613
This is useful to get the side-effects of generating a stream.
614
615
self.pb.update('scanning %s' % (message,), pb_offset)
704
705
pack_factory = GCPack
705
706
resumed_pack_factory = ResumedGCPack
706
normal_packer_class = GCCHKPacker
707
optimising_packer_class = GCCHKPacker
709
708
def _check_new_inventories(self):
710
709
"""Detect missing inventories or chk root entries for the new revisions
792
791
% (sorted(missing_text_keys),))
794
def _execute_pack_operations(self, pack_operations,
795
_packer_class=GCCHKPacker,
797
"""Execute a series of pack operations.
799
:param pack_operations: A list of [revision_count, packs_to_combine].
800
:param _packer_class: The class of packer to use (default: Packer).
803
# XXX: Copied across from RepositoryPackCollection simply because we
804
# want to override the _packer_class ... :(
805
for revision_count, packs in pack_operations:
806
# we may have no-ops from the setup logic
809
packer = GCCHKPacker(self, packs, '.autopack',
810
reload_func=reload_func)
812
result = packer.pack()
813
except errors.RetryWithNewPacks:
814
# An exception is propagating out of this context, make sure
815
# this packer has cleaned up. Packer() doesn't set its new_pack
816
# state into the RepositoryPackCollection object, so we only
817
# have access to it directly here.
818
if packer.new_pack is not None:
819
packer.new_pack.abort()
824
self._remove_pack_from_memory(pack)
825
# record the newly available packs and stop advertising the old
828
for _, packs in pack_operations:
829
to_be_obsoleted.extend(packs)
830
result = self._save_pack_names(clear_obsolete_packs=True,
831
obsolete_packs=to_be_obsoleted)
796
835
class CHKInventoryRepository(PackRepository):
797
836
"""subclass of PackRepository that uses CHK based inventories."""
799
838
def __init__(self, _format, a_bzrdir, control_files, _commit_builder_class,
801
840
"""Overridden to change pack collection class."""
802
super(CHKInventoryRepository, self).__init__(_format, a_bzrdir,
803
control_files, _commit_builder_class, _serializer)
841
super(CHKInventoryRepository, self).__init__(_format, a_bzrdir, control_files,
842
_commit_builder_class, _serializer)
804
843
index_transport = self._transport.clone('indices')
805
844
self._pack_collection = GCRepositoryPackCollection(self,
806
845
self._transport, index_transport,
1109
1148
return GroupCHKStreamSource(self, to_format)
1110
1149
return super(CHKInventoryRepository, self)._get_source(to_format)
1112
def _find_inconsistent_revision_parents(self, revisions_iterator=None):
1113
"""Find revisions with different parent lists in the revision object
1114
and in the index graph.
1116
:param revisions_iterator: None, or an iterator of (revid,
1117
Revision-or-None). This iterator controls the revisions checked.
1118
:returns: an iterator yielding tuples of (revison-id, parents-in-index,
1119
parents-in-revision).
1121
if not self.is_locked():
1122
raise AssertionError()
1124
if revisions_iterator is None:
1125
revisions_iterator = self._iter_revisions(None)
1126
for revid, revision in revisions_iterator:
1127
if revision is None:
1129
parent_map = vf.get_parent_map([(revid,)])
1130
parents_according_to_index = tuple(parent[-1] for parent in
1131
parent_map[(revid,)])
1132
parents_according_to_revision = tuple(revision.parent_ids)
1133
if parents_according_to_index != parents_according_to_revision:
1134
yield (revid, parents_according_to_index,
1135
parents_according_to_revision)
1137
def _check_for_inconsistent_revision_parents(self):
1138
inconsistencies = list(self._find_inconsistent_revision_parents())
1140
raise errors.BzrCheckError(
1141
"Revision index has inconsistent parents.")
1144
1152
class GroupCHKStreamSource(StreamSource):
1145
1153
"""Used when both the source and target repo are GroupCHK repos."""