76
77
class KnitRepository(MetaDirRepository):
77
78
"""Knit format repository."""
79
_serializer = xml5.serializer_v5
80
# These attributes are inherited from the Repository base class. Setting
81
# them to None ensures that if the constructor is changed to not initialize
82
# them, or a subclass fails to call the constructor, that an error will
83
# occur rather than the system working but generating incorrect data.
84
_commit_builder_class = None
87
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
88
control_store, text_store, _commit_builder_class, _serializer):
89
MetaDirRepository.__init__(self, _format, a_bzrdir, control_files,
90
_revision_store, control_store, text_store)
91
self._commit_builder_class = _commit_builder_class
92
self._serializer = _serializer
81
94
def _warn_if_deprecated(self):
82
95
# This class isn't deprecated
228
241
return _KnitParentsProvider(self._get_revision_vf())
231
class KnitRepository3(KnitRepository):
233
# knit3 repositories need a RootCommitBuilder
234
_commit_builder_class = RootCommitBuilder
236
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
237
control_store, text_store):
238
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
239
_revision_store, control_store, text_store)
240
self._serializer = xml7.serializer_v7
242
def deserialise_inventory(self, revision_id, xml):
243
"""Transform the xml into an inventory object.
245
:param revision_id: The expected revision id of the inventory.
246
:param xml: A serialised inventory.
248
result = self._serializer.read_inventory_from_string(xml)
249
assert result.root.revision is not None
252
def serialise_inventory(self, inv):
253
"""Transform the inventory object into XML text.
255
:param revision_id: The expected revision id of the inventory.
256
:param xml: A serialised inventory.
258
assert inv.revision_id is not None
259
assert inv.root.revision is not None
260
return KnitRepository.serialise_inventory(self, inv)
263
244
class RepositoryFormatKnit(MetaDirRepositoryFormat):
264
245
"""Bzr repository knit format (generalized).
277
258
# Set this attribute in derived classes to control the repository class
278
259
# created by open and initialize.
279
260
repository_class = None
261
# Set this attribute in derived classes to control the
262
# _commit_builder_class that the repository objects will have passed to
264
_commit_builder_class = None
265
# Set this attribute in derived clases to control the _serializer that the
266
# repository objects will have passed to their constructor.
267
_serializer = xml5.serializer_v5
281
269
def _get_control_store(self, repo_transport, control_files):
282
270
"""Return the control store for this repository."""
368
356
control_files=control_files,
369
357
_revision_store=_revision_store,
370
358
control_store=control_store,
371
text_store=text_store)
359
text_store=text_store,
360
_commit_builder_class=self._commit_builder_class,
361
_serializer=self._serializer)
374
364
class RepositoryFormatKnit1(RepositoryFormatKnit):
420
412
- support for recording tree-references
423
repository_class = KnitRepository3
415
repository_class = KnitRepository
416
_commit_builder_class = RootCommitBuilder
424
417
rich_root_data = True
425
418
supports_tree_reference = True
419
_serializer = xml7.serializer_v7
427
421
def _get_matching_bzrdir(self):
428
422
return bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')