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

  • Committer: Jelmer Vernooij
  • Date: 2018-08-21 07:56:36 UTC
  • mfrom: (7078 work)
  • mto: This revision was merged to the branch mainline in revision 7093.
  • Revision ID: jelmer@jelmer.uk-20180821075636-ranyu9myp6er1d8z
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
    def make_entry(self, file_id, path):
125
125
        from ..bzr.inventory import (InventoryFile, InventoryDirectory,
126
126
            InventoryLink)
 
127
        if not isinstance(file_id, bytes):
 
128
            raise TypeError(file_id)
127
129
        name = os.path.basename(path)
128
130
        kind = self.kind(path, file_id)
129
131
        parent_id = self.parent_id(file_id)
141
143
        return ie
142
144
 
143
145
    def add_dir(self, file_id, path):
 
146
        if not isinstance(file_id, bytes):
 
147
            raise TypeError(file_id)
144
148
        self.paths[file_id] = path
145
149
        self.ids[path] = file_id
146
150
 
147
151
    def add_file(self, file_id, path, contents):
 
152
        if not isinstance(file_id, bytes):
 
153
            raise TypeError(file_id)
148
154
        self.add_dir(file_id, path)
149
155
        self.contents[file_id] = contents
150
156
 
316
322
 
317
323
    def make_tree_3(self):
318
324
        btree, mtree = self.make_tree_1()
319
 
        mtree.add_file("e", "grandparent/parent/topping", "Anchovies\n")
 
325
        mtree.add_file(b"e", "grandparent/parent/topping", b"Anchovies\n")
320
326
        btree.note_rename("grandparent/parent/file",
321
327
                          "grandparent/alt_parent/file")
322
328
        btree.note_rename("grandparent/parent/topping",
480
486
        :return: The in-memory bundle
481
487
        """
482
488
        bundle_txt, rev_ids = self.create_bundle_text(base_rev_id, rev_id)
483
 
        new_text = bundle_txt.getvalue().replace('executable:no',
484
 
                                               'executable:yes')
 
489
        new_text = bundle_txt.getvalue().replace(b'executable:no',
 
490
                                                 b'executable:yes')
485
491
        bundle_txt = BytesIO(new_text)
486
492
        bundle = read_bundle(bundle_txt)
487
493
        self.valid_apply_bundle(base_rev_id, bundle)
1778
1784
        writer = v4.BundleWriter(fileobj)
1779
1785
        writer.begin()
1780
1786
        writer.add_info_record({b'foo': b'bar'})
1781
 
        writer._add_record("Record body", {b'parents': [b'1', b'3'],
 
1787
        writer._add_record(b"Record body", {b'parents': [b'1', b'3'],
1782
1788
            b'storage_kind': b'fulltext'}, 'file', b'revid', b'fileid')
1783
1789
        writer.end()
1784
1790
        fileobj.seek(0)
1788
1794
        self.assertEqual((None, {b'foo': b'bar', b'storage_kind': b'header'},
1789
1795
            'info', None, None), record)
1790
1796
        record = next(record_iter)
1791
 
        self.assertEqual(("Record body", {b'storage_kind': b'fulltext',
 
1797
        self.assertEqual((b"Record body", {b'storage_kind': b'fulltext',
1792
1798
                          b'parents': [b'1', b'3']}, 'file', b'revid', b'fileid'),
1793
1799
                          record)
1794
1800
 
1797
1803
        writer = v4.BundleWriter(fileobj)
1798
1804
        writer.begin()
1799
1805
        writer.add_info_record({b'foo': b'bar'})
1800
 
        writer._add_record("Record body", {b'parents': [b'1', b'3'],
 
1806
        writer._add_record(b"Record body", {b'parents': [b'1', b'3'],
1801
1807
            b'storage_kind': b'fulltext'}, 'file', b'revid', b'fileid')
1802
1808
        writer.end()
1803
1809
        fileobj.seek(0)
1807
1813
        self.assertEqual((None, {b'foo': b'bar', b'storage_kind': b'header'},
1808
1814
            'info', None, None), record)
1809
1815
        record = next(record_iter)
1810
 
        self.assertEqual(("Record body", {b'storage_kind': b'fulltext',
 
1816
        self.assertEqual((b"Record body", {b'storage_kind': b'fulltext',
1811
1817
                          b'parents': [b'1', b'3']}, 'file', b'revid', b'fileid'),
1812
1818
                          record)
1813
1819
 
1832
1838
        writer = v4.BundleWriter(fileobj)
1833
1839
        writer.begin()
1834
1840
        writer.add_info_record({b'foo': b'bar'})
1835
 
        writer._container.add_bytes_record(b'blah', [b'two', b'names'])
 
1841
        writer._container.add_bytes_record(b'blah', [(b'two', ), (b'names', )])
1836
1842
        writer.end()
1837
1843
        fileobj.seek(0)
1838
1844
        record_iter = v4.BundleReader(fileobj).iter_records()