35
35
from bzrlib.decorators import needs_read_lock, needs_write_lock
36
36
from bzrlib.repository import (
39
InterSameDataRepository,
40
38
IsInWriteGroupError,
42
MetaDirRepositoryFormat,
41
from bzrlib.vf_repository import (
42
InterSameDataRepository,
43
MetaDirVersionedFileRepository,
44
MetaDirVersionedFileRepositoryFormat,
45
VersionedFileCommitBuilder,
46
VersionedFileRootCommitBuilder,
46
48
from bzrlib import symbol_versioning
116
118
def __init__(self, _format, a_bzrdir, control_files, _commit_builder_class,
118
MetaDirRepository.__init__(self, _format, a_bzrdir, control_files)
120
super(KnitRepository, self).__init__(_format, a_bzrdir, control_files)
119
121
self._commit_builder_class = _commit_builder_class
120
122
self._serializer = _serializer
121
123
self._reconcile_fixes_text_parents = True
232
234
def _make_parents_provider(self):
233
235
return _KnitsParentsProvider(self.revisions)
235
def _find_inconsistent_revision_parents(self, revisions_iterator=None):
236
"""Find revisions with different parent lists in the revision object
237
and in the index graph.
239
:param revisions_iterator: None, or an iterator of (revid,
240
Revision-or-None). This iterator controls the revisions checked.
241
:returns: an iterator yielding tuples of (revison-id, parents-in-index,
242
parents-in-revision).
244
if not self.is_locked():
245
raise AssertionError()
247
if revisions_iterator is None:
248
revisions_iterator = self._iter_revisions(None)
249
for revid, revision in revisions_iterator:
252
parent_map = vf.get_parent_map([(revid,)])
253
parents_according_to_index = tuple(parent[-1] for parent in
254
parent_map[(revid,)])
255
parents_according_to_revision = tuple(revision.parent_ids)
256
if parents_according_to_index != parents_according_to_revision:
257
yield (revid, parents_according_to_index,
258
parents_according_to_revision)
260
def _check_for_inconsistent_revision_parents(self):
261
inconsistencies = list(self._find_inconsistent_revision_parents())
263
raise errors.BzrCheckError(
264
"Revision knit has inconsistent parents.")
266
def revision_graph_can_have_wrong_parents(self):
267
# The revision.kndx could potentially claim a revision has a different
268
# parent to the revision text.
272
class RepositoryFormatKnit(MetaDirRepositoryFormat):
238
class RepositoryFormatKnit(MetaDirVersionedFileRepositoryFormat):
273
239
"""Bzr repository knit format (generalized).
275
241
This repository format has:
305
271
_fetch_uses_deltas = True
306
272
fast_deltas = False
307
273
supports_funky_characters = True
308
supports_full_versioned_files = True
274
# The revision.kndx could potentially claim a revision has a different
275
# parent to the revision text.
276
revision_graph_can_have_wrong_parents = True
310
278
def _get_inventories(self, repo_transport, repo, name='inventory'):
311
279
mapper = versionedfile.ConstantMapper(name)