/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: John Arbash Meinel
  • Date: 2007-11-30 23:18:15 UTC
  • mto: This revision was merged to the branch mainline in revision 3072.
  • Revision ID: john@arbash-meinel.com-20071130231815-0r6ce70307kmv28r
Use a Graph.heads() check to determine if the ancestries are compatible.
Whether we should do nothing because source is already ahead,
raise an exception because we have diverged,
or move forward because the new revision is a tip revision.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
18
18
 
30
30
        self.build_tree(['source/dir/', 'source/dir/contents'])
31
31
        source_tree.add(['dir', 'dir/contents'], ['dir-id', 'contents-id'])
32
32
        source_tree.commit('added dir')
33
 
        target_tree.lock_write()
34
 
        self.addCleanup(target_tree.unlock)
35
 
        merge.merge_inner(target_tree.branch, source_tree.basis_tree(),
 
33
        merge.merge_inner(target_tree.branch, source_tree.basis_tree(), 
36
34
                          target_tree.basis_tree(), this_tree=target_tree)
37
35
        self.failUnlessExists('target/dir')
38
36
        self.failUnlessExists('target/dir/contents')
67
65
        tree.commit('add new_file')
68
66
        tree.revert(old_tree=basis_tree)
69
67
        self.failIfExists('tree/new_file')
70
 
 
 
68
        
71
69
        # files should be deleted if their changes came from merges
72
70
        merge_target.merge_from_branch(tree.branch)
73
71
        self.failUnlessExists('merge_target/new_file')
86
84
        tt = transform.TreeTransform(tree)
87
85
        tt.new_file('newfile', tt.root, 'helooo!', 'newfile-id', True)
88
86
        tt.apply()
89
 
        tree.lock_write()
90
 
        try:
91
 
            self.assertTrue(tree.is_executable('newfile-id'))
92
 
            tree.commit('added newfile')
93
 
        finally:
94
 
            tree.unlock()
 
87
        self.assertTrue(tree.is_executable('newfile-id'))
 
88
        tree.commit('added newfile')
95
89
        return tree
96
90
 
97
91
    def test_preserve_execute(self):
102
96
        tt.create_file('Woooorld!', newfile)
103
97
        tt.apply()
104
98
        tree = workingtree.WorkingTree.open('tree')
105
 
        tree.lock_write()
106
 
        self.addCleanup(tree.unlock)
107
99
        self.assertTrue(tree.is_executable('newfile-id'))
108
100
        transform.revert(tree, tree.basis_tree(), None, backups=True)
109
101
        self.assertEqual('helooo!', tree.get_file('newfile-id').read())
115
107
        newfile = tt.trans_id_tree_file_id('newfile-id')
116
108
        tt.set_executability(False, newfile)
117
109
        tt.apply()
118
 
        tree.lock_write()
119
 
        self.addCleanup(tree.unlock)
120
110
        transform.revert(tree, tree.basis_tree(), None)
121
111
        self.assertTrue(tree.is_executable('newfile-id'))
122
112
 
157
147
        self.failUnlessExists('dir/file1')
158
148
        self.failIfExists('dir/file2')
159
149
        self.assertEqual('dir-id', tree.path2id('dir'))
160
 
 
161
 
    def test_revert_root_id_change(self):
162
 
        tree = self.make_branch_and_tree('.')
163
 
        tree.set_root_id('initial-root-id')
164
 
        self.build_tree(['file1'])
165
 
        tree.add(['file1'])
166
 
        tree.commit('first')
167
 
        tree.set_root_id('temp-root-id')
168
 
        self.assertEqual('temp-root-id', tree.get_root_id())
169
 
        tree.revert()
170
 
        self.assertEqual('initial-root-id', tree.get_root_id())