76
77
class KnitRepository(MetaDirRepository):
77
78
"""Knit format repository."""
79
_serializer = xml5.serializer_v5
80
# make an manually, or incorrectly initialised KnitRepository object
82
_commit_builder_class = None
85
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
86
control_store, text_store, _commit_builder_class, _serializer):
87
MetaDirRepository.__init__(self, _format, a_bzrdir, control_files,
88
_revision_store, control_store, text_store)
89
self._commit_builder_class = _commit_builder_class
90
self._serializer = _serializer
81
92
def _warn_if_deprecated(self):
82
93
# This class isn't deprecated
233
244
return _KnitParentsProvider(self._get_revision_vf())
236
class KnitRepository3(KnitRepository):
238
# knit3 repositories need a RootCommitBuilder
239
_commit_builder_class = RootCommitBuilder
241
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
242
control_store, text_store):
243
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
244
_revision_store, control_store, text_store)
245
self._serializer = xml7.serializer_v7
247
def deserialise_inventory(self, revision_id, xml):
248
"""Transform the xml into an inventory object.
250
:param revision_id: The expected revision id of the inventory.
251
:param xml: A serialised inventory.
253
result = self._serializer.read_inventory_from_string(xml)
254
assert result.root.revision is not None
257
def serialise_inventory(self, inv):
258
"""Transform the inventory object into XML text.
260
:param revision_id: The expected revision id of the inventory.
261
:param xml: A serialised inventory.
263
assert inv.revision_id is not None
264
assert inv.root.revision is not None
265
return KnitRepository.serialise_inventory(self, inv)
268
247
class RepositoryFormatKnit(MetaDirRepositoryFormat):
269
248
"""Bzr repository knit format (generalized).
282
261
# Set this attribute in derived classes to control the repository class
283
262
# created by open and initialize.
284
263
repository_class = None
264
# Set this attribute in derived classes to control the
265
# _commit_builder_class that the repository objects will have passed to
267
_commit_builder_class = None
268
# Set this attribute in derived clases to control the _serializer that the
269
# repository objects will have passed to their constructor.
286
272
def _get_control_store(self, repo_transport, control_files):
287
273
"""Return the control store for this repository."""
373
359
control_files=control_files,
374
360
_revision_store=_revision_store,
375
361
control_store=control_store,
376
text_store=text_store)
362
text_store=text_store,
363
_commit_builder_class=self._commit_builder_class,
364
_serializer=self._serializer)
379
367
class RepositoryFormatKnit1(RepositoryFormatKnit):
425
415
- support for recording tree-references
428
repository_class = KnitRepository3
418
repository_class = KnitRepository
419
_commit_builder_class = RootCommitBuilder
429
420
rich_root_data = True
430
421
supports_tree_reference = True
422
_serializer = xml7.serializer_v7
432
424
def _get_matching_bzrdir(self):
433
425
return bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')