/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-03-25 11:54:30 UTC
  • mfrom: (6855.4.10 more-bees)
  • Revision ID: breezy.the.bot@gmail.com-20180325115430-75xnlbrmzjoomd83
Add more bees. In particular:

* for file ids
* for revision ids
* for file contents in build_tree_contents()

Merged from https://code.launchpad.net/~jelmer/brz/more-bees/+merge/337919

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        wt.lock_write()
54
54
        self.addCleanup(wt.unlock)
55
55
        root_id = wt.get_root_id()
56
 
        wt.apply_inventory_delta([(None, 'bar/foo', 'foo-id',
57
 
            inventory.InventoryFile('foo-id', 'foo', parent_id='bar-id')),
58
 
            (None, 'bar', 'bar-id', inventory.InventoryDirectory('bar-id',
 
56
        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
59
            'bar', parent_id=root_id))])
60
 
        self.assertEqual('bar/foo', wt.id2path('foo-id'))
61
 
        self.assertEqual('bar', wt.id2path('bar-id'))
 
60
        self.assertEqual('bar/foo', wt.id2path(b'foo-id'))
 
61
        self.assertEqual('bar', wt.id2path(b'bar-id'))
62
62
 
63
63
    def test_remove(self):
64
64
        wt = self.make_branch_and_tree('.')
65
65
        wt.lock_write()
66
66
        self.addCleanup(wt.unlock)
67
67
        self.build_tree(['foo/', 'foo/bar'])
68
 
        wt.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])
69
 
        wt.apply_inventory_delta([('foo', None, 'foo-id', None),
70
 
                                  ('foo/bar', None, 'bar-id', None)])
 
68
        wt.add(['foo', 'foo/bar'], [b'foo-id', b'bar-id'])
 
69
        wt.apply_inventory_delta([('foo', None, b'foo-id', None),
 
70
                                  ('foo/bar', None, b'bar-id', None)])
71
71
        self.assertFalse(wt.is_versioned('foo'))
72
72
 
73
73
    def test_rename_dir_with_children(self):
77
77
        self.addCleanup(wt.unlock)
78
78
        self.build_tree(['foo/', 'foo/bar'])
79
79
        wt.add(['foo', 'foo/bar'],
80
 
               ['foo-id', 'bar-id'])
81
 
        wt.apply_inventory_delta([('foo', 'baz', 'foo-id',
82
 
            inventory.InventoryDirectory('foo-id', 'baz', root_id))])
 
80
               [b'foo-id', b'bar-id'])
 
81
        wt.apply_inventory_delta([('foo', 'baz', b'foo-id',
 
82
            inventory.InventoryDirectory(b'foo-id', 'baz', root_id))])
83
83
        # foo/bar should have been followed the rename of its parent to baz/bar
84
 
        self.assertEqual('baz', wt.id2path('foo-id'))
85
 
        self.assertEqual('baz/bar', wt.id2path('bar-id'))
 
84
        self.assertEqual('baz', wt.id2path(b'foo-id'))
 
85
        self.assertEqual('baz/bar', wt.id2path(b'bar-id'))
86
86
 
87
87
    def test_rename_dir_with_children_with_children(self):
88
88
        wt = self.make_branch_and_tree('.')
91
91
        self.addCleanup(wt.unlock)
92
92
        self.build_tree(['foo/', 'foo/bar/', 'foo/bar/baz'])
93
93
        wt.add(['foo', 'foo/bar', 'foo/bar/baz'],
94
 
               ['foo-id', 'bar-id', 'baz-id'])
95
 
        wt.apply_inventory_delta([('foo', 'quux', 'foo-id',
96
 
            inventory.InventoryDirectory('foo-id', 'quux', root_id))])
 
94
               [b'foo-id', b'bar-id', b'baz-id'])
 
95
        wt.apply_inventory_delta([('foo', 'quux', b'foo-id',
 
96
            inventory.InventoryDirectory(b'foo-id', 'quux', root_id))])
97
97
        # foo/bar/baz should have been followed the rename of its parent's
98
98
        # parent to quux/bar/baz
99
 
        self.assertEqual('quux/bar/baz', wt.id2path('baz-id'))
 
99
        self.assertEqual('quux/bar/baz', wt.id2path(b'baz-id'))
100
100
 
101
101
    def test_rename_file(self):
102
102
        wt = self.make_branch_and_tree('.')
104
104
        self.addCleanup(wt.unlock)
