~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2008-09-26 22:14:42 UTC
  • mto: This revision was merged to the branch mainline in revision 3747.
  • Revision ID: john@arbash-meinel.com-20080926221442-3r67j99sr9rwe9w0
Make message optional, don't check the memory flag directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008 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
 
        open('tree/a', 'wb').write('new contents of a\n')
 
35
        self.build_tree_contents([('tree/a', 'new contents of a\n')])
36
36
        wt.commit('second commit', rev_id='a2')
37
37
 
38
38
        return wt
60
60
        out, err = self.run_bzr('status')
61
61
        self.assertEquals(out, 'modified:\n  a\n')
62
62
 
 
63
    def test_uncommit_no_history(self):
 
64
        wt = self.make_branch_and_tree('tree')
 
65
        out, err = self.run_bzr('uncommit --force', retcode=1)
 
66
        self.assertEqual('', err)
 
67
        self.assertEqual('No revisions to uncommit.\n', out)
 
68
 
63
69
    def test_uncommit_checkout(self):
64
70
        wt = self.create_simple_tree()
65
71
        checkout_tree = wt.branch.create_checkout('checkout')
104
110
        b.pull(t_a.branch)
105
111
        uncommit.uncommit(b)
106
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
 
107
125
    def test_uncommit_revision(self):
108
126
        wt = self.create_simple_tree()
109
127
 
155
173
        wt = self.create_simple_tree()
156
174
 
157
175
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
158
 
 
159
176
        tree2.commit('unchanged', rev_id='b3')
160
177
 
 
178
        tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
 
179
        tree3.commit('unchanged', rev_id='c3')
 
180
 
161
181
        wt.merge_from_branch(tree2.branch)
162
182
        wt.commit('merge b3', rev_id='a3')
163
183
 
164
 
        tree2.commit('unchanged', rev_id='b4')
165
 
 
166
 
        wt.merge_from_branch(tree2.branch)
167
 
        wt.commit('merge b4', rev_id='a4')
 
184
        wt.merge_from_branch(tree3.branch)
 
185
        wt.commit('merge c3', rev_id='a4')
168
186
 
169
187
        self.assertEqual(['a4'], wt.get_parent_ids())
170
188
 
171
189
        os.chdir('tree')
172
190
        out, err = self.run_bzr('uncommit --force -r 2')
173
191
 
174
 
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
 
192
        self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
175
193
 
176
194
    def test_uncommit_merge_plus_pending(self):
177
195
        wt = self.create_simple_tree()
178
196
 
179
197
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
180
 
 
181
198
        tree2.commit('unchanged', rev_id='b3')
 
199
        tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
 
200
        tree3.commit('unchanged', rev_id='c3')
 
201
 
182
202
        wt.branch.fetch(tree2.branch)
183
203
        wt.set_pending_merges(['b3'])
184
204
        wt.commit('merge b3', rev_id='a3')
185
205
 
186
 
        tree2.commit('unchanged', rev_id='b4')
187
 
        wt.branch.fetch(tree2.branch)
188
 
        wt.set_pending_merges(['b4'])
189
 
 
190
 
        self.assertEqual(['a3', 'b4'], wt.get_parent_ids())
 
206
 
 
207
        wt.merge_from_branch(tree3.branch)
 
208
 
 
209
        self.assertEqual(['a3', 'c3'], wt.get_parent_ids())
191
210
 
192
211
        os.chdir('tree')
193
212
        out, err = self.run_bzr('uncommit --force -r 2')
194
213
 
195
 
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
 
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')
196
223
 
197
224
    def test_uncommit_octopus_merge(self):
198
225
        # Check that uncommit keeps the pending merges in the same order
 
226
        # though it will also filter out ones in the ancestry
199
227
        wt = self.create_simple_tree()
200
228
 
201
229
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
203
231
 
204
232
        tree2.commit('unchanged', rev_id='b3')
205
233
        tree3.commit('unchanged', rev_id='c3')
206
 
        
 
234
 
207
235
        wt.merge_from_branch(tree2.branch)
208
236
        wt.merge_from_branch(tree3.branch)
209
237
        wt.commit('merge b3, c3', rev_id='a3')
220
248
        os.chdir('tree')
221
249
        out, err = self.run_bzr('uncommit --force -r 2')
222
250
 
223
 
        self.assertEqual(['a2', 'b3', 'c3', 'c4', 'b4'], wt.get_parent_ids())
 
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')