/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.2 by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical
1
# Copyright (C) 2006 Canonical Ltd
1908.5.2 by Robert Collins
Create and test set_parent_trees.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1908.5.2 by Robert Collins
Create and test set_parent_trees.
16
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
17
"""Tests of the parent related functions of WorkingTrees."""
18
1908.5.2 by Robert Collins
Create and test set_parent_trees.
19
import os
20
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
21
from ... import (
2598.5.2 by Aaron Bentley
Got all tests passing with Branch returning 'null:' for null revision
22
    errors,
23
    revision as _mod_revision,
24
    )
6670.4.3 by Jelmer Vernooij
Fix more imports.
25
from ...bzr.inventory import (
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
26
    Inventory,
27
    InventoryFile,
28
    InventoryDirectory,
29
    InventoryLink,
30
    )
6913.4.2 by Jelmer Vernooij
Skip parents tests against non-inventory trees.
31
from ...bzr.inventorytree import (
32
    InventoryRevisionTree,
33
    InventoryTree,
34
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
35
from ...sixish import (
6621.22.2 by Martin
Use BytesIO or StringIO from bzrlib.sixish
36
    BytesIO,
37
    )
6913.4.2 by Jelmer Vernooij
Skip parents tests against non-inventory trees.
38
from ...tests import TestNotApplicable
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
39
from ..per_workingtree import TestCaseWithWorkingTree
40
from .. import (
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
41
    features,
42
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
43
from ...uncommit import uncommit
1908.5.2 by Robert Collins
Create and test set_parent_trees.
44
45
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
46
class TestParents(TestCaseWithWorkingTree):
47
48
    def assertConsistentParents(self, expected, tree):
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
49
        """Check that the parents found are as expected.
50
51
        This test helper also checks that they are consistent with
52
        the pre-get_parent_ids() api - which is now deprecated.
53
        """
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
54
        self.assertEqual(expected, tree.get_parent_ids())
55
        if expected == []:
2598.5.7 by Aaron Bentley
Updates from review
56
            self.assertEqual(_mod_revision.NULL_REVISION,
57
                             _mod_revision.ensure_null(tree.last_revision()))
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
58
        else:
1908.7.11 by Robert Collins
Merge bzr.dev and undeprecated WorkingTree.last_revision as per review feedback.
59
            self.assertEqual(expected[0], tree.last_revision())
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
60
61
2598.5.2 by Aaron Bentley
Got all tests passing with Branch returning 'null:' for null revision
62
class TestGetParents(TestParents):
63
64
    def test_get_parents(self):
65
        t = self.make_branch_and_tree('.')
66
        self.assertEqual([], t.get_parent_ids())
67
68
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
69
class TestSetParents(TestParents):
1908.5.2 by Robert Collins
Create and test set_parent_trees.
70
71
    def test_set_no_parents(self):
72
        t = self.make_branch_and_tree('.')
73
        t.set_parent_trees([])
74
        self.assertEqual([], t.get_parent_ids())
75
        # now give it a real parent, and then set it to no parents again.
76
        t.commit('first post')
77
        t.set_parent_trees([])
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
78
        self.assertConsistentParents([], t)
1908.5.2 by Robert Collins
Create and test set_parent_trees.
79
2598.5.2 by Aaron Bentley
Got all tests passing with Branch returning 'null:' for null revision
80
    def test_set_null_parent(self):
81
        t = self.make_branch_and_tree('.')
6973.11.7 by Jelmer Vernooij
Fix more tests.
82
        self.assertRaises(errors.ReservedId, t.set_parent_ids, [b'null:'],
2598.5.2 by Aaron Bentley
Got all tests passing with Branch returning 'null:' for null revision
83
                          allow_leftmost_as_ghost=True)
84
        self.assertRaises(errors.ReservedId, t.set_parent_trees,
6973.11.7 by Jelmer Vernooij
Fix more tests.
85
                          [(b'null:', None)], allow_leftmost_as_ghost=True)
2598.5.2 by Aaron Bentley
Got all tests passing with Branch returning 'null:' for null revision
86
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
87
    def test_set_one_ghost_parent_rejects(self):
88
        t = self.make_branch_and_tree('.')
1908.5.12 by Robert Collins
Apply review feedback - paired with Martin.
89
        self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
90
                          t.set_parent_trees, [(b'missing-revision-id', None)])
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
91
92
    def test_set_one_ghost_parent_force(self):
93
        t = self.make_branch_and_tree('.')
6844.1.2 by Jelmer Vernooij
Add supports_leftmost_parent_id_as_ghost.
94
        if t._format.supports_leftmost_parent_id_as_ghost:
6973.11.7 by Jelmer Vernooij
Fix more tests.
95
            t.set_parent_trees([(b'missing-revision-id', None)],
7143.15.2 by Jelmer Vernooij
Run autopep8.
96
                               allow_leftmost_as_ghost=True)
6973.11.7 by Jelmer Vernooij
Fix more tests.
97
            self.assertConsistentParents([b'missing-revision-id'], t)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
98
        else:
99
            self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
100
                              t.set_parent_trees, [(b'missing-revision-id', None)])
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
101
            self.assertConsistentParents([], t)
1908.5.2 by Robert Collins
Create and test set_parent_trees.
102
103
    def test_set_two_parents_one_ghost(self):
104
        t = self.make_branch_and_tree('.')
105
        revision_in_repo = t.commit('first post')
106
        # remove the tree's history
107
        uncommit(t.branch, tree=t)
108
        rev_tree = t.branch.repository.revision_tree(revision_in_repo)
6861.5.1 by Jelmer Vernooij
Add supports_righthand_parent_id_as_ghost flag.
109
        if t._format.supports_righthand_parent_id_as_ghost:
110
            t.set_parent_trees([(revision_in_repo, rev_tree),
7143.15.2 by Jelmer Vernooij
Run autopep8.
111
                                (b'another-missing', None)])
112
            self.assertConsistentParents(
113
                [revision_in_repo, b'another-missing'], t)
6861.5.1 by Jelmer Vernooij
Add supports_righthand_parent_id_as_ghost flag.
114
        else:
115
            self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
116
                              t.set_parent_trees, [(revision_in_repo, rev_tree),
117
                                                   (b'another-missing', None)])
1908.5.2 by Robert Collins
Create and test set_parent_trees.
118
119
    def test_set_three_parents(self):
120
        t = self.make_branch_and_tree('.')
121
        first_revision = t.commit('first post')
122
        uncommit(t.branch, tree=t)
123
        second_revision = t.commit('second post')
124
        uncommit(t.branch, tree=t)
125
        third_revision = t.commit('third post')
126
        uncommit(t.branch, tree=t)
127
        rev_tree1 = t.branch.repository.revision_tree(first_revision)
128
        rev_tree2 = t.branch.repository.revision_tree(second_revision)
129
        rev_tree3 = t.branch.repository.revision_tree(third_revision)
