~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

Fixed some Windows bugs, introduced a conflicts bug

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
            oz_id = transform.create_path('oz', root)
34
34
            transform.create_directory(oz_id)
35
35
            transform.version_file('ozzie', oz_id)
36
 
            wiz_id = transform.create_path('wizard', oz_id)
37
 
            transform.create_symlink('behind_curtain', wiz_id)
38
 
            transform.version_file('wiz-id', wiz_id)
39
36
            trans_id2 = transform.create_path('name2', root)
40
37
            transform.create_file('contents', trans_id2)
41
38
            transform.set_executability(False, trans_id2)
46
43
            self.assertIs(wt.is_executable('my_pretties'), True)
47
44
            self.assertIs(wt.is_executable('my_pretties2'), False)
48
45
            self.assertEqual('directory', file_kind('oz'))
49
 
            self.assertEqual(file_kind('oz/wizard'), 'symlink')
50
 
            self.assertEqual(os.readlink('oz/wizard'), 'behind_curtain')
51
46
        finally:
52
47
            transform.finalize()
53
48
        # is it safe to finalize repeatedly?
65
60
            dorothy = transform.new_directory('dorothy', oz, 'dorothy-id')
66
61
            toto = transform.new_file('toto', dorothy, 'toto-contents', 
67
62
                                      'toto-id', False)
68
 
            wizard = transform.new_symlink('wizard', oz, 'wizard-target', 
69
 
                                           'wizard-id')
 
63
 
70
64
            self.assertEqual(len(transform.find_conflicts()), 0)
71
65
            transform.apply()
72
66
            self.assertRaises(ReusingTransform, transform.find_conflicts)
76
70
            self.assertEqual(wt.path2id('oz'), 'oz-id')
77
71
            self.assertEqual(wt.path2id('oz/dorothy'), 'dorothy-id')
78
72
            self.assertEqual(wt.path2id('oz/dorothy/toto'), 'toto-id')
79
 
            self.assertEqual(wt.path2id('oz/wizard'), 'wizard-id')
 
73
 
80
74
            self.assertEqual('toto-contents', file('oz/dorothy/toto').read())
81
75
            self.assertIs(wt.is_executable('toto-id'), False)
82
 
            self.assertEqual(os.readlink('oz/wizard'), 'wizard-target')
83
76
        finally:
84
77
            transform.finalize()
85
78
 
141
134
            transform.apply()
142
135
        finally:
143
136
            transform.finalize()
144
 
            self.assertEqual('contents', file('name').read())
145
137
            self.assertEqual(wt.path2id('name'), 'my_pretties')
 
138
            self.assertEqual('contents', file(wt.abspath('name')).read())
146
139
        transform2 = TreeTransform(wt)
147
140
        try:
148
141
            oz_id = transform2.get_id_tree('oz-id')
226
219
        self.assertEqual(wt.path2id('dying_directory'), 'ddir')
227
220
        self.assertIs(wt.path2id('dying_directory/dying_file'), None)
228
221
        mfile2_path = wt.abspath(os.path.join('new_directory','mfile2'))
 
222
 
 
223
    def test_symlinks(self):
 
224
        if not getattr(os, 'symlink', False):
 
225
            return
 
226
        branch = Branch.initialize('.')
 
227
        wt = branch.working_tree()
 
228
        transform = TreeTransform(wt)
 
229
        try:
 
230
            root = transform.get_id_tree(wt.get_root_id())
 
231
            oz_id = transform.new_directory('oz', root)
 
232
            wizard = transform.new_symlink('wizard', oz, 'wizard-target', 
 
233
                                           'wizard-id')
 
234
            wiz_id = transform.create_path('wizard2', oz_id)
 
235
            transform.create_symlink('behind_curtain', wiz_id)
 
236
            transform.version_file('wiz-id2', wiz_id)            
 
237
            self.assertEqual(wt.path2id('oz/wizard'), 'wizard-id')
 
238
            transform.apply()
 
239
            self.assertEqual(file_kind('oz/wizard'), 'symlink')
 
240
            self.assertEqual(os.readlink('oz/wizard'), 'behind_curtain')
 
241
            self.assertEqual(os.readlink('oz/wizard2'), 'wizard-target')
 
242
        finally:
 
243
            transform.finalize()