181
181
br_b = wt_a.bzrdir.open_branch().sprout(repo_b.bzrdir, revision_id='1')
182
182
self.assertEqual(br_b.last_revision(), '1')
184
def get_parented_branch(self):
185
wt_a = self.make_branch_and_tree('a')
186
self.build_tree(['a/one'])
188
wt_a.commit('commit one', rev_id='1')
190
branch_b = wt_a.bzrdir.sprout('b', revision_id='1').open_branch()
191
self.assertEqual(wt_a.branch.base, branch_b.get_parent())
184
194
def test_clone_branch_nickname(self):
185
195
# test the nick name is preserved always
186
196
raise TestSkipped('XXX branch cloning is not yet tested..')
188
198
def test_clone_branch_parent(self):
189
199
# test the parent is preserved always
190
raise TestSkipped('XXX branch cloning is not yet tested..')
200
branch_b = self.get_parented_branch()
201
repo_c = self.make_repository('c')
202
branch_b.repository.copy_content_into(repo_c)
203
branch_c = branch_b.clone(repo_c.bzrdir)
204
self.assertNotEqual(None, branch_c.get_parent())
205
self.assertEqual(branch_b.get_parent(), branch_c.get_parent())
207
# We can also set a specific parent, and it should be honored
208
random_parent = 'http://bazaar-vcs.org/path/to/branch'
209
branch_b.set_parent(random_parent)
210
repo_d = self.make_repository('d')
211
branch_b.repository.copy_content_into(repo_d)
212
branch_d = branch_b.clone(repo_d.bzrdir)
213
self.assertEqual(random_parent, branch_d.get_parent())
192
215
def test_sprout_branch_nickname(self):
193
216
# test the nick name is reset always
194
217
raise TestSkipped('XXX branch sprouting is not yet tested..')
207
230
branch.set_submit_branch('sftp://example.net')
208
231
self.assertEqual(branch.get_submit_branch(), 'sftp://example.net')
210
def test_record_initial_ghost_merge(self):
211
"""A pending merge with no revision present is still a merge."""
233
def test_record_initial_ghost(self):
234
"""Branches should support having ghosts."""
212
235
wt = self.make_branch_and_tree('.')
214
236
wt.add_pending_merge('non:existent@rev--ision--0--2')
215
wt.commit('pretend to merge nonexistent-revision', rev_id='first')
216
rev = branch.repository.get_revision(branch.last_revision())
217
self.assertEqual(len(rev.parent_ids), 1)
237
rev_id = wt.commit('commit against a ghost first parent.')
238
rev = wt.branch.repository.get_revision(rev_id)
239
self.assertEqual(rev.parent_ids, ['non:existent@rev--ision--0--2'])
218
240
# parent_sha1s is not populated now, WTF. rbc 20051003
219
241
self.assertEqual(len(rev.parent_sha1s), 0)
220
self.assertEqual(rev.parent_ids[0], 'non:existent@rev--ision--0--2')
243
def test_record_two_ghosts(self):
244
"""Recording with all ghosts works."""
245
wt = self.make_branch_and_tree('.')
246
wt.add_pending_merge('foo@azkhazan-123123-abcabc')
247
wt.add_pending_merge('wibble@fofof--20050401--1928390812')
248
rev_id = wt.commit("commit from ghost base with one merge")
249
# the revision should have been committed with two parents
250
rev = wt.branch.repository.get_revision(rev_id)
251
self.assertEqual(['foo@azkhazan-123123-abcabc',
252
'wibble@fofof--20050401--1928390812'],
222
255
def test_bad_revision(self):
223
256
self.assertRaises(errors.InvalidRevisionId,
229
262
# an identical tree without a ghost
230
263
# fetch missing should rewrite the TOC of weaves to list newly available parents.
232
def test_pending_merges(self):
233
"""Tracking pending-merged revisions."""
234
wt = self.make_branch_and_tree('.')
236
self.assertEquals(wt.pending_merges(), [])
237
wt.add_pending_merge('foo@azkhazan-123123-abcabc')
238
self.assertEquals(wt.pending_merges(), ['foo@azkhazan-123123-abcabc'])
239
wt.add_pending_merge('foo@azkhazan-123123-abcabc')
240
self.assertEquals(wt.pending_merges(), ['foo@azkhazan-123123-abcabc'])
241
wt.add_pending_merge('wibble@fofof--20050401--1928390812')
242
self.assertEquals(wt.pending_merges(),
243
['foo@azkhazan-123123-abcabc',
244
'wibble@fofof--20050401--1928390812'])
245
wt.commit("commit from base with two merges")
246
rev = b.repository.get_revision(b.revision_history()[0])
247
self.assertEquals(len(rev.parent_ids), 2)
248
self.assertEquals(rev.parent_ids[0],
249
'foo@azkhazan-123123-abcabc')
250
self.assertEquals(rev.parent_ids[1],
251
'wibble@fofof--20050401--1928390812')
252
# list should be cleared when we do a commit
253
self.assertEquals(wt.pending_merges(), [])
255
265
def test_sign_existing_revision(self):
256
266
wt = self.make_branch_and_tree('.')
257
267
branch = wt.branch
373
383
tree.branch.generate_revision_history(bzrlib.revision.NULL_REVISION)
374
384
self.assertEqual([], tree.branch.revision_history())
386
def test_create_checkout(self):
387
tree_a = self.make_branch_and_tree('a')
388
branch_a = tree_a.branch
389
checkout_b = branch_a.create_checkout('b')
390
checkout_b.commit('rev1', rev_id='rev1')
391
self.assertEqual('rev1', branch_a.last_revision())
392
self.assertNotEqual(checkout_b.branch.base, branch_a.base)
394
checkout_c = branch_a.create_checkout('c', lightweight=True)
395
checkout_c.commit('rev2', rev_id='rev2')
396
self.assertEqual('rev2', branch_a.last_revision())
397
self.assertEqual(checkout_c.branch.base, branch_a.base)
400
checkout_d = branch_a.create_checkout('d', lightweight=True)
402
checkout_e = branch_a.create_checkout('e')
377
405
class ChrootedTests(TestCaseWithBranch):
378
406
"""A support class that provides readonly urls outside the local namespace.