130
        t.set_parent_trees([(first_revision, rev_tree1),
7143.15.2 by Jelmer Vernooij
Run autopep8.
131
                            (second_revision, rev_tree2),
132
                            (third_revision, rev_tree3)])
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
133
        self.assertConsistentParents(
134
            [first_revision, second_revision, third_revision], t)
1908.5.4 by Robert Collins
Add add_parent_tree_id WorkingTree helper api.
135
1908.5.5 by Robert Collins
Add WorkingTree.set_parent_ids.
136
    def test_set_no_parents_ids(self):
137
        t = self.make_branch_and_tree('.')
138
        t.set_parent_ids([])
139
        self.assertEqual([], t.get_parent_ids())
140
        # now give it a real parent, and then set it to no parents again.
141
        t.commit('first post')
142
        t.set_parent_ids([])
143
        self.assertConsistentParents([], t)
144
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
145
    def test_set_one_ghost_parent_ids_rejects(self):
146
        t = self.make_branch_and_tree('.')
1908.5.12 by Robert Collins
Apply review feedback - paired with Martin.
147
        self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
148
                          t.set_parent_ids, [b'missing-revision-id'])
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
149
150
    def test_set_one_ghost_parent_ids_force(self):
151
        t = self.make_branch_and_tree('.')
6844.1.2 by Jelmer Vernooij
Add supports_leftmost_parent_id_as_ghost.
152
        if t._format.supports_leftmost_parent_id_as_ghost:
6973.10.6 by Jelmer Vernooij
Fix tests.
153
            t.set_parent_ids([b'missing-revision-id'],
7143.15.2 by Jelmer Vernooij
Run autopep8.
154
                             allow_leftmost_as_ghost=True)
6973.10.6 by Jelmer Vernooij
Fix tests.
155
            self.assertConsistentParents([b'missing-revision-id'], t)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
156
        else:
157
            self.assertRaises(
158
                errors.GhostRevisionUnusableHere, t.set_parent_ids,
6973.10.6 by Jelmer Vernooij
Fix tests.
159
                [b'missing-revision-id'], allow_leftmost_as_ghost=True)
1908.5.5 by Robert Collins
Add WorkingTree.set_parent_ids.
160
161
    def test_set_two_parents_one_ghost_ids(self):
162
        t = self.make_branch_and_tree('.')
163
        revision_in_repo = t.commit('first post')
164
        # remove the tree's history
165
        uncommit(t.branch, tree=t)
166
        rev_tree = t.branch.repository.revision_tree(revision_in_repo)
6861.5.1 by Jelmer Vernooij
Add supports_righthand_parent_id_as_ghost flag.
167
        if t._format.supports_righthand_parent_id_as_ghost:
6973.10.6 by Jelmer Vernooij
Fix tests.
168
            t.set_parent_ids([revision_in_repo, b'another-missing'])
7143.15.2 by Jelmer Vernooij
Run autopep8.
169
            self.assertConsistentParents(
170
                [revision_in_repo, b'another-missing'], t)
6861.5.1 by Jelmer Vernooij
Add supports_righthand_parent_id_as_ghost flag.
171
        else:
172
            self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
173
                              t.set_parent_ids, [revision_in_repo, b'another-missing'])
1908.5.5 by Robert Collins
Add WorkingTree.set_parent_ids.
174
175
    def test_set_three_parents_ids(self):
176
        t = self.make_branch_and_tree('.')
177
        first_revision = t.commit('first post')
178
        uncommit(t.branch, tree=t)
179
        second_revision = t.commit('second post')
180
        uncommit(t.branch, tree=t)
181
        third_revision = t.commit('third post')
182
        uncommit(t.branch, tree=t)
183
        rev_tree1 = t.branch.repository.revision_tree(first_revision)
184
        rev_tree2 = t.branch.repository.revision_tree(second_revision)
185
        rev_tree3 = t.branch.repository.revision_tree(third_revision)
186
        t.set_parent_ids([first_revision, second_revision, third_revision])
187
        self.assertConsistentParents(
188
            [first_revision, second_revision, third_revision], t)
189
3462.1.2 by John Arbash Meinel
Change WT.set_parent_(ids/trees) to filter out ancestors.
190
    def test_set_duplicate_parent_ids(self):
191
        t = self.make_branch_and_tree('.')
192
        rev1 = t.commit('first post')
193
        uncommit(t.branch, tree=t)
194
        rev2 = t.commit('second post')
195
        uncommit(t.branch, tree=t)
196
        rev3 = t.commit('third post')
197
        uncommit(t.branch, tree=t)
198
        t.set_parent_ids([rev1, rev2, rev2, rev3])
199
        # We strip the duplicate, but preserve the ordering
200
        self.assertConsistentParents([rev1, rev2, rev3], t)
201
202
    def test_set_duplicate_parent_trees(self):
203
        t = self.make_branch_and_tree('.')
204
        rev1 = t.commit('first post')
205
        uncommit(t.branch, tree=t)
206
        rev2 = t.commit('second post')
207
        uncommit(t.branch, tree=t)
208
        rev3 = t.commit('third post')
209
        uncommit(t.branch, tree=t)
210
        rev_tree1 = t.branch.repository.revision_tree(rev1)
211
        rev_tree2 = t.branch.repository.revision_tree(rev2)
212
        rev_tree3 = t.branch.repository.revision_tree(rev3)
213
        t.set_parent_trees([(rev1, rev_tree1), (rev2, rev_tree2),
214
                            (rev2, rev_tree2), (rev3, rev_tree3)])
215
        # We strip the duplicate, but preserve the ordering
216
        self.assertConsistentParents([rev1, rev2, rev3], t)
217
218
    def test_set_parent_ids_in_ancestry(self):
219
        t = self.make_branch_and_tree('.')
220
        rev1 = t.commit('first post')
221
        rev2 = t.commit('second post')
222
        rev3 = t.commit('third post')
223
        # Reset the tree, back to rev1
224
        t.set_parent_ids([rev1])
225
        t.branch.set_last_revision_info(1, rev1)
226
        self.assertConsistentParents([rev1], t)
227
        t.set_parent_ids([rev1, rev2, rev3])
228
        # rev2 is in the ancestry of rev3, so it will be filtered out
229
        self.assertConsistentParents([rev1, rev3], t)
230
        # Order should be preserved, and the first revision should always be
231
        # kept
232
        t.set_parent_ids([rev2, rev3, rev1])
233
        self.assertConsistentParents([rev2, rev3], t)
234
235
    def test_set_parent_trees_in_ancestry(self):
236
        t = self.make_branch_and_tree('.')
237
        rev1 = t.commit('first post')
238
        rev2 = t.commit('second post')
239
        rev3 = t.commit('third post')
240
        # Reset the tree, back to rev1
241
        t.set_parent_ids([rev1])
242
        t.branch.set_last_revision_info(1, rev1)
243
        self.assertConsistentParents([rev1], t)
244
        rev_tree1 = t.branch.repository.revision_tree(rev1)
