/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_branch.py

  • Committer: Aaron Bentley
  • Date: 2006-09-28 13:48:10 UTC
  • mfrom: (2049 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2268.
  • Revision ID: abentley@panoramicfeedback.com-20060928134810-2c8ae086a4a70f43
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
        repo_b = self.make_repository('b')
165
165
        wt_a.bzrdir.open_repository().copy_content_into(repo_b)
166
166
        br_b = wt_a.bzrdir.open_branch().clone(repo_b.bzrdir, revision_id='1')
167
 
        self.assertEqual(br_b.last_revision(), '1')
 
167
        self.assertEqual('1', br_b.last_revision())
168
168
 
169
169
    def test_sprout_partial(self):
170
170
        # test sprouting with a prefix of the revision-history.
179
179
        repo_b = self.make_repository('b')
180
180
        wt_a.bzrdir.open_repository().copy_content_into(repo_b)
181
181
        br_b = wt_a.bzrdir.open_branch().sprout(repo_b.bzrdir, revision_id='1')
182
 
        self.assertEqual(br_b.last_revision(), '1')
 
182
        self.assertEqual('1', br_b.last_revision())
183
183
 
184
184
    def get_parented_branch(self):
185
185
        wt_a = self.make_branch_and_tree('a')
230
230
        branch.set_submit_branch('sftp://example.net')
231
231
        self.assertEqual(branch.get_submit_branch(), 'sftp://example.net')
232
232
        
233
 
    def test_record_initial_ghost_merge(self):
234
 
        """A pending merge with no revision present is still a merge."""
 
233
    def test_record_initial_ghost(self):
 
234
        """Branches should support having ghosts."""
235
235
        wt = self.make_branch_and_tree('.')
236
 
        branch = wt.branch
237
 
        wt.add_pending_merge('non:existent@rev--ision--0--2')
238
 
        wt.commit('pretend to merge nonexistent-revision', rev_id='first')
239
 
        rev = branch.repository.get_revision(branch.last_revision())
240
 
        self.assertEqual(len(rev.parent_ids), 1)
 
236
        wt.set_parent_ids(['non:existent@rev--ision--0--2'],
 
237
            allow_leftmost_as_ghost=True)
 
238
        rev_id = wt.commit('commit against a ghost first parent.')
 
239
        rev = wt.branch.repository.get_revision(rev_id)
 
240
        self.assertEqual(rev.parent_ids, ['non:existent@rev--ision--0--2'])
241
241
        # parent_sha1s is not populated now, WTF. rbc 20051003
242
242
        self.assertEqual(len(rev.parent_sha1s), 0)
243
 
        self.assertEqual(rev.parent_ids[0], 'non:existent@rev--ision--0--2')
 
243
 
 
244
    def test_record_two_ghosts(self):
 
245
        """Recording with all ghosts works."""
 
246
        wt = self.make_branch_and_tree('.')
 
247
        wt.set_parent_ids([
 
248
                'foo@azkhazan-123123-abcabc',
 
249
                'wibble@fofof--20050401--1928390812',
 
250
            ],
 
251
            allow_leftmost_as_ghost=True)
 
252
        rev_id = wt.commit("commit from ghost base with one merge")
 
253
        # the revision should have been committed with two parents
 
254
        rev = wt.branch.repository.get_revision(rev_id)
 
255
        self.assertEqual(['foo@azkhazan-123123-abcabc',
 
256
            'wibble@fofof--20050401--1928390812'],
 
257
            rev.parent_ids)
244
258
 
245
259
    def test_bad_revision(self):
246
260
        self.assertRaises(errors.InvalidRevisionId,
252
266
#     an identical tree without a ghost
253
267
# fetch missing should rewrite the TOC of weaves to list newly available parents.
254
268
        
255
 
    def test_pending_merges(self):
256
 
        """Tracking pending-merged revisions."""
257
 
        wt = self.make_branch_and_tree('.')
258
 
        b = wt.branch
259
 
        self.assertEquals(wt.pending_merges(), [])
260
 
        wt.add_pending_merge('foo@azkhazan-123123-abcabc')
261
 
        self.assertEquals(wt.pending_merges(), ['foo@azkhazan-123123-abcabc'])
262
 
        wt.add_pending_merge('foo@azkhazan-123123-abcabc')
263
 
        self.assertEquals(wt.pending_merges(), ['foo@azkhazan-123123-abcabc'])
264
 
        wt.add_pending_merge('wibble@fofof--20050401--1928390812')
265
 
        self.assertEquals(wt.pending_merges(),
266
 
                          ['foo@azkhazan-123123-abcabc',
267
 
                           'wibble@fofof--20050401--1928390812'])
268
 
        wt.commit("commit from base with two merges")
269
 
        rev = b.repository.get_revision(b.revision_history()[0])
270
 
        self.assertEquals(len(rev.parent_ids), 2)
271
 
        self.assertEquals(rev.parent_ids[0],
272
 
                          'foo@azkhazan-123123-abcabc')
273
 
        self.assertEquals(rev.parent_ids[1],
274
 
                           'wibble@fofof--20050401--1928390812')
275
 
        # list should be cleared when we do a commit
276
 
        self.assertEquals(wt.pending_merges(), [])
277
 
 
278
269
    def test_sign_existing_revision(self):
279
270
        wt = self.make_branch_and_tree('.')
280
271
        branch = wt.branch
400
391
        tree_a = self.make_branch_and_tree('a')
401
392
        branch_a = tree_a.branch
402
393
        checkout_b = branch_a.create_checkout('b')
 
394
        self.assertEqual(None, checkout_b.last_revision())
403
395
        checkout_b.commit('rev1', rev_id='rev1')
404
396
        self.assertEqual('rev1', branch_a.last_revision())
405
397
        self.assertNotEqual(checkout_b.branch.base, branch_a.base)
406
398
 
407
399
        checkout_c = branch_a.create_checkout('c', lightweight=True)
 
400
        self.assertEqual('rev1', checkout_c.last_revision())
408
401
        checkout_c.commit('rev2', rev_id='rev2')
409
402
        self.assertEqual('rev2', branch_a.last_revision())
410
403
        self.assertEqual(checkout_c.branch.base, branch_a.base)
411
404
 
412
405
        os.mkdir('d')
413
406
        checkout_d = branch_a.create_checkout('d', lightweight=True)
 
407
        self.assertEqual('rev2', checkout_d.last_revision())
414
408
        os.mkdir('e')
415
409
        checkout_e = branch_a.create_checkout('e')
 
410
        self.assertEqual('rev2', checkout_e.last_revision())
 
411
 
 
412
    def test_create_anonymous_lightweight_checkout(self):
 
413
        """A lightweight checkout from a readonly branch should succeed."""
 
414
        tree_a = self.make_branch_and_tree('a')
 
415
        rev_id = tree_a.commit('put some content in the branch')
 
416
        source_branch = bzrlib.branch.Branch.open(
 
417
            'readonly+' + tree_a.bzrdir.root_transport.base)
 
418
        # sanity check that the test will be valid
 
419
        self.assertRaises((errors.LockError, errors.TransportNotPossible),
 
420
            source_branch.lock_write)
 
421
        checkout = source_branch.create_checkout('c', lightweight=True)
 
422
        self.assertEqual(rev_id, checkout.last_revision())
 
423
 
 
424
    def test_create_anonymous_heavyweight_checkout(self):
 
425
        """A regular checkout from a readonly branch should succeed."""
 
426
        tree_a = self.make_branch_and_tree('a')
 
427
        rev_id = tree_a.commit('put some content in the branch')
 
428
        source_branch = bzrlib.branch.Branch.open(
 
429
            'readonly+' + tree_a.bzrdir.root_transport.base)
 
430
        # sanity check that the test will be valid
 
431
        self.assertRaises((errors.LockError, errors.TransportNotPossible),
 
432
            source_branch.lock_write)
 
433
        checkout = source_branch.create_checkout('c')
 
434
        self.assertEqual(rev_id, checkout.last_revision())
416
435
 
417
436
 
418
437
class ChrootedTests(TestCaseWithBranch):