~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revert.py

(gz) Fix test failure on alpha by correcting format string for
 gc_chk_sha1_record (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        self.addCleanup(target_tree.unlock)
35
35
        merge.merge_inner(target_tree.branch, source_tree.basis_tree(),
36
36
                          target_tree.basis_tree(), this_tree=target_tree)
37
 
        self.assertPathExists('target/dir')
38
 
        self.assertPathExists('target/dir/contents')
 
37
        self.failUnlessExists('target/dir')
 
38
        self.failUnlessExists('target/dir/contents')
39
39
        target_tree.revert()
40
 
        self.assertPathDoesNotExist('target/dir/contents')
41
 
        self.assertPathDoesNotExist('target/dir')
 
40
        self.failIfExists('target/dir/contents')
 
41
        self.failIfExists('target/dir')
42
42
 
43
43
    def test_revert_new(self):
44
44
        """Only locally-changed new files should be preserved when reverting
60
60
        tree.add('new_file')
61
61
        basis_tree = tree.branch.repository.revision_tree(tree.last_revision())
62
62
        tree.revert()
63
 
        self.assertPathExists('tree/new_file')
 
63
        self.failUnlessExists('tree/new_file')
64
64
 
65
65
        # unchanged files should be deleted
66
66
        tree.add('new_file')
67
67
        tree.commit('add new_file')
68
68
        tree.revert(old_tree=basis_tree)
69
 
        self.assertPathDoesNotExist('tree/new_file')
 
69
        self.failIfExists('tree/new_file')
70
70
 
71
71
        # files should be deleted if their changes came from merges
72
72
        merge_target.merge_from_branch(tree.branch)
73
 
        self.assertPathExists('merge_target/new_file')
 
73
        self.failUnlessExists('merge_target/new_file')
74
74
        merge_target.revert()
75
 
        self.assertPathDoesNotExist('merge_target/new_file')
 
75
        self.failIfExists('merge_target/new_file')
76
76
 
77
77
        # files should not be deleted if changed after a merge
78
78
        merge_target.merge_from_branch(tree.branch)
79
 
        self.assertPathExists('merge_target/new_file')
 
79
        self.failUnlessExists('merge_target/new_file')
80
80
        self.build_tree_contents([('merge_target/new_file', 'new_contents')])
81
81
        merge_target.revert()
82
 
        self.assertPathExists('merge_target/new_file')
 
82
        self.failUnlessExists('merge_target/new_file')
83
83
 
84
84
    def tree_with_executable(self):
85
85
        tree = self.make_branch_and_tree('tree')
127
127
        tree.commit('added file', rev_id='rev1')
128
128
        os.unlink('file')
129
129
        tree.commit('removed file')
130
 
        self.assertPathDoesNotExist('file')
 
130
        self.failIfExists('file')
131
131
        tree.revert(old_tree=tree.branch.repository.revision_tree('rev1'))
132
 
        self.assertPathExists('file')
 
132
        self.failUnlessExists('file')
133
133
        tree.revert()
134
 
        self.assertPathDoesNotExist('file')
 
134
        self.failIfExists('file')
135
135
        self.assertEqual({}, tree.merge_modified())
136
136
 
 
137
    def test_empty_deprecated(self):
 
138
        tree = self.make_branch_and_tree('.')
 
139
        self.build_tree(['file'])
 
140
        tree.add('file')
 
141
        self.callDeprecated(['Using [] to revert all files is deprecated'
 
142
            ' as of bzr 0.91.  Please use None (the default) instead.'],
 
143
            tree.revert, [])
 
144
        self.assertIs(None, tree.path2id('file'))
 
145
 
137
146
    def test_revert_file_in_deleted_dir(self):
138
147
        tree = self.make_branch_and_tree('.')
139
148
        self.build_tree(['dir/', 'dir/file1', 'dir/file2'])
145
154
        os.rmdir('dir')
146
155
        tree.remove(['dir/', 'dir/file1', 'dir/file2'])
147
156
        tree.revert(['dir/file1'])
148
 
        self.assertPathExists('dir/file1')
149
 
        self.assertPathDoesNotExist('dir/file2')
 
157
        self.failUnlessExists('dir/file1')
 
158
        self.failIfExists('dir/file2')
150
159
        self.assertEqual('dir-id', tree.path2id('dir'))
151
160
 
152
161
    def test_revert_root_id_change(self):