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