~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_uncommit.py

  • Committer: Aaron Bentley
  • Date: 2007-12-09 23:53:50 UTC
  • mto: This revision was merged to the branch mainline in revision 3133.
  • Revision ID: aaron.bentley@utoronto.ca-20071209235350-qp39yk0xzx7a4f6p
Don't use the base if not cherrypicking

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
 
1
# Copyright (C) 2005, 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
32
32
        wt.add(['a', 'b', 'c'])
33
33
        wt.commit('initial commit', rev_id='a1')
34
34
 
35
 
        self.build_tree_contents([('tree/a', 'new contents of a\n')])
 
35
        open('tree/a', 'wb').write('new contents of a\n')
36
36
        wt.commit('second commit', rev_id='a2')
37
37
 
38
38
        return wt
110
110
        b.pull(t_a.branch)
111
111
        uncommit.uncommit(b)
112
112
 
113
 
    def test_uncommit_bound_local(self):
114
 
        t_a = self.make_branch_and_tree('a')
115
 
        rev_id1 = t_a.commit('commit 1')
116
 
        rev_id2 = t_a.commit('commit 2')
117
 
        rev_id3 = t_a.commit('commit 3')
118
 
        b = t_a.branch.create_checkout('b').branch
119
 
 
120
 
        out, err = self.run_bzr(['uncommit', '--local', 'b', '--force'])
121
 
        self.assertEqual(rev_id3, t_a.last_revision())
122
 
        self.assertEqual((3, rev_id3), t_a.branch.last_revision_info())
123
 
        self.assertEqual((2, rev_id2), b.last_revision_info())
124
 
 
125
113
    def test_uncommit_revision(self):
126
114
        wt = self.create_simple_tree()
127
115
 
173
161
        wt = self.create_simple_tree()
174
162
 
175
163
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
 
164
 
176
165
        tree2.commit('unchanged', rev_id='b3')
177
166
 
178
 
        tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
179
 
        tree3.commit('unchanged', rev_id='c3')
180
 
 
181
167
        wt.merge_from_branch(tree2.branch)
182
168
        wt.commit('merge b3', rev_id='a3')
183
169
 
184
 
        wt.merge_from_branch(tree3.branch)
185
 
        wt.commit('merge c3', rev_id='a4')
 
170
        tree2.commit('unchanged', rev_id='b4')
 
171
 
 
172
        wt.merge_from_branch(tree2.branch)
 
173
        wt.commit('merge b4', rev_id='a4')
186
174
 
187
175
        self.assertEqual(['a4'], wt.get_parent_ids())
188
176
 
189
177
        os.chdir('tree')
190
178
        out, err = self.run_bzr('uncommit --force -r 2')
191
179
 
192
 
        self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
 
180
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
193
181
 
194
182
    def test_uncommit_merge_plus_pending(self):
195
183
        wt = self.create_simple_tree()
196
184
 
197
185
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
 
186
 
198
187
        tree2.commit('unchanged', rev_id='b3')
199
 
        tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
200
 
        tree3.commit('unchanged', rev_id='c3')
201
 
 
202
188
        wt.branch.fetch(tree2.branch)
203
189
        wt.set_pending_merges(['b3'])
204
190
        wt.commit('merge b3', rev_id='a3')
205
191
 
206
 
 
207
 
        wt.merge_from_branch(tree3.branch)
208
 
 
209
 
        self.assertEqual(['a3', 'c3'], wt.get_parent_ids())
 
192
        tree2.commit('unchanged', rev_id='b4')
 
193
        wt.branch.fetch(tree2.branch)
 
194
        wt.set_pending_merges(['b4'])
 
195
 
 
196
        self.assertEqual(['a3', 'b4'], wt.get_parent_ids())
210
197
 
211
198
        os.chdir('tree')
212
199
        out, err = self.run_bzr('uncommit --force -r 2')
213
200
 
214
 
        self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
215
 
 
216
 
    def test_uncommit_shows_log_with_revision_id(self):
217
 
        wt = self.create_simple_tree()
218
 
 
219
 
        out, err = self.run_bzr('uncommit --force', working_dir='tree')
220
 
        self.assertContainsRe(out, r'second commit')
221
 
        self.assertContainsRe(err, r'You can restore the old tip by running')
222
 
        self.assertContainsRe(err, r'bzr pull . -r revid:a2')
 
201
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
223
202
 
224
203
    def test_uncommit_octopus_merge(self):
225
204
        # Check that uncommit keeps the pending merges in the same order
226
 
        # though it will also filter out ones in the ancestry
227
205
        wt = self.create_simple_tree()
228
206
 
229
207
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
231
209
 
232
210
        tree2.commit('unchanged', rev_id='b3')
233
211
        tree3.commit('unchanged', rev_id='c3')
234
 
 
 
212
        
235
213
        wt.merge_from_branch(tree2.branch)
236
214
        wt.merge_from_branch(tree3.branch)
237
215
        wt.commit('merge b3, c3', rev_id='a3')
248
226
        os.chdir('tree')
249
227
        out, err = self.run_bzr('uncommit --force -r 2')
250
228
 
251
 
        self.assertEqual(['a2', 'c4', 'b4'], wt.get_parent_ids())
252
 
 
253
 
    def test_uncommit_nonascii(self):
254
 
        tree = self.make_branch_and_tree('tree')
255
 
        tree.commit(u'\u1234 message')
256
 
        out, err = self.run_bzr('uncommit --force tree', encoding='ascii')
257
 
        self.assertContainsRe(out, r'\? message')
 
229
        self.assertEqual(['a2', 'b3', 'c3', 'c4', 'b4'], wt.get_parent_ids())