/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Andrew Bennetts
  • Date: 2007-10-12 05:26:46 UTC
  • mfrom: (2904 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2906.
  • Revision ID: andrew.bennetts@canonical.com-20071012052646-wl95idld3ijjy714
Merge from bzr.dev.

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
    # 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
 
85
    _serializer = None
 
86
 
 
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
80
93
 
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.
101
114
        """
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))
129
140
        """
130
141
        if _mod_revision.is_null(revision_id):
131
142
            return [None]
132
 
        revision_id = osutils.safe_revision_id(revision_id)
133
143
        vf = self._get_revision_vf()
134
144
        try:
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:
181
191
            return {}
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([])
208
217
        else:
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
255
264
    
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)
259
267
 
260
268
    def _make_parents_provider(self):
261
269
        return _KnitParentsProvider(self._get_revision_vf())
262
270
 
263
271
 
264
 
class KnitRepository3(KnitRepository):
265
 
 
266
 
    # knit3 repositories need a RootCommitBuilder
267
 
    _commit_builder_class = RootCommitBuilder
268
 
 
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
274
 
 
275
 
    def deserialise_inventory(self, revision_id, xml):
276
 
        """Transform the xml into an inventory object. 
277
 
 
278
 
        :param revision_id: The expected revision id of the inventory.
279
 
        :param xml: A serialised inventory.
280
 
        """
281
 
        result = self._serializer.read_inventory_from_string(xml)
282
 
        assert result.root.revision is not None
283
 
        return result
284
 
 
285
 
    def serialise_inventory(self, inv):
286
 
        """Transform the inventory object into XML text.
287
 
 
288
 
        :param revision_id: The expected revision id of the inventory.
289
 
        :param xml: A serialised inventory.
290
 
        """
291
 
        assert inv.revision_id is not None
292
 
        assert inv.root.revision is not None
293
 
        return KnitRepository.serialise_inventory(self, inv)
294
 
 
295
 
 
296
272
class RepositoryFormatKnit(MetaDirRepositoryFormat):
297
273
    """Bzr repository knit format (generalized). 
298
274
 
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
 
291
    # their constructor.
 
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
313
296
 
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)
405
390
 
406
391
 
407
392
class RepositoryFormatKnit1(RepositoryFormatKnit):
421
406
    """
422
407
 
423
408
    repository_class = KnitRepository
 
409
    _commit_builder_class = CommitBuilder
 
410
    _serializer = xml5.serializer_v5
424
411
 
425
412
    def __ne__(self, other):
426
413
        return self.__class__ is not other.__class__
453
440
     - support for recording tree-references
454
441
    """
455
442
 
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
459
448
 
460
449
    def _get_matching_bzrdir(self):
461
450
        return bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')