/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revert.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import os
18
18
 
19
 
from breezy import merge, tests, transform, workingtree
 
19
from bzrlib import merge, tests, transform, workingtree
20
20
 
21
21
 
22
22
class TestRevert(tests.TestCaseWithTransport):
26
26
        """Reverting a merge that adds a directory deletes the directory"""
27
27
        source_tree = self.make_branch_and_tree('source')
28
28
        source_tree.commit('empty tree')
29
 
        target_tree = source_tree.controldir.sprout('target').open_workingtree()
 
29
        target_tree = source_tree.bzrdir.sprout('target').open_workingtree()
30
30
        self.build_tree(['source/dir/', 'source/dir/contents'])
31
 
        source_tree.add(['dir', 'dir/contents'], [b'dir-id', b'contents-id'])
 
31
        source_tree.add(['dir', 'dir/contents'], ['dir-id', 'contents-id'])
32
32
        source_tree.commit('added dir')
33
33
        target_tree.lock_write()
34
34
        self.addCleanup(target_tree.unlock)
53
53
        """
54
54
        tree = self.make_branch_and_tree('tree')
55
55
        tree.commit('empty tree')
56
 
        merge_target = tree.controldir.sprout('merge_target').open_workingtree()
 
56
        merge_target = tree.bzrdir.sprout('merge_target').open_workingtree()
57
57
        self.build_tree(['tree/new_file'])
58
58
 
59
59
        # newly-added files should not be deleted
77
77
        # files should not be deleted if changed after a merge
78
78
        merge_target.merge_from_branch(tree.branch)
79
79
        self.assertPathExists('merge_target/new_file')
80
 
        self.build_tree_contents([('merge_target/new_file', b'new_contents')])
 
80
        self.build_tree_contents([('merge_target/new_file', 'new_contents')])
81
81
        merge_target.revert()
82
82
        self.assertPathExists('merge_target/new_file')
83
83
 
88
88
        tt.apply()
89
89
        tree.lock_write()
90
90
        try:
91
 
            self.assertTrue(tree.is_executable('newfile'))
 
91
            self.assertTrue(tree.is_executable('newfile-id'))
92
92
            tree.commit('added newfile')
93
93
        finally:
94
94
            tree.unlock()
97
97
    def test_preserve_execute(self):
98
98
        tree = self.tree_with_executable()
99
99
        tt = transform.TreeTransform(tree)
100
 
        newfile = tt.trans_id_tree_path('newfile')
 
100
        newfile = tt.trans_id_tree_file_id('newfile-id')
101
101
        tt.delete_contents(newfile)
102
102
        tt.create_file('Woooorld!', newfile)
103
103
        tt.apply()
104
104
        tree = workingtree.WorkingTree.open('tree')
105
105
        tree.lock_write()
106
106
        self.addCleanup(tree.unlock)
107
 
        self.assertTrue(tree.is_executable('newfile'))
 
107
        self.assertTrue(tree.is_executable('newfile-id'))
108
108
        transform.revert(tree, tree.basis_tree(), None, backups=True)
109
 
        self.assertEqual('helooo!', tree.get_file('newfile').read())
110
 
        self.assertTrue(tree.is_executable('newfile'))
 
109
        self.assertEqual('helooo!', tree.get_file('newfile-id').read())
 
110
        self.assertTrue(tree.is_executable('newfile-id'))
111
111
 
112
112
    def test_revert_executable(self):
113
113
        tree = self.tree_with_executable()
114
114
        tt = transform.TreeTransform(tree)
115
 
        newfile = tt.trans_id_tree_path('newfile')
 
115
        newfile = tt.trans_id_tree_file_id('newfile-id')
116
116
        tt.set_executability(False, newfile)
117
117
        tt.apply()
118
118
        tree.lock_write()
119
119
        self.addCleanup(tree.unlock)
120
120
        transform.revert(tree, tree.basis_tree(), None)
121
 
        self.assertTrue(tree.is_executable('newfile'))
 
121
        self.assertTrue(tree.is_executable('newfile-id'))
122
122
 
123
123
    def test_revert_deletes_files_from_revert(self):
124
124
        tree = self.make_branch_and_tree('.')
125
125
        self.build_tree(['file'])
126
126
        tree.add('file')
127
 
        tree.commit('added file', rev_id=b'rev1')
 
127
        tree.commit('added file', rev_id='rev1')
128
128
        os.unlink('file')
129
129
        tree.commit('removed file')
130
130
        self.assertPathDoesNotExist('file')
151
151
 
152
152
    def test_revert_root_id_change(self):
153
153
        tree = self.make_branch_and_tree('.')
154
 
        tree.set_root_id(b'initial-root-id')
 
154
        tree.set_root_id('initial-root-id')
155
155
        self.build_tree(['file1'])
156
156
        tree.add(['file1'])
157
157
        tree.commit('first')
158
 
        tree.set_root_id(b'temp-root-id')
 
158
        tree.set_root_id('temp-root-id')
159
159
        self.assertEqual('temp-root-id', tree.get_root_id())
160
160
        tree.revert()
161
161
        self.assertEqual('initial-root-id', tree.get_root_id())