/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/tests/test_bundle.py

  • Committer: John Arbash Meinel
  • Date: 2007-04-25 16:56:25 UTC
  • mto: This revision was merged to the branch mainline in revision 2466.
  • Revision ID: john@arbash-meinel.com-20070425165625-d2act28kmjn5avel
Change the default serializer to include a trailing whitespace for empty properties.
This means that new bundles can be read by old versions of bzr
(though they cannot read their own).
On the flip side, the new bzr can read old outputs correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
917
917
        self.assertContainsRe(bundle_sio.getvalue(),
918
918
                              '# properties:\n'
919
919
                              '#   branch-nick: tree\n'
920
 
                              '#   empty:\n'
 
920
                              '#   empty: \n'
921
921
                              '#   one: two\n'
922
922
                             )
923
923
        bundle = read_bundle(bundle_sio)
928
928
                         rev.properties)
929
929
 
930
930
    def test_bundle_empty_property_alt(self):
931
 
        """Test serializing revision properties with an empty value."""
 
931
        """Test serializing revision properties with an empty value.
 
932
 
 
933
        Older readers had a bug when reading an empty property.
 
934
        They assumed that all keys ended in ': \n'. However they would write an
 
935
        empty value as ':\n'. This tests make sure that all newer bzr versions
 
936
        can handle th second form.
 
937
        """
932
938
        tree = self.make_branch_and_memory_tree('tree')
933
939
        tree.lock_write()
934
940
        self.addCleanup(tree.unlock)
937
943
        self.b1 = tree.branch
938
944
        bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
939
945
        txt = bundle_sio.getvalue()
940
 
        loc = txt.find('#   empty:') + len('#   empty:')
941
 
        # Create a new bundle, which just has a trailing space after empty
942
 
        bundle_sio = StringIO(txt[:loc] + ' ' + txt[loc:])
 
946
        loc = txt.find('#   empty: ') + len('#   empty:')
 
947
        # Create a new bundle, which strips the trailing space after empty
 
948
        bundle_sio = StringIO(txt[:loc] + txt[loc+1:])
943
949
 
944
950
        self.assertContainsRe(bundle_sio.getvalue(),
945
951
                              '# properties:\n'
946
952
                              '#   branch-nick: tree\n'
947
 
                              '#   empty: \n'
 
953
                              '#   empty:\n'
948
954
                              '#   one: two\n'
949
955
                             )
950
956
        bundle = read_bundle(bundle_sio)