~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-10 07:46:15 UTC
  • mfrom: (5844 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5845.
  • Revision ID: jelmer@samba.org-20110510074615-eptod049ndjxc4i7
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
""")
35
35
from bzrlib.decorators import needs_read_lock, needs_write_lock
36
36
from bzrlib.repository import (
37
 
    CommitBuilder,
38
37
    InterRepository,
39
 
    InterSameDataRepository,
40
38
    IsInWriteGroupError,
41
 
    MetaDirRepository,
42
 
    MetaDirRepositoryFormat,
43
39
    RepositoryFormat,
44
 
    RootCommitBuilder,
 
40
    )
 
41
from bzrlib.vf_repository import (
 
42
    InterSameDataRepository,
 
43
    MetaDirVersionedFileRepository,
 
44
    MetaDirVersionedFileRepositoryFormat,
 
45
    VersionedFileCommitBuilder,
 
46
    VersionedFileRootCommitBuilder,
45
47
    )
46
48
from bzrlib import symbol_versioning
47
49
 
103
105
        return result
104
106
 
105
107
 
106
 
class KnitRepository(MetaDirRepository):
 
108
class KnitRepository(MetaDirVersionedFileRepository):
107
109
    """Knit format repository."""
108
110
 
109
111
    # These attributes are inherited from the Repository base class. Setting
115
117
 
116
118
    def __init__(self, _format, a_bzrdir, control_files, _commit_builder_class,
117
119
        _serializer):
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)
234
236
 
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.
238
 
 
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).
243
 
        """
244
 
        if not self.is_locked():
245
 
            raise AssertionError()
246
 
        vf = self.revisions
247
 
        if revisions_iterator is None:
248
 
            revisions_iterator = self._iter_revisions(None)
249
 
        for revid, revision in revisions_iterator:
250
 
            if revision is None:
251
 
                pass
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)
259
 
 
260
 
    def _check_for_inconsistent_revision_parents(self):
261
 
        inconsistencies = list(self._find_inconsistent_revision_parents())
262
 
        if inconsistencies:
263
 
            raise errors.BzrCheckError(
264
 
                "Revision knit has inconsistent parents.")
265
 
 
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.
269
 
        return True
270
 
 
271
 
 
272
 
class RepositoryFormatKnit(MetaDirRepositoryFormat):
 
237
 
 
238
class RepositoryFormatKnit(MetaDirVersionedFileRepositoryFormat):
273
239
    """Bzr repository knit format (generalized).
274
240
 
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
309
277
 
310
278
    def _get_inventories(self, repo_transport, repo, name='inventory'):
311
279
        mapper = versionedfile.ConstantMapper(name)
414
382
    """
415
383
 
416
384
    repository_class = KnitRepository
417
 
    _commit_builder_class = CommitBuilder
 
385
    _commit_builder_class = VersionedFileCommitBuilder
418
386
    @property
419
387
    def _serializer(self):
420
388
        return xml5.serializer_v5
448
416
    """
449
417
 
450
418
    repository_class = KnitRepository
451
 
    _commit_builder_class = RootCommitBuilder
 
419
    _commit_builder_class = VersionedFileRootCommitBuilder
452
420
    rich_root_data = True
453
421
    experimental = True
454
422
    supports_tree_reference = True
490
458
    """
491
459
 
492
460
    repository_class = KnitRepository
493
 
    _commit_builder_class = RootCommitBuilder
 
461
    _commit_builder_class = VersionedFileRootCommitBuilder
494
462
    rich_root_data = True
495
463
    supports_tree_reference = False
496
464
    @property