~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2007-11-24 14:20:59 UTC
  • mto: (3928.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3929.
  • Revision ID: v.ladeuil+lp@free.fr-20071124142059-2114qtsgfdv8g9p1
Ssl files needed for the test https server.

* bzrlib/tests/ssl_certs/create_ssls.py: 
Script to create the ssl keys and certificates.

* bzrlib/tests/ssl_certs/server.crt: 
Server certificate signed by the certificate authority.

* bzrlib/tests/ssl_certs/server.csr: 
Server certificate signing request.

* bzrlib/tests/ssl_certs/server_without_pass.key: 
Server key usable without password.

* bzrlib/tests/ssl_certs/server_with_pass.key: 
Server key.

* bzrlib/tests/ssl_certs/ca.key: 
Certificate authority private key.

* bzrlib/tests/ssl_certs/ca.crt: 
Certificate authority certificate.

* bzrlib/tests/ssl_certs/__init__.py: 
Provide access to ssl files (keys and certificates). 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 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
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
 
22
22
from bzrlib.bzrdir import BzrDirMetaFormat1
23
23
from bzrlib.errors import BzrError, BoundBranchOutOfDate
24
24
from bzrlib.tests import TestCaseWithTransport
25
 
from bzrlib.tests.script import ScriptRunner
26
25
 
27
26
 
28
27
class TestUncommit(TestCaseWithTransport):
33
32
        wt.add(['a', 'b', 'c'])
34
33
        wt.commit('initial commit', rev_id='a1')
35
34
 
36
 
        self.build_tree_contents([('tree/a', 'new contents of a\n')])
 
35
        open('tree/a', 'wb').write('new contents of a\n')
37
36
        wt.commit('second commit', rev_id='a2')
38
37
 
39
38
        return wt
104
103
        uncommit.uncommit(b)
105
104
        self.assertEqual(len(b.revision_history()), 2)
106
105
        self.assertEqual(len(t_a.branch.revision_history()), 2)
107
 
        # update A's tree to not have the uncommitted revision referenced.
 
106
        # update A's tree to not have the uncomitted revision referenced.
108
107
        t_a.update()
109
108
        t_a.commit('commit 3b')
110
109
        self.assertRaises(BoundBranchOutOfDate, uncommit.uncommit, b)
111
110
        b.pull(t_a.branch)
112
111
        uncommit.uncommit(b)
113
112
 
114
 
    def test_uncommit_bound_local(self):
115
 
        t_a = self.make_branch_and_tree('a')
116
 
        rev_id1 = t_a.commit('commit 1')
117
 
        rev_id2 = t_a.commit('commit 2')
118
 
        rev_id3 = t_a.commit('commit 3')
119
 
        b = t_a.branch.create_checkout('b').branch
120
 
 
121
 
        out, err = self.run_bzr(['uncommit', '--local', 'b', '--force'])
122
 
        self.assertEqual(rev_id3, t_a.last_revision())
123
 
        self.assertEqual((3, rev_id3), t_a.branch.last_revision_info())
124
 
        self.assertEqual((2, rev_id2), b.last_revision_info())
125
 
 
126
113
    def test_uncommit_revision(self):
127
114
        wt = self.create_simple_tree()
128
115
 
174
161
        wt = self.create_simple_tree()
175
162
 
176
163
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
 
164
 
177
165
        tree2.commit('unchanged', rev_id='b3')
178
166
 
179
 
        tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
180
 
        tree3.commit('unchanged', rev_id='c3')
181
 
 
182
167
        wt.merge_from_branch(tree2.branch)
183
168
        wt.commit('merge b3', rev_id='a3')
184
169
 
185
 
        wt.merge_from_branch(tree3.branch)
186
 
        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')
187
174
 
188
175
        self.assertEqual(['a4'], wt.get_parent_ids())
189
176
 
190
177
        os.chdir('tree')
191
178
        out, err = self.run_bzr('uncommit --force -r 2')
192
179
 
193
 
        self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
 
180
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
194
181
 
195
182
    def test_uncommit_merge_plus_pending(self):
196
183
        wt = self.create_simple_tree()
197
184
 
198
185
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
 
186
 
199
187
        tree2.commit('unchanged', rev_id='b3')
200
 
        tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
201
 
        tree3.commit('unchanged', rev_id='c3')
202
 
 
203
188
        wt.branch.fetch(tree2.branch)
204
189
        wt.set_pending_merges(['b3'])
205
190
        wt.commit('merge b3', rev_id='a3')
206
191
 
207
 
 
208
 
        wt.merge_from_branch(tree3.branch)
209
 
 
210
 
        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())
211
197
 
212
198
        os.chdir('tree')
213
199
        out, err = self.run_bzr('uncommit --force -r 2')
214
200
 
215
 
        self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
216
 
 
217
 
    def test_uncommit_shows_log_with_revision_id(self):
218
 
        wt = self.create_simple_tree()
219
 
 
220
 
        script = ScriptRunner()
221
 
        script.run_script(self, """
222
 
$ cd tree
223
 
$ bzr uncommit --force 
224
 
    2 ...
225
 
      second commit
226
 
...
227
 
The above revision(s) will be removed.
228
 
You can restore the old tip by running:
229
 
  bzr pull . -r revid:a2
230
 
""")
 
201
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
231
202
 
232
203
    def test_uncommit_octopus_merge(self):
233
204
        # Check that uncommit keeps the pending merges in the same order
234
 
        # though it will also filter out ones in the ancestry
235
205
        wt = self.create_simple_tree()
236
206
 
237
207
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
239
209
 
240
210
        tree2.commit('unchanged', rev_id='b3')
241
211
        tree3.commit('unchanged', rev_id='c3')
242
 
 
 
212
        
243
213
        wt.merge_from_branch(tree2.branch)
244
 
        wt.merge_from_branch(tree3.branch, force=True)
 
214
        wt.merge_from_branch(tree3.branch)
245
215
        wt.commit('merge b3, c3', rev_id='a3')
246
216
 
247
217
        tree2.commit('unchanged', rev_id='b4')
248
218
        tree3.commit('unchanged', rev_id='c4')
249
219
 
250
220
        wt.merge_from_branch(tree3.branch)
251
 
        wt.merge_from_branch(tree2.branch, force=True)
 
221
        wt.merge_from_branch(tree2.branch)
252
222
        wt.commit('merge b4, c4', rev_id='a4')
253
223
 
254
224
        self.assertEqual(['a4'], wt.get_parent_ids())
256
226
        os.chdir('tree')
257
227
        out, err = self.run_bzr('uncommit --force -r 2')
258
228
 
259
 
        self.assertEqual(['a2', 'c4', 'b4'], wt.get_parent_ids())
260
 
 
261
 
    def test_uncommit_nonascii(self):
262
 
        tree = self.make_branch_and_tree('tree')
263
 
        tree.commit(u'\u1234 message')
264
 
        out, err = self.run_bzr('uncommit --force tree', encoding='ascii')
265
 
        self.assertContainsRe(out, r'\? message')
 
229
        self.assertEqual(['a2', 'b3', 'c3', 'c4', 'b4'], wt.get_parent_ids())