/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Robert Collins
  • Date: 2007-10-17 09:39:41 UTC
  • mfrom: (2911 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20071017093941-v7d1djrt2617citb
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
            _revision_store, control_store, text_store)
91
91
        self._commit_builder_class = _commit_builder_class
92
92
        self._serializer = _serializer
 
93
        self._reconcile_fixes_text_parents = True
93
94
 
94
95
    def _warn_if_deprecated(self):
95
96
        # This class isn't deprecated
147
148
            raise errors.NoSuchRevision(self, revision_id)
148
149
 
149
150
    @needs_read_lock
 
151
    def get_data_stream(self, revision_ids):
 
152
        """See Repository.get_data_stream."""
 
153
        item_keys = self.item_keys_introduced_by(revision_ids)
 
154
        for knit_kind, file_id, versions in item_keys:
 
155
            name = (knit_kind,)
 
156
            if knit_kind == 'file':
 
157
                name = ('file', file_id)
 
158
                knit = self.weave_store.get_weave_or_empty(
 
159
                    file_id, self.get_transaction())
 
160
            elif knit_kind == 'inventory':
 
161
                knit = self.get_inventory_weave()
 
162
            elif knit_kind == 'revisions':
 
163
                knit = self._revision_store.get_revision_file(
 
164
                    self.get_transaction())
 
165
            elif knit_kind == 'signatures':
 
166
                knit = self._revision_store.get_signature_file(
 
167
                    self.get_transaction())
 
168
            else:
 
169
                raise AssertionError('Unknown knit kind %r' % (knit_kind,))
 
170
            yield name, _get_stream_as_bytes(knit, versions)
 
171
 
 
172
    @needs_read_lock
 
173
    def get_revision(self, revision_id):
 
174
        """Return the Revision object for a named revision"""
 
175
        revision_id = osutils.safe_revision_id(revision_id)
 
176
        return self.get_revision_reconcile(revision_id)
 
177
 
 
178
    @needs_read_lock
150
179
    def get_revision_graph(self, revision_id=None):
151
180
        """Return a dictionary containing the revision graph.
152
181
 
240
269
    def _make_parents_provider(self):
241
270
        return _KnitParentsProvider(self._get_revision_vf())
242
271
 
 
272
    def _find_inconsistent_revision_parents(self):
 
273
        """Find revisions with different parent lists in the revision object
 
274
        and in the index graph.
 
275
 
 
276
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
 
277
            parents-in-revision).
 
278
        """
 
279
        assert self.is_locked()
 
280
        vf = self._get_revision_vf()
 
281
        for index_version in vf.versions():
 
282
            parents_according_to_index = tuple(vf.get_parents_with_ghosts(
 
283
                index_version))
 
284
            revision = self.get_revision(index_version)
 
285
            parents_according_to_revision = tuple(revision.parent_ids)
 
286
            if parents_according_to_index != parents_according_to_revision:
 
287
                yield (index_version, parents_according_to_index,
 
288
                    parents_according_to_revision)
 
289
 
 
290
    def _check_for_inconsistent_revision_parents(self):
 
291
        inconsistencies = list(self._find_inconsistent_revision_parents())
 
292
        if inconsistencies:
 
293
            raise errors.BzrCheckError(
 
294
                "Revision knit has inconsistent parents.")
 
295
 
 
296
    def revision_graph_can_have_wrong_parents(self):
 
297
        # The revision.kndx could potentially claim a revision has a different
 
298
        # parent to the revision text.
 
299
        return True
 
300
 
243
301
 
244
302
class RepositoryFormatKnit(MetaDirRepositoryFormat):
245
303
    """Bzr repository knit format (generalized).