245
        rev_tree2 = t.branch.repository.revision_tree(rev2)
246
        rev_tree3 = t.branch.repository.revision_tree(rev3)
247
        t.set_parent_trees([(rev1, rev_tree1), (rev2, rev_tree2),
248
                            (rev3, rev_tree3)])
249
        # rev2 is in the ancestry of rev3, so it will be filtered out
250
        self.assertConsistentParents([rev1, rev3], t)
251
        # Order should be preserved, and the first revision should always be
252
        # kept
253
        t.set_parent_trees([(rev2, rev_tree2), (rev1, rev_tree1),
254
                            (rev3, rev_tree3)])
255
        self.assertConsistentParents([rev2, rev3], t)
256
3763.9.7 by Daniel Clemente
Tested Unicode target rather than always trying to create it in UTF-8. Test renamed
257
    def test_unicode_symlink(self):
3763.9.1 by Daniel Clemente
New testcase for bug 272444 (support symlinks to non-ASCII files)
258
        # this tests bug #272444
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
259
        self.requireFeature(features.SymlinkFeature)
260
        self.requireFeature(features.UnicodeFilenameFeature)
3763.9.1 by Daniel Clemente
New testcase for bug 272444 (support symlinks to non-ASCII files)
261
3763.9.3 by Daniel Clemente
Clearer test with better names and just one parent
262
        tree = self.make_branch_and_tree('tree1')
3763.9.2 by Daniel Clemente
Adapted test to use set_parent_ids and raise KnownFailure
263
3763.9.9 by Daniel Clemente
Used a greek omega instead of an accented 'o' to avoid combining characters
264
        # The link points to a file whose name is an omega
265
        # U+03A9 GREEK CAPITAL LETTER OMEGA
266
        # UTF-8: ce a9  UTF-16BE: 03a9  Decimal: Ω
4241.14.12 by Vincent Ladeuil
Far too many modifications for a single commit, need to restart.
267
        target = u'\u03a9'
268
        link_name = u'\N{Euro Sign}link'
269
        os.symlink(target, 'tree1/' + link_name)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
270
        tree.add([link_name])
3763.9.2 by Daniel Clemente
Adapted test to use set_parent_ids and raise KnownFailure
271
4095.3.1 by Vincent Ladeuil
Fix #339055 and #277444 by handling non ascii symlink targets.
272
        revision1 = tree.commit('added a link to a Unicode target')
273
        revision2 = tree.commit('this revision will be discarded')
274
        tree.set_parent_ids([revision1])
4241.14.12 by Vincent Ladeuil
Far too many modifications for a single commit, need to restart.
275
        tree.lock_read()
276
        self.addCleanup(tree.unlock)
277
        # Check that the symlink target is safely round-tripped in the trees.
6809.4.7 by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind.
278
        self.assertEqual(target, tree.get_symlink_target(link_name))
4241.14.12 by Vincent Ladeuil
Far too many modifications for a single commit, need to restart.
279
        basis = tree.basis_tree()
6809.4.7 by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind.
280
        self.assertEqual(target, basis.get_symlink_target(link_name))
3763.9.1 by Daniel Clemente
New testcase for bug 272444 (support symlinks to non-ASCII files)
281
1908.5.4 by Robert Collins
Add add_parent_tree_id WorkingTree helper api.
282
1908.5.6 by Robert Collins
Add add_parent_tree to WorkingTree.
283
class TestAddParent(TestParents):
1908.5.4 by Robert Collins
Add add_parent_tree_id WorkingTree helper api.
284
285
    def test_add_first_parent_id(self):
286
        """Test adding the first parent id"""
287
        tree = self.make_branch_and_tree('.')
288
        first_revision = tree.commit('first post')
289
        uncommit(tree.branch, tree=tree)
290
        tree.add_parent_tree_id(first_revision)
291
        self.assertConsistentParents([first_revision], tree)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
292
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
293
    def test_add_first_parent_id_ghost_rejects(self):
294
        """Test adding the first parent id - as a ghost"""
295
        tree = self.make_branch_and_tree('.')
1908.5.12 by Robert Collins
Apply review feedback - paired with Martin.
296
        self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
297
                          tree.add_parent_tree_id, b'first-revision')
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
298
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
299
    def test_add_first_parent_id_ghost_force(self):
300
        """Test adding the first parent id - as a ghost"""
301
        tree = self.make_branch_and_tree('.')
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
302
        try:
7143.15.2 by Jelmer Vernooij
Run autopep8.
303
            tree.add_parent_tree_id(
304
                b'first-revision', allow_leftmost_as_ghost=True)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
305
        except errors.GhostRevisionUnusableHere:
6844.1.2 by Jelmer Vernooij
Add supports_leftmost_parent_id_as_ghost.
306
            self.assertFalse(tree._format.supports_leftmost_parent_id_as_ghost)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
307
        else:
6844.1.2 by Jelmer Vernooij
Add supports_leftmost_parent_id_as_ghost.
308
            self.assertTrue(tree._format.supports_leftmost_parent_id_as_ghost)
6973.10.4 by Jelmer Vernooij
Update python3.passing.
309
            self.assertConsistentParents([b'first-revision'], tree)
1908.5.13 by Robert Collins
Adding a parent when the first is a ghost already should not require forcing it.
310
311
    def test_add_second_parent_id_with_ghost_first(self):
312
        """Test adding the second parent when the first is a ghost."""
313
        tree = self.make_branch_and_tree('.')
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
314
        try:
7143.15.2 by Jelmer Vernooij
Run autopep8.
315
            tree.add_parent_tree_id(
316
                b'first-revision', allow_leftmost_as_ghost=True)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
317
        except errors.GhostRevisionUnusableHere:
6844.1.2 by Jelmer Vernooij
Add supports_leftmost_parent_id_as_ghost.
318
            self.assertFalse(tree._format.supports_leftmost_parent_id_as_ghost)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
319
        else:
6973.10.4 by Jelmer Vernooij
Update python3.passing.
320
            tree.add_parent_tree_id(b'second')
321
            self.assertConsistentParents([b'first-revision', b'second'], tree)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
322
1908.5.4 by Robert Collins
Add add_parent_tree_id WorkingTree helper api.
323
    def test_add_second_parent_id(self):
324
        """Test adding the second parent id"""
325
        tree = self.make_branch_and_tree('.')
326
        first_revision = tree.commit('first post')
327
        uncommit(tree.branch, tree=tree)
328
        second_revision = tree.commit('second post')
329
        tree.add_parent_tree_id(first_revision)
330
        self.assertConsistentParents([second_revision, first_revision], tree)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
331
1908.5.4 by Robert Collins
Add add_parent_tree_id WorkingTree helper api.
332
    def test_add_second_parent_id_ghost(self):
333
        """Test adding the second parent id - as a ghost"""
334
        tree = self.make_branch_and_tree('.')
335
        first_revision = tree.commit('first post')
