~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/serializer/v4.py

  • Committer: Aaron Bentley
  • Date: 2007-06-26 19:31:00 UTC
  • mto: (2520.5.2 bzr.mpbundle)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: abentley@panoramicfeedback.com-20070626193100-d6lhaut5mixlzw5r
Use a registry to look up xml serializers by format

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    pack,
27
27
    revision as _mod_revision,
28
28
    trace,
 
29
    xml_serializer,
29
30
    )
30
31
from bzrlib.bundle import bundle_data, serializer
31
32
from bzrlib.util import bencode
150
151
        bundle = BundleInfoV4(file, self)
151
152
        return bundle
152
153
 
 
154
    @staticmethod
 
155
    def get_source_serializer(info):
 
156
        return xml_serializer.format_registry.get(info['serializer'])
 
157
 
153
158
 
154
159
class BundleWriteOperation(object):
155
160
 
300
305
        return BundleReader(self._fileobj)
301
306
 
302
307
    def _get_real_revisions(self):
303
 
        from bzrlib import xml7
304
308
        if self.__real_revisions is None:
305
309
            self.__real_revisions = []
306
310
            bundle_reader = self.get_bundle_reader()
307
311
            for bytes, parents, repo_kind, revision_id, file_id in \
308
312
                bundle_reader.iter_records():
 
313
                if repo_kind == 'info':
 
314
                    serializer =\
 
315
                        self._serializer.get_source_serializer(parents)
309
316
                if repo_kind == 'revision':
310
 
                    rev = xml7.serializer_v7.read_revision_from_string(bytes)
 
317
                    rev = serializer.read_revision_from_string(bytes)
311
318
                    self.__real_revisions.append(rev)
312
319
        return self.__real_revisions
313
320
    real_revisions = property(_get_real_revisions)
338
345
 
339
346
    def handle_info(self, info):
340
347
        self._info = info
341
 
        if info['serializer'] == '5':
342
 
            from bzrlib import xml5
343
 
            self._source_serializer = xml5.serializer_v5
344
 
        else:
345
 
            from bzrlib import xml7
346
 
            self._source_serializer = xml7.serializer_v7
 
348
        self._source_serializer = self._serializer.get_source_serializer(info)
347
349
        if (info['supports_rich_root'] == 0 and
348
350
            self._repository.supports_rich_root()):
349
351
            self.update_root = True