~ubuntu-branches/ubuntu/karmic/bzr/karmic-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2008-05-12 00:14:54 UTC
  • mfrom: (1.1.42 upstream)
  • Revision ID: james.westby@ubuntu.com-20080512001454-yjpajuiocykl48p9
Tags: 1.5~rc1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
    @staticmethod
108
108
    def encode_name(content_kind, revision_id, file_id=None):
109
109
        """Encode semantic ids as a container name"""
110
 
        assert content_kind in ('revision', 'file', 'inventory', 'signature',
111
 
                                'info')
112
 
 
 
110
        if content_kind not in ('revision', 'file', 'inventory', 'signature',
 
111
                'info'):
 
112
            raise ValueError(content_kind)
113
113
        if content_kind == 'file':
114
 
            assert file_id is not None
 
114
            if file_id is None:
 
115
                raise AssertionError()
115
116
        else:
116
 
            assert file_id is None
 
117
            if file_id is not None:
 
118
                raise AssertionError()
117
119
        if content_kind == 'info':
118
 
            assert revision_id is None
119
 
        else:
120
 
            assert revision_id is not None
 
120
            if revision_id is not None:
 
121
                raise AssertionError()
 
122
        elif revision_id is None:
 
123
            raise AssertionError()
121
124
        names = [n.replace('/', '//') for n in
122
125
                 (content_kind, revision_id, file_id) if n is not None]
123
126
        return '/'.join(names)
494
497
        for bytes, metadata, repo_kind, revision_id, file_id in\
495
498
            self._container.iter_records():
496
499
            if repo_kind == 'info':
497
 
                assert self._info is None
 
500
                if self._info is not None:
 
501
                    raise AssertionError()
498
502
                self._handle_info(metadata)
499
503
            if (repo_kind, file_id) != ('file', current_file):
500
504
                if len(pending_file_records) > 0:
588
592
    def _install_revision(self, revision_id, metadata, text):
589
593
        if self._repository.has_revision(revision_id):
590
594
            return
591
 
        self._repository._add_revision_text(revision_id, text)
 
595
        if self._info['serializer'] == self._repository._serializer.format_num:
 
596
            self._repository._add_revision_text(revision_id, text)
 
597
        else:
 
598
            revision = self._source_serializer.read_revision_from_string(text)
 
599
            self._repository.add_revision(revision.revision_id, revision)
592
600
 
593
601
    def _install_signature(self, revision_id, metadata, text):
594
602
        transaction = self._repository.get_transaction()