~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Robert Collins
  • Date: 2007-10-05 03:14:29 UTC
  • mfrom: (2889.1.1 knit-repo)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20071005031429-8zab3gybvpicu52l
Merge KnitRepository3 removal branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
from bzrlib.decorators import needs_read_lock, needs_write_lock
39
39
from bzrlib.repository import (
 
40
    CommitBuilder,
40
41
    MetaDirRepository,
41
42
    MetaDirRepositoryFormat,
42
43
    RepositoryFormat,
76
77
class KnitRepository(MetaDirRepository):
77
78
    """Knit format repository."""
78
79
 
79
 
    _serializer = xml5.serializer_v5
 
80
    # make an manually, or incorrectly initialised KnitRepository object
 
81
    # invalid
 
82
    _commit_builder_class = None
 
83
    _serializer = None
 
84
 
 
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
80
91
 
81
92
    def _warn_if_deprecated(self):
82
93
        # This class isn't deprecated
233
244
        return _KnitParentsProvider(self._get_revision_vf())
234
245
 
235
246
 
236
 
class KnitRepository3(KnitRepository):
237
 
 
238
 
    # knit3 repositories need a RootCommitBuilder
239
 
    _commit_builder_class = RootCommitBuilder
240
 
 
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
246
 
 
247
 
    def deserialise_inventory(self, revision_id, xml):
248
 
        """Transform the xml into an inventory object. 
249
 
 
250
 
        :param revision_id: The expected revision id of the inventory.
251
 
        :param xml: A serialised inventory.
252
 
        """
253
 
        result = self._serializer.read_inventory_from_string(xml)
254
 
        assert result.root.revision is not None
255
 
        return result
256
 
 
257
 
    def serialise_inventory(self, inv):
258
 
        """Transform the inventory object into XML text.
259
 
 
260
 
        :param revision_id: The expected revision id of the inventory.
261
 
        :param xml: A serialised inventory.
262
 
        """
263
 
        assert inv.revision_id is not None
264
 
        assert inv.root.revision is not None
265
 
        return KnitRepository.serialise_inventory(self, inv)
266
 
 
267
 
 
268
247
class RepositoryFormatKnit(MetaDirRepositoryFormat):
269
248
    """Bzr repository knit format (generalized). 
270
249
 
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
 
266
    # their constructor.
 
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.
 
270
    _serializer = None
285
271
 
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)
377
365
 
378
366
 
379
367
class RepositoryFormatKnit1(RepositoryFormatKnit):
393
381
    """
394
382
 
395
383
    repository_class = KnitRepository
 
384
    _commit_builder_class = CommitBuilder
 
385
    _serializer = xml5.serializer_v5
396
386
 
397
387
    def __ne__(self, other):
398
388
        return self.__class__ is not other.__class__
425
415
     - support for recording tree-references
426
416
    """
427
417
 
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
431
423
 
432
424
    def _get_matching_bzrdir(self):
433
425
        return bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')