6861.5.1 by Jelmer Vernooij
Add supports_righthand_parent_id_as_ghost flag.
336
        if tree._format.supports_righthand_parent_id_as_ghost:
6973.10.4 by Jelmer Vernooij
Update python3.passing.
337
            tree.add_parent_tree_id(b'second')
338
            self.assertConsistentParents([first_revision, b'second'], tree)
6861.5.1 by Jelmer Vernooij
Add supports_righthand_parent_id_as_ghost flag.
339
        else:
340
            self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
341
                              tree.add_parent_tree_id, b'second')
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
342
1908.5.6 by Robert Collins
Add add_parent_tree to WorkingTree.
343
    def test_add_first_parent_tree(self):
344
        """Test adding the first parent id"""
345
        tree = self.make_branch_and_tree('.')
346
        first_revision = tree.commit('first post')
347
        uncommit(tree.branch, tree=tree)
348
        tree.add_parent_tree((first_revision,
7143.15.2 by Jelmer Vernooij
Run autopep8.
349
                              tree.branch.repository.revision_tree(first_revision)))
1908.5.6 by Robert Collins
Add add_parent_tree to WorkingTree.
350
        self.assertConsistentParents([first_revision], tree)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
351
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
352
    def test_add_first_parent_tree_ghost_rejects(self):
353
        """Test adding the first parent id - as a ghost"""
354
        tree = self.make_branch_and_tree('.')
1908.5.12 by Robert Collins
Apply review feedback - paired with Martin.
355
        self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
356
                          tree.add_parent_tree, (b'first-revision', None))
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
357
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
358
    def test_add_first_parent_tree_ghost_force(self):
359
        """Test adding the first parent id - as a ghost"""
360
        tree = self.make_branch_and_tree('.')
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
361
        try:
7045.4.1 by Jelmer Vernooij
Some brz-git fixes.
362
            tree.add_parent_tree((b'first-revision', None),
7143.15.2 by Jelmer Vernooij
Run autopep8.
363
                                 allow_leftmost_as_ghost=True)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
364
        except errors.GhostRevisionUnusableHere:
6844.1.2 by Jelmer Vernooij
Add supports_leftmost_parent_id_as_ghost.
365
            self.assertFalse(tree._format.supports_leftmost_parent_id_as_ghost)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
366
        else:
6844.1.2 by Jelmer Vernooij
Add supports_leftmost_parent_id_as_ghost.
367
            self.assertTrue(tree._format.supports_leftmost_parent_id_as_ghost)
7045.4.1 by Jelmer Vernooij
Some brz-git fixes.
368
            self.assertConsistentParents([b'first-revision'], tree)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
369
1908.5.6 by Robert Collins
Add add_parent_tree to WorkingTree.
370
    def test_add_second_parent_tree(self):
371
        """Test adding the second parent id"""
372
        tree = self.make_branch_and_tree('.')
373
        first_revision = tree.commit('first post')
374
        uncommit(tree.branch, tree=tree)
375
        second_revision = tree.commit('second post')
376
        tree.add_parent_tree((first_revision,
7143.15.2 by Jelmer Vernooij
Run autopep8.
377
                              tree.branch.repository.revision_tree(first_revision)))
1908.5.6 by Robert Collins
Add add_parent_tree to WorkingTree.
378
        self.assertConsistentParents([second_revision, first_revision], tree)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
379
1908.5.6 by Robert Collins
Add add_parent_tree to WorkingTree.
380
    def test_add_second_parent_tree_ghost(self):
381
        """Test adding the second parent id - as a ghost"""
382
        tree = self.make_branch_and_tree('.')
383
        first_revision = tree.commit('first post')
6861.5.1 by Jelmer Vernooij
Add supports_righthand_parent_id_as_ghost flag.
384
        if tree._format.supports_righthand_parent_id_as_ghost:
7045.4.1 by Jelmer Vernooij
Some brz-git fixes.
385
            tree.add_parent_tree((b'second', None))
386
            self.assertConsistentParents([first_revision, b'second'], tree)
6861.5.1 by Jelmer Vernooij
Add supports_righthand_parent_id_as_ghost flag.
387
        else:
388
            self.assertRaises(errors.GhostRevisionUnusableHere,
7143.15.2 by Jelmer Vernooij
Run autopep8.
389
                              tree.add_parent_tree, (b'second', None))
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
390
391
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
392
class UpdateToOneParentViaDeltaTests(TestCaseWithWorkingTree):
2903.2.7 by Martin Pool
Rename update_to_one_parent_via_delta to more wieldy update_basis_by_delta
393
    """Tests for the update_basis_by_delta call.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
394
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
395
    This is intuitively defined as 'apply an inventory delta to the basis and
396
    discard other parents', but for trees that have an inventory that is not
397
    managed as a tree-by-id, the implementation requires roughly duplicated
398
    tests with those for apply_inventory_delta on the main tree.
399
    """
400
401
    def assertDeltaApplicationResultsInExpectedBasis(self, tree, revid, delta,
7143.15.2 by Jelmer Vernooij
Run autopep8.
402
                                                     expected_inventory):
6913.4.2 by Jelmer Vernooij
Skip parents tests against non-inventory trees.
403
        with tree.lock_write():
2929.2.1 by Robert Collins
* Commit updates the state of the working tree via a delta rather than
404
            tree.update_basis_by_delta(revid, delta)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
405
        # check the last revision was adjusted to rev_id
406
        self.assertEqual(revid, tree.last_revision())
407
        # check the parents are what we expect
408
        self.assertEqual([revid], tree.get_parent_ids())
409
        # check that the basis tree has the inventory we expect from applying
410
        # the delta.
411
        result_basis = tree.basis_tree()
6913.4.2 by Jelmer Vernooij
Skip parents tests against non-inventory trees.
412
        with result_basis.lock_read():
6405.2.9 by Jelmer Vernooij
More test fixes.
413
            self.assertEqual(expected_inventory, result_basis.root_inventory)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
414
415
    def make_inv_delta(self, old, new):
416
        """Make an inventory delta from two inventories."""
6656.1.1 by Martin
Apply 2to3 dict fixer and clean up resulting mess using view helpers
417
        old_ids = set(old._byid)
