~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Martin Pool
  • Date: 2007-10-10 00:21:57 UTC
  • mfrom: (2900 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2901.
  • Revision ID: mbp@sourcefrog.net-20071010002157-utci0x44m2w47wgd
merge news

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)
151
161
        # special case NULL_REVISION
152
162
        if revision_id == _mod_revision.NULL_REVISION:
153
163
            return {}
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([])
180
189
        else:
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
227
236
    
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)
231
239
 
232
240
    def _make_parents_provider(self):
233
241
        return _KnitParentsProvider(self._get_revision_vf())
234
242
 
235
243
 
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
244
class RepositoryFormatKnit(MetaDirRepositoryFormat):
269
245
    """Bzr repository knit format (generalized). 
270
246
 
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
 
263
    # their constructor.
 
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
285
268
 
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)
377
362
 
378
363
 
379
364
class RepositoryFormatKnit1(RepositoryFormatKnit):
393
378
    """
394
379
 
395
380
    repository_class = KnitRepository
 
381
    _commit_builder_class = CommitBuilder
 
382
    _serializer = xml5.serializer_v5
396
383
 
397
384
    def __ne__(self, other):
398
385
        return self.__class__ is not other.__class__
425
412
     - support for recording tree-references
426
413
    """
427
414
 
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
431
420
 
432
421
    def _get_matching_bzrdir(self):
433
422
        return bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')