/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

Ensure Format4 working trees start with a dirstate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
# test all change permutations in one and two parents.
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
# Test get state from a file, then asking for lines.
29
30
 
30
31
class TestTreeToDirstate(TestCaseWithTransport):
31
32
 
180
181
            '\x00\x00a file\x00f\x00a file id\x0012\x00[0-9a-zA-Z+/]{32}\x008b787bd9293c8b962c7a637a9fdbf627fe68610e\x00%s\x00f\x00\x00a file\x0024\x00n\x00c3ed76e4bfd45ff1763ca206055bca8e9fc28aa8\x00%s\x00f\x00\x00a file\x0014\x00n\x00314d796174c9412647c3ce07dfb5d36a94e72958\x00\n'
181
182
            '\x00$') % (rev_id.encode('utf8'), rev_id2.encode('utf8'))
182
183
        self.assertContainsRe(''.join(lines), expected_lines_re)
 
184
 
 
185
 
 
186
class TestDirStateOnFile(TestCaseWithTransport):
 
187
 
 
188
    def test_construct_with_path(self):
 
189
        tree = self.make_branch_and_tree('tree')
 
190
        state = dirstate.DirState.from_tree(tree)
 
191
        # we want to be able to get the lines of the dirstate that we will
 
192
        # write to disk.
 
193
        lines = state.get_lines()
 
194
        self.build_tree_contents([('dirstate', ''.join(lines))])
 
195
        # get a state object
 
196
        state = dirstate.DirState.on_file('dirstate')
 
197
        # ask it for a parents list
 
198
        self.assertEqual([], state.get_parent_ids())
 
199
 
 
200
 
 
201
class TestDirStateInitialize(TestCaseWithTransport):
 
202
 
 
203
    def test_initialize(self):
 
204
        state = dirstate.DirState.initialize('dirstate')
 
205
        self.assertIsInstance(state, dirstate.DirState)
 
206
        self.assertFileEqual(
 
207
            '#bzr dirstate flat format 1\n'
 
208
            'adler32: 14155835\n'
 
209
            'num_entries: 0\n'
 
210
            '0\x00\n'
 
211
            '\x00',
 
212
            'dirstate')