418
        new_ids = set(new._byid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
419
        adds = new_ids - old_ids
420
        deletes = old_ids - new_ids
421
        common = old_ids.intersection(new_ids)
422
        delta = []
423
        for file_id in deletes:
424
            delta.append((old.id2path(file_id), None, file_id, None))
425
        for file_id in adds:
7143.15.2 by Jelmer Vernooij
Run autopep8.
426
            delta.append((None, new.id2path(file_id),
427
                          file_id, new.get_entry(file_id)))
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
428
        for file_id in common:
6915.4.2 by Jelmer Vernooij
Remove __getitem__ and __iter__ from Inventory.
429
            if old.get_entry(file_id) != new.get_entry(file_id):
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
430
                delta.append((old.id2path(file_id), new.id2path(file_id),
7143.15.2 by Jelmer Vernooij
Run autopep8.
431
                              file_id, new.get_entry(file_id)))
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
432
        return delta
433
434
    def fake_up_revision(self, tree, revid, shape):
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
435
6913.4.2 by Jelmer Vernooij
Skip parents tests against non-inventory trees.
436
        if not isinstance(tree, InventoryTree):
437
            raise TestNotApplicable("test requires inventory tree")
438
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
439
        class ShapeTree(InventoryRevisionTree):
440
441
            def __init__(self, shape):
442
                self._repository = tree.branch.repository
443
                self._inventory = shape
444
7192.5.1 by Jelmer Vernooij
Remove more file ids.
445
            def get_file_text(self, path):
446
                file_id = self.path2id(path)
6915.4.2 by Jelmer Vernooij
Remove __getitem__ and __iter__ from Inventory.
447
                ie = self.root_inventory.get_entry(file_id)
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
448
                if ie.kind != "file":
6977.2.1 by Jelmer Vernooij
Require that get_file implementations are contect managers, simplify file handling in transform.
449
                    return b""
450
                return b'a' * ie.text_size
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
451
7192.5.1 by Jelmer Vernooij
Remove more file ids.
452
            def get_file(self, path):
453
                return BytesIO(self.get_file_text(path))
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
454
6851.1.1 by Jelmer Vernooij
More foreign branch fixes.
455
        with tree.lock_write():
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
456
            if shape.root.revision is None:
457
                shape.root.revision = revid
458
            builder = tree.branch.get_commit_builder(
7143.15.2 by Jelmer Vernooij
Run autopep8.
459
                parents=[],
460
                timestamp=0,
461
                timezone=None,
462
                committer="Foo Bar <foo@example.com>",
463
                revision_id=revid)
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
464
            shape_tree = ShapeTree(shape)
5809.4.3 by Jelmer Vernooij
Fix base revid.
465
            base_tree = tree.branch.repository.revision_tree(
7143.15.2 by Jelmer Vernooij
Run autopep8.
466
                _mod_revision.NULL_REVISION)
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
467
            changes = shape_tree.iter_changes(
5809.4.3 by Jelmer Vernooij
Fix base revid.
468
                base_tree)
7206.6.1 by Jelmer Vernooij
Drop file_id from record_iter_changes return value.
469
            list(builder.record_iter_changes(
470
                shape_tree, base_tree.get_revision_id(), changes))
5809.4.1 by Jelmer Vernooij
Avoid .texts.add_lines, rather use Repository.get_commit_builder.
471
            builder.finish_inventory()
472
            builder.commit("Message")
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
473
474
    def add_entry(self, inv, rev_id, entry):
475
        entry.revision = rev_id
476
        inv.add(entry)
477
478
    def add_dir(self, inv, rev_id, file_id, parent_id, name):
479
        new_dir = InventoryDirectory(file_id, name, parent_id)
480
        self.add_entry(inv, rev_id, new_dir)
481
482
    def add_file(self, inv, rev_id, file_id, parent_id, name, sha, size):
483
        new_file = InventoryFile(file_id, name, parent_id)
484
        new_file.text_sha1 = sha
485
        new_file.text_size = size
486
        self.add_entry(inv, rev_id, new_file)
487
488
    def add_link(self, inv, rev_id, file_id, parent_id, name, target):
489
        new_link = InventoryLink(file_id, name, parent_id)
490
        new_link.symlink_target = target
491
        self.add_entry(inv, rev_id, new_link)
492
493
    def add_new_root(self, new_shape, old_revid, new_revid):
494
        if self.bzrdir_format.repository_format.rich_root_data:
6973.11.7 by Jelmer Vernooij
Fix more tests.
495
            self.add_dir(new_shape, old_revid, b'root-id', None, '')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
496
        else:
6973.11.7 by Jelmer Vernooij
Fix more tests.
497
            self.add_dir(new_shape, new_revid, b'root-id', None, '')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
498
499
    def assertTransitionFromBasisToShape(self, basis_shape, basis_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
500
                                         new_shape, new_revid, extra_parent=None, set_current_inventory=True):
2889.1.1 by Robert Collins
* The class ``bzrlib.repofmt.knitrepo.KnitRepository3`` has been folded into
501
        # set the inventory revision ids.
502
        basis_shape.revision_id = basis_revid
503
        new_shape.revision_id = new_revid
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
504
        delta = self.make_inv_delta(basis_shape, new_shape)
505
        tree = self.make_branch_and_tree('tree')
506
        # the shapes need to be in the tree's repository to be able to set them
507
        # as a parent, but the file content is not needed.
508
        if basis_revid is not None:
509
            self.fake_up_revision(tree, basis_revid, basis_shape)
510
            parents = [basis_revid]
511
            if extra_parent is not None:
512
                parents.append(extra_parent)
513
            tree.set_parent_ids(parents)
514
        self.fake_up_revision(tree, new_revid, new_shape)
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
515
        if set_current_inventory:
516
            # give tree an inventory of new_shape
517
            tree._write_inventory(new_shape)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
518
        self.assertDeltaApplicationResultsInExpectedBasis(tree, new_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
519
                                                          delta, new_shape)
2929.2.2 by Robert Collins
Review feedback on dirstate update_basis_via_delta logic.
520
        # The tree should be internally consistent; while this is a moderately
521
        # large hammer, this is a particularly sensitive area of code, so the
522
        # extra assurance is well worth it.
523
        tree._validate()
6437.70.4 by John Arbash Meinel
Now that we have 2 possible locations where things exist, we must cleanup both.
524
        # If tree.branch is remote
6437.70.5 by John Arbash Meinel
user_url seems a cleaner way to do the same thing.
525
        if tree.user_url != tree.branch.user_url:
6437.70.4 by John Arbash Meinel
Now that we have 2 possible locations where things exist, we must cleanup both.
526
            # We have a lightweight checkout, delete both locations
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
527
            tree.branch.controldir.root_transport.delete_tree('.')
528
        tree.controldir.root_transport.delete_tree('.')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
529
530
    def test_no_parents_just_root(self):
531
        """Test doing an empty commit - no parent, set a root only."""
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
532
        basis_shape = Inventory(root_id=None)  # empty tree
533
        new_shape = Inventory()  # tree with a root
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
534
        self.assertTransitionFromBasisToShape(basis_shape, None, new_shape,
7143.15.2 by Jelmer Vernooij
Run autopep8.
535
                                              b'new_parent')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
536
537
    def test_no_parents_full_tree(self):
538
        """Test doing a regular initial commit with files and dirs."""
7143.15.2 by Jelmer Vernooij
Run autopep8.
539
        basis_shape = Inventory(root_id=None)  # empty tree
6973.11.7 by Jelmer Vernooij
Fix more tests.
540
        revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
541
        new_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
542
        self.add_dir(new_shape, revid, b'root-id', None, '')
7143.15.2 by Jelmer Vernooij
Run autopep8.
543
        self.add_link(new_shape, revid, b'link-id',
544
                      b'root-id', 'link', 'target')
7045.1.1 by Jelmer Vernooij
Fix another 300 tests.
545
        self.add_file(new_shape, revid, b'file-id', b'root-id', 'file', b'1' * 32,
7143.15.2 by Jelmer Vernooij
Run autopep8.
546
                      12)
6973.11.7 by Jelmer Vernooij
Fix more tests.
547
        self.add_dir(new_shape, revid, b'dir-id', b'root-id', 'dir')
548
        self.add_file(new_shape, revid, b'subfile-id', b'dir-id', 'subfile',
7143.15.2 by Jelmer Vernooij
Run autopep8.
549
                      b'2' * 32, 24)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
550
        self.assertTransitionFromBasisToShape(basis_shape, None, new_shape,
7143.15.2 by Jelmer Vernooij
Run autopep8.
551
                                              revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
552
553
    def test_file_content_change(self):
6973.11.7 by Jelmer Vernooij
Fix more tests.
554
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
555
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
556
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
557
        self.add_file(basis_shape, old_revid, b'file-id', b'root-id', 'file',
7143.15.2 by Jelmer Vernooij
Run autopep8.
558
                      b'1' * 32, 12)
6973.11.7 by Jelmer Vernooij
Fix more tests.
559
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
560
        new_shape = Inventory(root_id=None)
561
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
562
        self.add_file(new_shape, new_revid, b'file-id', b'root-id', 'file',
7143.15.2 by Jelmer Vernooij
Run autopep8.
563
                      b'2' * 32, 24)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
564
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
565
                                              new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
566
567
    def test_link_content_change(self):
6973.11.7 by Jelmer Vernooij
Fix more tests.
568
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
569
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
570
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
571
        self.add_link(basis_shape, old_revid, b'link-id', b'root-id', 'link',
7143.15.2 by Jelmer Vernooij
Run autopep8.
572
                      'old-target')
6973.11.7 by Jelmer Vernooij
Fix more tests.
573
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
574
        new_shape = Inventory(root_id=None)
575
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
576
        self.add_link(new_shape, new_revid, b'link-id', b'root-id', 'link',
7143.15.2 by Jelmer Vernooij
Run autopep8.
577
                      'new-target')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
578
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
579
                                              new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
580
581
    def test_kind_changes(self):
582
        def do_file(inv, revid):
7045.1.1 by Jelmer Vernooij
Fix another 300 tests.
583
            self.add_file(inv, revid, b'path-id', b'root-id', 'path', b'1' * 32,
7143.15.2 by Jelmer Vernooij
Run autopep8.
584
                          12)
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
585
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
586
        def do_link(inv, revid):
6973.11.7 by Jelmer Vernooij
Fix more tests.
587
            self.add_link(inv, revid, b'path-id', b'root-id', 'path', 'target')
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
588
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
589
        def do_dir(inv, revid):
6973.11.7 by Jelmer Vernooij
Fix more tests.
590
            self.add_dir(inv, revid, b'path-id', b'root-id', 'path')
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
591
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
592
        for old_factory in (do_file, do_link, do_dir):
593
            for new_factory in (do_file, do_link, do_dir):
594
                if old_factory == new_factory:
595
                    continue
6973.11.7 by Jelmer Vernooij
Fix more tests.
596
                old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
597
                basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
598
                self.add_dir(basis_shape, old_revid, b'root-id', None, '')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
599
                old_factory(basis_shape, old_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
600
                new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
601
                new_shape = Inventory(root_id=None)
602
                self.add_new_root(new_shape, old_revid, new_revid)
603
                new_factory(new_shape, new_revid)
604
                self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
605
                                                      new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
606
607
    def test_content_from_second_parent_is_dropped(self):
7045.1.1 by Jelmer Vernooij
Fix another 300 tests.
608
        left_revid = b'left-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
609
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
610
        self.add_dir(basis_shape, left_revid, b'root-id', None, '')
611
        self.add_link(basis_shape, left_revid, b'link-id', b'root-id', 'link',
7143.15.2 by Jelmer Vernooij
Run autopep8.
612
                      'left-target')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
613
        # the right shape has content - file, link, subdir with a child,
614
        # that should all be discarded by the call.
7045.1.1 by Jelmer Vernooij
Fix another 300 tests.
615
        right_revid = b'right-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
616
        right_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
617
        self.add_dir(right_shape, left_revid, b'root-id', None, '')
618
        self.add_link(right_shape, right_revid, b'link-id', b'root-id', 'link',
7143.15.2 by Jelmer Vernooij
Run autopep8.
619
                      'some-target')
6973.11.7 by Jelmer Vernooij
Fix more tests.
620
        self.add_dir(right_shape, right_revid, b'subdir-id', b'root-id', 'dir')
621
        self.add_file(right_shape, right_revid, b'file-id', b'subdir-id', 'file',
7143.15.2 by Jelmer Vernooij
Run autopep8.
622
                      b'2' * 32, 24)
6973.11.7 by Jelmer Vernooij
Fix more tests.
623
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
624
        new_shape = Inventory(root_id=None)
625
        self.add_new_root(new_shape, left_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
626
        self.add_link(new_shape, new_revid, b'link-id', b'root-id', 'link',
7143.15.2 by Jelmer Vernooij
Run autopep8.
627
                      'new-target')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
628
        self.assertTransitionFromBasisToShape(basis_shape, left_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
629
                                              new_shape, new_revid, right_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
630
631
    def test_parent_id_changed(self):
2865.1.3 by Robert Collins
Review feedback.
632
        # test that when the only change to an entry is its parent id changing
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
633
        # that it is handled correctly (that is it keeps the same path)
6973.11.7 by Jelmer Vernooij
Fix more tests.
634
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
635
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
636
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
7143.15.2 by Jelmer Vernooij
Run autopep8.
637
        self.add_dir(basis_shape, old_revid,
638
                     b'orig-parent-id', b'root-id', 'dir')
639
        self.add_dir(basis_shape, old_revid, b'dir-id',
640
                     b'orig-parent-id', 'dir')
6973.11.7 by Jelmer Vernooij
Fix more tests.
641
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
642
        new_shape = Inventory(root_id=None)
643
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
644
        self.add_dir(new_shape, new_revid, b'new-parent-id', b'root-id', 'dir')
645
        self.add_dir(new_shape, new_revid, b'dir-id', b'new-parent-id', 'dir')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
646
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
647
                                              new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
648
649
    def test_name_changed(self):
2865.1.3 by Robert Collins
Review feedback.
650
        # test that when the only change to an entry is its name changing that
651
        # it is handled correctly (that is it keeps the same parent id)
6973.11.7 by Jelmer Vernooij
Fix more tests.
652
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
653
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
654
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
7143.15.2 by Jelmer Vernooij
Run autopep8.
655
        self.add_dir(basis_shape, old_revid,
656
                     b'parent-id', b'root-id', 'origdir')
6973.11.7 by Jelmer Vernooij
Fix more tests.
657
        self.add_dir(basis_shape, old_revid, b'dir-id', b'parent-id', 'olddir')
658
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
659
        new_shape = Inventory(root_id=None)
660
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
661
        self.add_dir(new_shape, new_revid, b'parent-id', b'root-id', 'newdir')
662
        self.add_dir(new_shape, new_revid, b'dir-id', b'parent-id', 'newdir')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
663
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
664
                                              new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
665
2929.2.2 by Robert Collins
Review feedback on dirstate update_basis_via_delta logic.
666
    def test_parent_child_swap(self):
667
        # test a A->A/B and A/B->A path swap.
6973.11.7 by Jelmer Vernooij
Fix more tests.
668
        old_revid = b'old-parent'
2929.2.2 by Robert Collins
Review feedback on dirstate update_basis_via_delta logic.
669
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
670
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
671
        self.add_dir(basis_shape, old_revid, b'dir-id-A', b'root-id', 'A')
672
        self.add_dir(basis_shape, old_revid, b'dir-id-B', b'dir-id-A', 'B')
7143.15.2 by Jelmer Vernooij
Run autopep8.
673
        self.add_link(basis_shape, old_revid,
674
                      b'link-id-C', b'dir-id-B', 'C', 'C')
6973.11.7 by Jelmer Vernooij
Fix more tests.
675
        new_revid = b'new-parent'
2929.2.2 by Robert Collins
Review feedback on dirstate update_basis_via_delta logic.
676
        new_shape = Inventory(root_id=None)
677
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
678
        self.add_dir(new_shape, new_revid, b'dir-id-B', b'root-id', 'A')
679
        self.add_dir(new_shape, new_revid, b'dir-id-A', b'dir-id-B', 'B')
7143.15.2 by Jelmer Vernooij
Run autopep8.
680
        self.add_link(new_shape, new_revid, b'link-id-C',
681
                      b'dir-id-A', 'C', 'C')
2929.2.2 by Robert Collins
Review feedback on dirstate update_basis_via_delta logic.
682
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
683
                                              new_shape, new_revid)
2929.2.2 by Robert Collins
Review feedback on dirstate update_basis_via_delta logic.
684
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
685
    def test_parent_deleted_child_renamed(self):
686
        # test a A->None and A/B->A.
6973.11.7 by Jelmer Vernooij
Fix more tests.
687
        old_revid = b'old-parent'
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
688
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
689
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
690
        self.add_dir(basis_shape, old_revid, b'dir-id-A', b'root-id', 'A')
691
        self.add_dir(basis_shape, old_revid, b'dir-id-B', b'dir-id-A', 'B')
7143.15.2 by Jelmer Vernooij
Run autopep8.
692
        self.add_link(basis_shape, old_revid,
693
                      b'link-id-C', b'dir-id-B', 'C', 'C')
6973.11.7 by Jelmer Vernooij
Fix more tests.
694
        new_revid = b'new-parent'
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
695
        new_shape = Inventory(root_id=None)
696
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
697
        self.add_dir(new_shape, new_revid, b'dir-id-B', b'root-id', 'A')
7143.15.2 by Jelmer Vernooij
Run autopep8.
698
        self.add_link(new_shape, old_revid, b'link-id-C',
699
                      b'dir-id-B', 'C', 'C')
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
700
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
701
                                              new_shape, new_revid)
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
702
703
    def test_dir_to_root(self):
704
        # test a A->''.
6973.11.7 by Jelmer Vernooij
Fix more tests.
705
        old_revid = b'old-parent'
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
706
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
707
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
708
        self.add_dir(basis_shape, old_revid, b'dir-id-A', b'root-id', 'A')
7143.15.2 by Jelmer Vernooij
Run autopep8.
709
        self.add_link(basis_shape, old_revid,
710
                      b'link-id-B', b'dir-id-A', 'B', 'B')
6973.11.7 by Jelmer Vernooij
Fix more tests.
711
        new_revid = b'new-parent'
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
712
        new_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
713
        self.add_dir(new_shape, new_revid, b'dir-id-A', None, '')
7143.15.2 by Jelmer Vernooij
Run autopep8.
714
        self.add_link(new_shape, old_revid, b'link-id-B',
715
                      b'dir-id-A', 'B', 'B')
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
716
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
717
                                              new_shape, new_revid)
3253.2.1 by John Arbash Meinel
Fix moving directories to root nodes.
718
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
719
    def test_path_swap(self):
720
        # test a A->B and B->A path swap.
6973.11.7 by Jelmer Vernooij
Fix more tests.
721
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
722
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
723
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
724
        self.add_dir(basis_shape, old_revid, b'dir-id-A', b'root-id', 'A')
725
        self.add_dir(basis_shape, old_revid, b'dir-id-B', b'root-id', 'B')
7143.15.2 by Jelmer Vernooij
Run autopep8.
726
        self.add_link(basis_shape, old_revid,
727
                      b'link-id-C', b'root-id', 'C', 'C')
728
        self.add_link(basis_shape, old_revid,
729
                      b'link-id-D', b'root-id', 'D', 'D')
6973.11.7 by Jelmer Vernooij
Fix more tests.
730
        self.add_file(basis_shape, old_revid, b'file-id-E', b'root-id', 'E',
7143.15.2 by Jelmer Vernooij
Run autopep8.
731
                      b'1' * 32, 12)
6973.11.7 by Jelmer Vernooij
Fix more tests.
732
        self.add_file(basis_shape, old_revid, b'file-id-F', b'root-id', 'F',
7143.15.2 by Jelmer Vernooij
Run autopep8.
733
                      b'2' * 32, 24)
6973.11.7 by Jelmer Vernooij
Fix more tests.
734
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
735
        new_shape = Inventory(root_id=None)
736
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
737
        self.add_dir(new_shape, new_revid, b'dir-id-A', b'root-id', 'B')
738
        self.add_dir(new_shape, new_revid, b'dir-id-B', b'root-id', 'A')
739
        self.add_link(new_shape, new_revid, b'link-id-C', b'root-id', 'D', 'C')
740
        self.add_link(new_shape, new_revid, b'link-id-D', b'root-id', 'C', 'D')
741
        self.add_file(new_shape, new_revid, b'file-id-E', b'root-id', 'F',
7143.15.2 by Jelmer Vernooij
Run autopep8.
742
                      b'1' * 32, 12)
6973.11.7 by Jelmer Vernooij
Fix more tests.
743
        self.add_file(new_shape, new_revid, b'file-id-F', b'root-id', 'E',
7143.15.2 by Jelmer Vernooij
Run autopep8.
744
                      b'2' * 32, 24)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
745
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
746
                                              new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
747
748
    def test_adds(self):
749
        # test adding paths and dirs, including adding to a newly added dir.
6973.11.7 by Jelmer Vernooij
Fix more tests.
750
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
751
        basis_shape = Inventory(root_id=None)
752
        # with a root, so its a commit after the first.
6973.11.7 by Jelmer Vernooij
Fix more tests.
753
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
754
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
755
        new_shape = Inventory(root_id=None)
756
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
757
        self.add_dir(new_shape, new_revid, b'dir-id-A', b'root-id', 'A')
758
        self.add_link(new_shape, new_revid, b'link-id-B', b'root-id', 'B', 'C')
759
        self.add_file(new_shape, new_revid, b'file-id-C', b'root-id', 'C',
7143.15.2 by Jelmer Vernooij
Run autopep8.
760
                      b'1' * 32, 12)
6973.11.7 by Jelmer Vernooij
Fix more tests.
761
        self.add_file(new_shape, new_revid, b'file-id-D', b'dir-id-A', 'D',
7143.15.2 by Jelmer Vernooij
Run autopep8.
762
                      b'2' * 32, 24)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
763
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
764
                                              new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
765
766
    def test_removes(self):
767
        # test removing paths, including paths that are within other also
768
        # removed paths.
6973.11.7 by Jelmer Vernooij
Fix more tests.
769
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
770
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
771
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
772
        self.add_dir(basis_shape, old_revid, b'dir-id-A', b'root-id', 'A')
7143.15.2 by Jelmer Vernooij
Run autopep8.
773
        self.add_link(basis_shape, old_revid,
774
                      b'link-id-B', b'root-id', 'B', 'C')
6973.11.7 by Jelmer Vernooij
Fix more tests.
775
        self.add_file(basis_shape, old_revid, b'file-id-C', b'root-id', 'C',
7143.15.2 by Jelmer Vernooij
Run autopep8.
776
                      b'1' * 32, 12)
6973.11.7 by Jelmer Vernooij
Fix more tests.
777
        self.add_file(basis_shape, old_revid, b'file-id-D', b'dir-id-A', 'D',
7143.15.2 by Jelmer Vernooij
Run autopep8.
778
                      b'2' * 32, 24)
6973.11.7 by Jelmer Vernooij
Fix more tests.
779
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
780
        new_shape = Inventory(root_id=None)
781
        self.add_new_root(new_shape, old_revid, new_revid)
782
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
783
                                              new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
784
785
    def test_move_to_added_dir(self):
6973.11.7 by Jelmer Vernooij
Fix more tests.
786
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
787
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
788
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
7143.15.2 by Jelmer Vernooij
Run autopep8.
789
        self.add_link(basis_shape, old_revid,
790
                      b'link-id-B', b'root-id', 'B', 'C')
6973.11.7 by Jelmer Vernooij
Fix more tests.
791
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
792
        new_shape = Inventory(root_id=None)
793
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
794
        self.add_dir(new_shape, new_revid, b'dir-id-A', b'root-id', 'A')
7143.15.2 by Jelmer Vernooij
Run autopep8.
795
        self.add_link(new_shape, new_revid, b'link-id-B',
796
                      b'dir-id-A', 'B', 'C')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
797
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
798
                                              new_shape, new_revid)
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
799
800
    def test_move_from_removed_dir(self):
6973.11.7 by Jelmer Vernooij
Fix more tests.
801
        old_revid = b'old-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
802
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
803
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
804
        self.add_dir(basis_shape, old_revid, b'dir-id-A', b'root-id', 'A')
7143.15.2 by Jelmer Vernooij
Run autopep8.
805
        self.add_link(basis_shape, old_revid,
806
                      b'link-id-B', b'dir-id-A', 'B', 'C')
6973.11.7 by Jelmer Vernooij
Fix more tests.
807
        new_revid = b'new-parent'
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
808
        new_shape = Inventory(root_id=None)
809
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
810
        self.add_link(new_shape, new_revid, b'link-id-B', b'root-id', 'B', 'C')
2865.1.1 by Robert Collins
Create new mutable tree method update_to_one_parent_via_delta for eventual use by commit.
811
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
812
                                              new_shape, new_revid)
