36
36
target_tree.revert([])
37
37
self.failIfExists('target/dir/contents')
38
38
self.failIfExists('target/dir')
40
def test_revert_new(self):
41
"""Only locally-changed new files should be preserved when reverting
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
46
If a file has local changes, revert should unversion it, but not
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.
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'])
56
# newly-added files should not be deleted
58
basis_tree = tree.basis_tree()
60
self.failUnlessExists('tree/new_file')
62
# unchanged files should be deleted
64
tree.commit('add new_file')
65
tree.revert([], old_tree=basis_tree)
66
self.failIfExists('tree/new_file')
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')
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')