~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

Added symlink support

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
from bzrlib.transform import TreeTransform
4
4
from bzrlib.errors import DuplicateKey, MalformedTransform, NoSuchFile
5
5
from bzrlib.osutils import file_kind
 
6
import os
6
7
 
7
8
class TestTreeTransform(TestCaseInTempDir):
8
9
    def test_build(self):
32
33
            oz_id = transform.create_path('oz', root)
33
34
            transform.create_directory(oz_id)
34
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)
35
39
            transform.apply()
36
40
            self.assertEqual('contents', file('name').read())
37
41
            self.assertEqual(wt.path2id('name'), 'my_pretties')
38
42
            self.assertEqual('directory', file_kind('oz'))
 
43
            self.assertEqual(file_kind('oz/wizard'), 'symlink')
 
44
            self.assertEqual(os.readlink('oz/wizard'), 'behind_curtain')
39
45
        finally:
40
46
            transform.finalize()
41
47
        # is it safe to finalize repeatedly?
53
59
            dorothy = transform.new_directory('dorothy', oz, 'dorothy-id')
54
60
            toto = transform.new_file('toto', dorothy, 'toto-contents', 
55
61
                                      'toto-id')
 
62
            wizard = transform.new_symlink('wizard', oz, 'wizard-target', 
 
63
                                           'wizard-id')
56
64
            transform.apply()
57
65
            self.assertEqual(len(transform.find_conflicts()), 0)
58
66
            self.assertEqual('contents', file('name').read())
60
68
            self.assertEqual(wt.path2id('oz'), 'oz-id')
61
69
            self.assertEqual(wt.path2id('oz/dorothy'), 'dorothy-id')
62
70
            self.assertEqual(wt.path2id('oz/dorothy/toto'), 'toto-id')
 
71
            self.assertEqual(wt.path2id('oz/wizard'), 'wizard-id')
63
72
            self.assertEqual('toto-contents', file('oz/dorothy/toto').read())
 
73
            self.assertEqual(os.readlink('oz/wizard'), 'wizard-target')
64
74
        finally:
65
75
            transform.finalize()
66
76