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)
151
161
# special case NULL_REVISION
152
162
if revision_id == _mod_revision.NULL_REVISION:
154
revision_id = osutils.safe_revision_id(revision_id)
155
164
a_weave = self._get_revision_vf()
156
165
if revision_id is None:
157
166
return a_weave.get_graph()
178
187
pending = set(self.all_revision_ids())
179
188
required = set([])
181
pending = set(osutils.safe_revision_id(r) for r in revision_ids)
190
pending = set(revision_ids)
182
191
# special case NULL_REVISION
183
192
if _mod_revision.NULL_REVISION in pending:
184
193
pending.remove(_mod_revision.NULL_REVISION)
226
235
return reconciler
228
237
def revision_parents(self, revision_id):
229
revision_id = osutils.safe_revision_id(revision_id)
230
238
return self._get_revision_vf().get_parents(revision_id)
232
240
def _make_parents_provider(self):
233
241
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
244
class RepositoryFormatKnit(MetaDirRepositoryFormat):
269
245
"""Bzr repository knit format (generalized).
282
258
# Set this attribute in derived classes to control the repository class
283
259
# created by open and initialize.
284
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
286
269
def _get_control_store(self, repo_transport, control_files):
287
270
"""Return the control store for this repository."""
373
356
control_files=control_files,
374
357
_revision_store=_revision_store,
375
358
control_store=control_store,
376
text_store=text_store)
359
text_store=text_store,
360
_commit_builder_class=self._commit_builder_class,
361
_serializer=self._serializer)
379
364
class RepositoryFormatKnit1(RepositoryFormatKnit):
425
412
- support for recording tree-references
428
repository_class = KnitRepository3
415
repository_class = KnitRepository
416
_commit_builder_class = RootCommitBuilder
429
417
rich_root_data = True
430
418
supports_tree_reference = True
419
_serializer = xml7.serializer_v7
432
421
def _get_matching_bzrdir(self):
433
422
return bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')