2929.2.1 by Robert Collins
* Commit updates the state of the working tree via a delta rather than
813
814
    def test_move_moves_children_recursively(self):
6973.11.7 by Jelmer Vernooij
Fix more tests.
815
        old_revid = b'old-parent'
2929.2.1 by Robert Collins
* Commit updates the state of the working tree via a delta rather than
816
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
817
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
818
        self.add_dir(basis_shape, old_revid, b'dir-id-A', b'root-id', 'A')
819
        self.add_dir(basis_shape, old_revid, b'dir-id-B', b'dir-id-A', 'B')
7143.15.2 by Jelmer Vernooij
Run autopep8.
820
        self.add_link(basis_shape, old_revid,
821
                      b'link-id-C', b'dir-id-B', 'C', 'D')
6973.11.7 by Jelmer Vernooij
Fix more tests.
822
        new_revid = b'new-parent'
2929.2.1 by Robert Collins
* Commit updates the state of the working tree via a delta rather than
823
        new_shape = Inventory(root_id=None)
824
        self.add_new_root(new_shape, old_revid, new_revid)
825
        # the moved path:
6973.11.7 by Jelmer Vernooij
Fix more tests.
826
        self.add_dir(new_shape, new_revid, b'dir-id-A', b'root-id', 'B')
2929.2.1 by Robert Collins
* Commit updates the state of the working tree via a delta rather than
827
        # unmoved children.
