/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

Get DirState objects roundtripping an add of a ghost tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
# i.e. file in parent 1, dir in parent 2, symlink in tree.
28
28
# test that renames in the tree result in correct parent paths 
29
29
# Test get state from a file, then asking for lines.
 
30
# write a smaller state, and check the file has been truncated.
 
31
# add a entry when its in state deleted
30
32
 
31
33
class TestTreeToDirstate(TestCaseWithTransport):
32
34
 
72
74
        rev_id = tree.commit('first post')
73
75
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
74
76
        tree2.commit('second post', allow_pointless=True)
75
 
        self.merge(tree2.branch, tree)
 
77
        tree.merge_from_branch(tree2.branch)
76
78
        state = dirstate.DirState.from_tree(tree)
77
79
        # we want to be able to get the lines of the dirstate that we will
78
80
        # write to disk.
162
164
        # and length:
163
165
        self.build_tree_contents([('tree2/a file', 'merge content\n')])
164
166
        rev_id2 = tree2.commit('second post')
165
 
        self.merge(tree2.branch, tree)
 
167
        tree.merge_from_branch(tree2.branch)
166
168
        # change the current content to be different this will alter stat, sha
167
169
        # and length again, giving us three distinct values:
168
170
        self.build_tree_contents([('tree/a file', 'new content\n')])
210
212
            '0\x00\n'
211
213
            '\x00',
212
214
            'dirstate')
 
215
 
 
216
 
 
217
class TestDirstateManipulations(TestCaseWithTransport):
 
218
 
 
219
    def test_add_ghost_tree(self):
 
220
        state = dirstate.DirState.initialize('dirstate')
 
221
        state.add_parent_tree('a-ghost', None)
 
222
        # now the parent list should be changed:
 
223
        self.assertEqual(['a-ghost'], state.get_parent_ids())
 
224
        # save the state and reopen to check its persistent
 
225
        state.save()
 
226
        state = dirstate.DirState.on_file('dirstate')
 
227
        self.assertEqual(['a-ghost'], state.get_parent_ids())
 
228
 
 
229
 
 
230
class TestGetLines(TestCaseWithTransport):
 
231
 
 
232
    def test_adding_tree_changes_lines(self):
 
233
        state = dirstate.DirState.initialize('dirstate')
 
234
        lines = list(state.get_lines())
 
235
        state.add_parent_tree('a-ghost', None)
 
236
        self.assertNotEqual(lines, state.get_lines())