~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revert.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        target_tree.revert([])
37
37
        self.failIfExists('target/dir/contents')
38
38
        self.failIfExists('target/dir')
 
39
 
 
40
    def test_revert_new(self):
 
41
        """Only locally-changed new files should be preserved when reverting
 
42
 
 
43
        When a file isn't present in revert's target tree:
 
44
        If a file hasn't been committed, revert should unversion it, but not
 
45
        delete it.
 
46
        If a file has local changes, revert should unversion it, but not
 
47
        delete it.
 
48
        If a file has no changes from the last commit, revert should delete it.
 
49
        If a file has changes due to a merge, revert should delete it.
 
50
        """
 
51
        tree = self.make_branch_and_tree('tree')
 
52
        tree.commit('empty tree')
 
53
        merge_target = tree.bzrdir.sprout('merge_target').open_workingtree()
 
54
        self.build_tree(['tree/new_file'])
 
55
 
 
56
        # newly-added files should not be deleted
 
57
        tree.add('new_file')
 
58
        basis_tree = tree.basis_tree()
 
59
        tree.revert([])
 
60
        self.failUnlessExists('tree/new_file')
 
61
 
 
62
        # unchanged files should be deleted
 
63
        tree.add('new_file')
 
64
        tree.commit('add new_file')
 
65
        tree.revert([], old_tree=basis_tree)
 
66
        self.failIfExists('tree/new_file')
 
67
        
 
68
        # files should be deleted if their changes came from merges
 
69
        merge_target.merge_from_branch(tree.branch)
 
70
        self.failUnlessExists('merge_target/new_file')
 
71
        merge_target.revert([])
 
72
        self.failIfExists('merge_target/new_file')
 
73
 
 
74
        # files should not be deleted if changed after a merge
 
75
        merge_target.merge_from_branch(tree.branch)
 
76
        self.failUnlessExists('merge_target/new_file')
 
77
        self.build_tree_contents([('merge_target/new_file', 'new_contents')])
 
78
        merge_target.revert([])
 
79
        self.failUnlessExists('merge_target/new_file')