~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

Added directory handling

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
from bzrlib.branch import Branch
3
3
from bzrlib.transform import TreeTransform
4
4
from bzrlib.errors import DuplicateKey, MalformedTransform, NoSuchFile
 
5
from bzrlib.osutils import file_kind
5
6
 
6
7
class TestTreeTransform(TestCaseInTempDir):
7
8
    def test_build(self):
28
29
            self.assertEqual(transform.final_file_id(trans_id), 'my_pretties')
29
30
            self.assertEqual(transform.final_parent(trans_id), root)
30
31
            self.assertIs(transform.final_parent(root), None)
 
32
            oz_id = transform.create_path('oz', root)
 
33
            transform.create_directory(oz_id)
 
34
            transform.version_file('ozzie', oz_id)
31
35
            transform.apply()
32
36
            self.assertEqual('contents', file('name').read())
33
37
            self.assertEqual(wt.path2id('name'), 'my_pretties')
 
38
            self.assertEqual('directory', file_kind('oz'))
34
39
        finally:
35
40
            transform.finalize()
36
41
        # is it safe to finalize repeatedly?
44
49
            root = transform.get_id_tree(wt.get_root_id())
45
50
            trans_id = transform.new_file('name', root, 'contents', 
46
51
                                          'my_pretties')
 
52
            oz = transform.new_directory('oz', root, 'oz-id')
 
53
            dorothy = transform.new_directory('dorothy', oz, 'dorothy-id')
 
54
            toto = transform.new_file('toto', dorothy, 'toto-contents', 
 
55
                                      'toto-id')
47
56
            transform.apply()
48
57
            self.assertEqual(len(transform.find_conflicts()), 0)
49
58
            self.assertEqual('contents', file('name').read())
50
59
            self.assertEqual(wt.path2id('name'), 'my_pretties')
 
60
            self.assertEqual(wt.path2id('oz'), 'oz-id')
 
61
            self.assertEqual(wt.path2id('oz/dorothy'), 'dorothy-id')
 
62
            self.assertEqual(wt.path2id('oz/dorothy/toto'), 'toto-id')
 
63
            self.assertEqual('toto-contents', file('oz/dorothy/toto').read())
51
64
        finally:
52
65
            transform.finalize()
53
66