/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/per_workingtree/test_inv.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        wt.lock_tree_write()
32
32
        self.addCleanup(wt.unlock)
33
33
        self.assertEqual(len(list(wt.all_versioned_paths())), 1)
34
 
        with open('b1/a', 'wb') as f: f.write(b'a test\n')
 
34
        with open('b1/a', 'wb') as f:
 
35
            f.write(b'a test\n')
35
36
        wt.add('a')
36
37
        self.assertEqual(len(list(wt.all_versioned_paths())), 2)
37
 
        wt.flush() # workaround revert doing wt._write_inventory for now.
 
38
        wt.flush()  # workaround revert doing wt._write_inventory for now.
38
39
        os.unlink('b1/a')
39
40
        wt.revert()
40
41
        self.assertEqual(len(list(wt.all_versioned_paths())), 1)
54
55
        self.addCleanup(wt.unlock)
55
56
        root_id = wt.get_root_id()
56
57
        wt.apply_inventory_delta([(None, 'bar/foo', b'foo-id',
57
 
            inventory.InventoryFile(b'foo-id', 'foo', parent_id=b'bar-id')),
58
 
            (None, 'bar', b'bar-id', inventory.InventoryDirectory(b'bar-id',
59
 
            'bar', parent_id=root_id))])
 
58
                                   inventory.InventoryFile(b'foo-id', 'foo', parent_id=b'bar-id')),
 
59
                                  (None, 'bar', b'bar-id', inventory.InventoryDirectory(b'bar-id',
 
60
                                                                                        'bar', parent_id=root_id))])
60
61
        self.assertEqual('bar/foo', wt.id2path(b'foo-id'))
61
62
        self.assertEqual('bar', wt.id2path(b'bar-id'))
62
63
 
79
80
        wt.add(['foo', 'foo/bar'],
80
81
               [b'foo-id', b'bar-id'])
81
82
        wt.apply_inventory_delta([('foo', 'baz', b'foo-id',
82
 
            inventory.InventoryDirectory(b'foo-id', 'baz', root_id))])
 
83
                                   inventory.InventoryDirectory(b'foo-id', 'baz', root_id))])
83
84
        # foo/bar should have been followed the rename of its parent to baz/bar
84
85
        self.assertEqual('baz', wt.id2path(b'foo-id'))
85
86
        self.assertEqual('baz/bar', wt.id2path(b'bar-id'))
93
94
        wt.add(['foo', 'foo/bar', 'foo/bar/baz'],
94
95
               [b'foo-id', b'bar-id', b'baz-id'])
95
96
        wt.apply_inventory_delta([('foo', 'quux', b'foo-id',
96
 
            inventory.InventoryDirectory(b'foo-id', 'quux', root_id))])
 
97
                                   inventory.InventoryDirectory(b'foo-id', 'quux', root_id))])
97
98
        # foo/bar/baz should have been followed the rename of its parent's
98
99
        # parent to quux/bar/baz
99
100
        self.assertEqual('quux/bar/baz', wt.id2path(b'baz-id'))
106
107
        wt.add(['foo', 'foo/bar', 'baz'],
107
108
               [b'foo-id', b'bar-id', b'baz-id'])
108
109
        wt.apply_inventory_delta([('foo/bar', 'baz/bar', b'bar-id',
109
 
            inventory.InventoryFile(b'bar-id', 'bar', b'baz-id'))])
 
110
                                   inventory.InventoryFile(b'bar-id', 'bar', b'baz-id'))])
110
111
        self.assertEqual('baz/bar', wt.id2path(b'bar-id'))
111
112
 
112
113
    def test_rename_swap(self):
123
124
        wt.add(['foo', 'foo/bar', 'baz', 'baz/qux'],
124
125
               [b'foo-id', b'bar-id', b'baz-id', b'qux-id'])
125
126
        wt.apply_inventory_delta([('foo', 'baz', b'foo-id',
126
 
            inventory.InventoryDirectory(b'foo-id', 'baz', root_id)),
127
 
            ('baz', 'foo', b'baz-id',
128
 
            inventory.InventoryDirectory(b'baz-id', 'foo', root_id))])
 
127
                                   inventory.InventoryDirectory(b'foo-id', 'baz', root_id)),
 
128
                                  ('baz', 'foo', b'baz-id',
 
129
                                   inventory.InventoryDirectory(b'baz-id', 'foo', root_id))])
129
130
        self.assertEqual('baz/bar', wt.id2path(b'bar-id'))
130
131
        self.assertEqual('foo/qux', wt.id2path(b'qux-id'))
131
132
 
143
144
        # this delta moves dir-id to dir2 and reparents
144
145
        # child-id to a parent of other-id
145
146
        wt.apply_inventory_delta([('dir', 'dir2', b'dir-id',
146
 
            inventory.InventoryDirectory(b'dir-id', 'dir2', root_id)),
147
 
            ('dir/child', 'other/child', b'child-id',
148
 
             inventory.InventoryFile(b'child-id', 'child', b'other-id'))])
 
147
                                   inventory.InventoryDirectory(b'dir-id', 'dir2', root_id)),
 
148
                                  ('dir/child', 'other/child', b'child-id',
 
149
                                   inventory.InventoryFile(b'child-id', 'child', b'other-id'))])
149
150
        self.assertEqual('dir2', wt.id2path(b'dir-id'))
150
151
        self.assertEqual('other/child', wt.id2path(b'child-id'))
151
152
 
156
157
 
157
158
        root_id = wt.get_root_id()
158
159
        wt.apply_inventory_delta([('', None, root_id, None),
159
 
            (None, '', b'root-id',
160
 
             inventory.InventoryDirectory(b'root-id', '', None))])
 
160
                                  (None, '', b'root-id',
 
161
                                   inventory.InventoryDirectory(b'root-id', '', None))])
161
162
 
162
163
 
163
164
class TestTreeReference(TestCaseWithWorkingTree):