~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/whitebox.py

[merge] robert's integration branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
from bzrlib.selftest import TestCaseInTempDir, TestCase
5
5
from bzrlib.branch import ScratchBranch, Branch
6
 
from bzrlib.errors import NotBranchError, NotVersionedError
 
6
from bzrlib.errors import NotBranchError
7
7
 
8
8
 
9
9
class TestBranch(TestCaseInTempDir):
25
25
        self.build_tree(['hello.txt'])
26
26
 
27
27
        self.assertRaises(PointlessCommit,
28
 
                          b.commit,
 
28
                          b.working_tree().commit,
29
29
                          'commit without adding',
30
30
                          allow_pointless=False)
31
31
 
32
 
        b.commit('commit pointless tree',
 
32
        b.working_tree().commit('commit pointless tree',
33
33
                 allow_pointless=True)
34
34
 
35
35
        b.add('hello.txt')
36
36
        
37
 
        b.commit('commit first added file',
 
37
        b.working_tree().commit('commit first added file',
38
38
                 allow_pointless=False)
39
39
        
40
40
        self.assertRaises(PointlessCommit,
41
 
                          b.commit,
 
41
                          b.working_tree().commit,
42
42
                          'commit after adding file',
43
43
                          allow_pointless=False)
44
44
        
45
 
        b.commit('commit pointless revision with one file',
 
45
        b.working_tree().commit('commit pointless revision with one file',
46
46
                 allow_pointless=True)
47
47
 
48
48
 
49
49
class MoreTests(TestCaseInTempDir):
50
50
 
51
 
    def test_revert(self):
52
 
        """Test selected-file revert"""
53
 
        b = Branch.initialize('.')
54
 
 
55
 
        self.build_tree(['hello.txt'])
56
 
        file('hello.txt', 'w').write('initial hello')
57
 
 
58
 
        self.assertRaises(NotVersionedError,
59
 
                          b.revert, ['hello.txt'])
60
 
        
61
 
        b.add(['hello.txt'])
62
 
        b.commit('create initial hello.txt')
63
 
 
64
 
        self.check_file_contents('hello.txt', 'initial hello')
65
 
        file('hello.txt', 'w').write('new hello')
66
 
        self.check_file_contents('hello.txt', 'new hello')
67
 
 
68
 
        # revert file modified since last revision
69
 
        b.revert(['hello.txt'])
70
 
        self.check_file_contents('hello.txt', 'initial hello')
71
 
        self.check_file_contents('hello.txt~', 'new hello')
72
 
 
73
 
        # reverting again clobbers the backup
74
 
        b.revert(['hello.txt'])
75
 
        self.check_file_contents('hello.txt', 'initial hello')
76
 
        self.check_file_contents('hello.txt~', 'initial hello')
77
 
 
78
51
    def test_rename_dirs(self):
79
52
        """Test renaming directories and the files within them."""
80
53
        b = Branch.initialize('.')
81
54
        self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file'])
82
55
        b.add(['dir', 'dir/sub', 'dir/sub/file'])
83
56
 
84
 
        b.commit('create initial state')
 
57
        b.working_tree().commit('create initial state')
85
58
 
86
59
        # TODO: lift out to a test helper that checks the shape of
87
60
        # an inventory
97
70
 
98
71
        b.rename_one('dir', 'newdir')
99
72
 
100
 
        self.check_inventory_shape(b.inventory,
 
73
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
101
74
                                   ['newdir', 'newdir/sub', 'newdir/sub/file'])
102
75
 
103
76
        b.rename_one('newdir/sub', 'newdir/newsub')
104
 
        self.check_inventory_shape(b.inventory,
 
77
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
105
78
                                   ['newdir', 'newdir/newsub',
106
79
                                    'newdir/newsub/file'])
107
80