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
99
112
This determines the set of revisions which are involved, and then
100
113
finds all file ids affected by those revisions.
102
from_revid = osutils.safe_revision_id(from_revid)
103
to_revid = osutils.safe_revision_id(to_revid)
104
115
vf = self._get_revision_vf()
105
116
from_set = set(vf.get_ancestry(from_revid))
106
117
to_set = set(vf.get_ancestry(to_revid))
130
141
if _mod_revision.is_null(revision_id):
132
revision_id = osutils.safe_revision_id(revision_id)
133
143
vf = self._get_revision_vf()
135
145
return [None] + vf.get_ancestry(revision_id, topo_sorted)
179
189
# special case NULL_REVISION
180
190
if revision_id == _mod_revision.NULL_REVISION:
182
revision_id = osutils.safe_revision_id(revision_id)
183
192
a_weave = self._get_revision_vf()
184
193
if revision_id is None:
185
194
return a_weave.get_graph()
206
215
pending = set(self.all_revision_ids())
207
216
required = set([])
209
pending = set(osutils.safe_revision_id(r) for r in revision_ids)
218
pending = set(revision_ids)
210
219
# special case NULL_REVISION
211
220
if _mod_revision.NULL_REVISION in pending:
212
221
pending.remove(_mod_revision.NULL_REVISION)
254
263
return reconciler
256
265
def revision_parents(self, revision_id):
257
revision_id = osutils.safe_revision_id(revision_id)
258
266
return self._get_revision_vf().get_parents(revision_id)
260
268
def _make_parents_provider(self):
261
269
return _KnitParentsProvider(self._get_revision_vf())
264
class KnitRepository3(KnitRepository):
266
# knit3 repositories need a RootCommitBuilder
267
_commit_builder_class = RootCommitBuilder
269
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
270
control_store, text_store):
271
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
272
_revision_store, control_store, text_store)
273
self._serializer = xml7.serializer_v7
275
def deserialise_inventory(self, revision_id, xml):
276
"""Transform the xml into an inventory object.
278
:param revision_id: The expected revision id of the inventory.
279
:param xml: A serialised inventory.
281
result = self._serializer.read_inventory_from_string(xml)
282
assert result.root.revision is not None
285
def serialise_inventory(self, inv):
286
"""Transform the inventory object into XML text.
288
:param revision_id: The expected revision id of the inventory.
289
:param xml: A serialised inventory.
291
assert inv.revision_id is not None
292
assert inv.root.revision is not None
293
return KnitRepository.serialise_inventory(self, inv)
296
272
class RepositoryFormatKnit(MetaDirRepositoryFormat):
297
273
"""Bzr repository knit format (generalized).
310
286
# Set this attribute in derived classes to control the repository class
311
287
# created by open and initialize.
312
288
repository_class = None
289
# Set this attribute in derived classes to control the
290
# _commit_builder_class that the repository objects will have passed to
292
_commit_builder_class = None
293
# Set this attribute in derived clases to control the _serializer that the
294
# repository objects will have passed to their constructor.
295
_serializer = xml5.serializer_v5
314
297
def _get_control_store(self, repo_transport, control_files):
315
298
"""Return the control store for this repository."""
401
384
control_files=control_files,
402
385
_revision_store=_revision_store,
403
386
control_store=control_store,
404
text_store=text_store)
387
text_store=text_store,
388
_commit_builder_class=self._commit_builder_class,
389
_serializer=self._serializer)
407
392
class RepositoryFormatKnit1(RepositoryFormatKnit):
453
440
- support for recording tree-references
456
repository_class = KnitRepository3
443
repository_class = KnitRepository
444
_commit_builder_class = RootCommitBuilder
457
445
rich_root_data = True
458
446
supports_tree_reference = True
447
_serializer = xml7.serializer_v7
460
449
def _get_matching_bzrdir(self):
461
450
return bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')