~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Ian Clatworthy
  • Date: 2008-04-01 04:19:06 UTC
  • mfrom: (3302.6.1 xma-mailmode)
  • mto: This revision was merged to the branch mainline in revision 3323.
  • Revision ID: ian.clatworthy@canonical.com-20080401041906-s7ekpfpo0tnyfkbz
Add mail-mode GNU Emacs mail package as a mail client option (Xavier Maillard)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
"""Test the uncommit command."""
18
18
 
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
103
103
        uncommit.uncommit(b)
104
104
        self.assertEqual(len(b.revision_history()), 2)
105
105
        self.assertEqual(len(t_a.branch.revision_history()), 2)
106
 
        # update A's tree to not have the uncommitted revision referenced.
 
106
        # update A's tree to not have the uncomitted revision referenced.
107
107
        t_a.update()
108
108
        t_a.commit('commit 3b')
109
109
        self.assertRaises(BoundBranchOutOfDate, uncommit.uncommit, b)
173
173
        wt = self.create_simple_tree()
174
174
 
175
175
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
 
176
 
176
177
        tree2.commit('unchanged', rev_id='b3')
177
178
 
178
 
        tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
179
 
        tree3.commit('unchanged', rev_id='c3')
180
 
 
181
179
        wt.merge_from_branch(tree2.branch)
182
180
        wt.commit('merge b3', rev_id='a3')
183
181
 
184
 
        wt.merge_from_branch(tree3.branch)
185
 
        wt.commit('merge c3', rev_id='a4')
 
182
        tree2.commit('unchanged', rev_id='b4')
 
183
 
 
184
        wt.merge_from_branch(tree2.branch)
 
185
        wt.commit('merge b4', rev_id='a4')
186
186
 
187
187
        self.assertEqual(['a4'], wt.get_parent_ids())
188
188
 
189
189
        os.chdir('tree')
190
190
        out, err = self.run_bzr('uncommit --force -r 2')
191
191
 
192
 
        self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
 
192
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
193
193
 
194
194
    def test_uncommit_merge_plus_pending(self):
195
195
        wt = self.create_simple_tree()
196
196
 
197
197
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
 
198
 
198
199
        tree2.commit('unchanged', rev_id='b3')
199
 
        tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
200
 
        tree3.commit('unchanged', rev_id='c3')
201
 
 
202
200
        wt.branch.fetch(tree2.branch)
203
201
        wt.set_pending_merges(['b3'])
204
202
        wt.commit('merge b3', rev_id='a3')
205
203
 
206
 
 
207
 
        wt.merge_from_branch(tree3.branch)
208
 
 
209
 
        self.assertEqual(['a3', 'c3'], wt.get_parent_ids())
 
204
        tree2.commit('unchanged', rev_id='b4')
 
205
        wt.branch.fetch(tree2.branch)
 
206
        wt.set_pending_merges(['b4'])
 
207
 
 
208
        self.assertEqual(['a3', 'b4'], wt.get_parent_ids())
210
209
 
211
210
        os.chdir('tree')
212
211
        out, err = self.run_bzr('uncommit --force -r 2')
213
212
 
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')
 
213
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
223
214
 
224
215
    def test_uncommit_octopus_merge(self):
225
216
        # Check that uncommit keeps the pending merges in the same order
226
 
        # though it will also filter out ones in the ancestry
227
217
        wt = self.create_simple_tree()
228
218
 
229
219
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
231
221
 
232
222
        tree2.commit('unchanged', rev_id='b3')
233
223
        tree3.commit('unchanged', rev_id='c3')
234
 
 
 
224
        
235
225
        wt.merge_from_branch(tree2.branch)
236
226
        wt.merge_from_branch(tree3.branch)
237
227
        wt.commit('merge b3, c3', rev_id='a3')
248
238
        os.chdir('tree')
249
239
        out, err = self.run_bzr('uncommit --force -r 2')
250
240
 
251
 
        self.assertEqual(['a2', 'c4', 'b4'], wt.get_parent_ids())
 
241
        self.assertEqual(['a2', 'b3', 'c3', 'c4', 'b4'], wt.get_parent_ids())
252
242
 
253
243
    def test_uncommit_nonascii(self):
254
244
        tree = self.make_branch_and_tree('tree')