~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: Aaron Bentley
  • Date: 2007-06-21 19:10:28 UTC
  • mto: (2520.5.2 bzr.mpbundle)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: abentley@panoramicfeedback.com-20070621191028-9yy1ye6jneejm1ht
Rename format to 4alpha

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from bzrlib.bzrdir import BzrDir
31
31
from bzrlib.bundle.apply_bundle import install_bundle, merge_bundle
32
32
from bzrlib.bundle.bundle_data import BundleTree
33
 
from bzrlib.bundle.serializer import write_bundle, read_bundle, v10
 
33
from bzrlib.bundle.serializer import write_bundle, read_bundle, v4
34
34
from bzrlib.bundle.serializer.v08 import BundleSerializerV08
35
35
from bzrlib.bundle.serializer.v09 import BundleSerializerV09
36
 
from bzrlib.bundle.serializer.v10 import BundleSerializerV10
 
36
from bzrlib.bundle.serializer.v4 import BundleSerializerV4
37
37
from bzrlib.branch import Branch
38
38
from bzrlib.diff import internal_diff
39
39
from bzrlib.errors import (BzrError, TestamentMismatch, NotABundle, BadBundle, 
1092
1092
        self.assertEqual({'branch-nick':'tree', 'omega':u'\u03a9',
1093
1093
                          'alpha':u'\u03b1'}, rev.properties)
1094
1094
 
1095
 
    def test_has_diff(self):
1096
 
        tree = self.make_branch_and_tree('tree')
1097
 
        self.build_tree_contents([('tree/file', 'File content 1')])
1098
 
        tree.add('file')
1099
 
        tree.commit('added file', rev_id='rev1')
1100
 
        s = StringIO()
1101
 
        serializer = BundleSerializerV10('1.0')
1102
 
        serializer.write(tree.branch.repository, ['rev1'], {}, s)
1103
 
        self.assertContainsRe(s.getvalue(), '\+File content 1')
1104
 
 
1105
1095
 
1106
1096
class V09BundleKnit2Tester(V08BundleTester):
1107
1097
 
1123
1113
        return format
1124
1114
 
1125
1115
 
1126
 
class V10BundleTester(BundleTester, TestCaseWithTransport):
 
1116
class V4BundleTester(BundleTester, TestCaseWithTransport):
1127
1117
 
1128
 
    format = '1.0alpha'
 
1118
    format = '4alpha'
1129
1119
 
1130
1120
    def get_valid_bundle(self, base_rev_id, rev_id, checkout_dir=None):
1131
1121
        """Create a bundle from base_rev_id -> rev_id in built-in branch.
1172
1162
                                    '<file executable="y" file_id="exe-1"')
1173
1163
        new_text = new_text.replace('B407', 'B422')
1174
1164
        bundle_txt = StringIO()
1175
 
        bundle_txt.write(serializer._get_bundle_header('1.0alpha'))
 
1165
        bundle_txt.write(serializer._get_bundle_header('4alpha'))
1176
1166
        bundle_txt.write('\n')
1177
1167
        bundle_txt.write(new_text.encode('bz2').encode('base-64'))
1178
1168
        bundle_txt.seek(0)
1203
1193
        self.build_tree_contents([('tree/file', 'contents2\nstatic\n')])
1204
1194
        tree.commit('changed file', rev_id='rev2')
1205
1195
        s = StringIO()
1206
 
        serializer = BundleSerializerV10('1.0')
 
1196
        serializer = BundleSerializerV4('1.0')
1207
1197
        serializer.write(tree.branch.repository, ['rev1', 'rev2'], {}, s)
1208
1198
        s.seek(0)
1209
1199
        tree2 = self.make_branch_and_tree('target')
1221
1211
 
1222
1212
    def test_name_encode(self):
1223
1213
        self.assertEqual('revision/rev1',
1224
 
            v10.BundleWriter.encode_name('revision', 'rev1'))
 
1214
            v4.BundleWriter.encode_name('revision', 'rev1'))
1225
1215
        self.assertEqual('file/rev1/file-id-1',
1226
 
            v10.BundleWriter.encode_name('file', 'rev1', 'file-id-1'))
 
1216
            v4.BundleWriter.encode_name('file', 'rev1', 'file-id-1'))
1227
1217
 
1228
1218
    def test_name_decode(self):
1229
1219
        self.assertEqual(('revision', 'rev1', None),
1230
 
            v10.BundleReader.decode_name('revision/rev1'))
 
1220
            v4.BundleReader.decode_name('revision/rev1'))
1231
1221
        self.assertEqual(('file', 'rev1', 'file-id-1'),
1232
 
            v10.BundleReader.decode_name('file/rev1/file-id-1'))
 
1222
            v4.BundleReader.decode_name('file/rev1/file-id-1'))
1233
1223
 
1234
1224
    @staticmethod
1235
1225
    def get_raw(bundle_file):
1265
1255
        tree_b = self.make_branch_and_tree('tree_b')
1266
1256
        repo_b = tree_b.branch.repository
1267
1257
        s = StringIO()
1268
 
        serializer = BundleSerializerV10('1.0')
 
1258
        serializer = BundleSerializerV4('4alpha')
1269
1259
        serializer.write(tree_a.branch.repository, ['A', 'B'], {}, s)
1270
1260
        s.seek(0)
1271
1261
        install_bundle(repo_b, serializer.read(s))
1363
1353
 
1364
1354
    def test_roundtrip_record(self):
1365
1355
        fileobj = StringIO()
1366
 
        writer = v10.BundleWriter(fileobj)
 
1356
        writer = v4.BundleWriter(fileobj)
1367
1357
        writer.begin()
1368
 
        writer.write_patch("Hi there!\n")
1369
1358
        writer._add_record("Record body", {'parents': ['1', '3']},
1370
1359
                           'file', 'revid', 'fileid')
1371
1360
        writer.end()
1372
1361
        fileobj.seek(0)
1373
 
        reader = v10.BundleReader(fileobj)
 
1362
        reader = v4.BundleReader(fileobj)
1374
1363
        record = reader.iter_records().next()
1375
1364
        self.assertEqual(("Record body", {'parents': ['1', '3']}, 'file',
1376
1365
                          'revid', 'fileid'), record)