105
105
        self.build_tree(['foo/', 'foo/bar', 'baz/'])
106
106
        wt.add(['foo', 'foo/bar', 'baz'],
107
 
               ['foo-id', 'bar-id', 'baz-id'])
108
 
        wt.apply_inventory_delta([('foo/bar', 'baz/bar', 'bar-id',
109
 
            inventory.InventoryFile('bar-id', 'bar', 'baz-id'))])
110
 
        self.assertEqual('baz/bar', wt.id2path('bar-id'))
 
107
               [b'foo-id', b'bar-id', b'baz-id'])
 
108
        wt.apply_inventory_delta([('foo/bar', 'baz/bar', b'bar-id',
 
109
            inventory.InventoryFile(b'bar-id', 'bar', b'baz-id'))])
 
110
        self.assertEqual('baz/bar', wt.id2path(b'bar-id'))
111
111
 
112
112
    def test_rename_swap(self):
113
113
        """Test the swap-names edge case.
121
121
        self.addCleanup(wt.unlock)
122
122
        self.build_tree(['foo/', 'foo/bar', 'baz/', 'baz/qux'])
123
123
        wt.add(['foo', 'foo/bar', 'baz', 'baz/qux'],
124
 
               ['foo-id', 'bar-id', 'baz-id', 'qux-id'])
125
 
        wt.apply_inventory_delta([('foo', 'baz', 'foo-id',
126
 
            inventory.InventoryDirectory('foo-id', 'baz', root_id)),
127
 
            ('baz', 'foo', 'baz-id',
128
 
            inventory.InventoryDirectory('baz-id', 'foo', root_id))])
129
 
        self.assertEqual('baz/bar', wt.id2path('bar-id'))
130
 
        self.assertEqual('foo/qux', wt.id2path('qux-id'))
 
124
               [b'foo-id', b'bar-id', b'baz-id', b'qux-id'])
 
125
        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))])
 
129
        self.assertEqual('baz/bar', wt.id2path(b'bar-id'))
 
130
        self.assertEqual('foo/qux', wt.id2path(b'qux-id'))
131
131
 
132
132
    def test_child_rename_ordering(self):
133
133
        """Test the rename-parent, move child edge case.
139
139
        root_id = wt.get_root_id()
140
140
        self.build_tree(['dir/', 'dir/child', 'other/'])
141
141
        wt.add(['dir', 'dir/child', 'other'],
142
 
               ['dir-id', 'child-id', 'other-id'])
 
142
               [b'dir-id', b'child-id', b'other-id'])
143
143
        # this delta moves dir-id to dir2 and reparents
144
144
        # child-id to a parent of other-id
145
 
        wt.apply_inventory_delta([('dir', 'dir2', 'dir-id',
146
 
            inventory.InventoryDirectory('dir-id', 'dir2', root_id)),
147
 
            ('dir/child', 'other/child', 'child-id',
148
 
             inventory.InventoryFile('child-id', 'child', 'other-id'))])
149
 
        self.assertEqual('dir2', wt.id2path('dir-id'))
150
 
        self.assertEqual('other/child', wt.id2path('child-id'))
 
145
        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'))])
 
149
        self.assertEqual('dir2', wt.id2path(b'dir-id'))
 
150
        self.assertEqual('other/child', wt.id2path(b'child-id'))
151
151
 
152
152
    def test_replace_root(self):
153
153
        wt = self.make_branch_and_tree('.')
170
170
        if not base.supports_tree_reference():
171
171
            raise tests.TestNotApplicable("wt doesn't support nested trees")
172
172
        # We add it as a directory, but it becomes a tree-reference
173
 
        base.add(['subdir'], ['subdir-id'], ['directory'])
 
173
        base.add(['subdir'], [b'subdir-id'], ['directory'])
174
174
        subdir = self.make_branch_and_tree('base/subdir')
175
175
        self.addCleanup(base.lock_read().unlock)
176
176
        # Note: we aren't strict about ie.kind being 'directory' here, what we
177
177
        # are strict about is that wt.inventory should match
178
178
        # wt.current_dirstate()'s idea about what files are where.
179
 
        ie = base.inventory['subdir-id']
 
179
        ie = base.inventory[b'subdir-id']
180
180
        self.assertEqual('directory', ie.kind)
181
181
        path, ie = next(base.iter_entries_by_dir(specific_files=['subdir']))
182
182
        self.assertEqual('subdir', path)