6973.11.7 by Jelmer Vernooij
Fix more tests.
828
        self.add_dir(new_shape, old_revid, b'dir-id-B', b'dir-id-A', 'B')
7143.15.2 by Jelmer Vernooij
Run autopep8.
829
        self.add_link(new_shape, old_revid, b'link-id-C',
830
                      b'dir-id-B', 'C', 'D')
2929.2.1 by Robert Collins
* Commit updates the state of the working tree via a delta rather than
831
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
832
                                              new_shape, new_revid)
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
833
834
    def test_add_files_to_empty_directory(self):
6973.11.7 by Jelmer Vernooij
Fix more tests.
835
        old_revid = b'old-parent'
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
836
        basis_shape = Inventory(root_id=None)
6973.11.7 by Jelmer Vernooij
Fix more tests.
837
        self.add_dir(basis_shape, old_revid, b'root-id', None, '')
838
        self.add_dir(basis_shape, old_revid, b'dir-id-A', b'root-id', 'A')
839
        new_revid = b'new-parent'
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
840
        new_shape = Inventory(root_id=None)
841
        self.add_new_root(new_shape, old_revid, new_revid)
6973.11.7 by Jelmer Vernooij
Fix more tests.
842
        self.add_dir(new_shape, old_revid, b'dir-id-A', b'root-id', 'A')
843
        self.add_file(new_shape, new_revid, b'file-id-B', b'dir-id-A', 'B',
7143.15.2 by Jelmer Vernooij
Run autopep8.
844
                      b'1' * 32, 24)
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
845
        self.assertTransitionFromBasisToShape(basis_shape, old_revid,
7143.15.2 by Jelmer Vernooij
Run autopep8.
846
                                              new_shape, new_revid, set_current_inventory=False)