~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

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')
391
391
        tree_a = self.make_branch_and_tree('a')
392
392
        branch_a = tree_a.branch
393
393
        checkout_b = branch_a.create_checkout('b')
 
394
        self.assertEqual(None, checkout_b.last_revision())
394
395
        checkout_b.commit('rev1', rev_id='rev1')
395
396
        self.assertEqual('rev1', branch_a.last_revision())
396
397
        self.assertNotEqual(checkout_b.branch.base, branch_a.base)
397
398
 
398
399
        checkout_c = branch_a.create_checkout('c', lightweight=True)
 
400
        self.assertEqual('rev1', checkout_c.last_revision())
399
401
        checkout_c.commit('rev2', rev_id='rev2')
400
402
        self.assertEqual('rev2', branch_a.last_revision())
401
403
        self.assertEqual(checkout_c.branch.base, branch_a.base)
402
404
 
403
405
        os.mkdir('d')
404
406
        checkout_d = branch_a.create_checkout('d', lightweight=True)
 
407
        self.assertEqual('rev2', checkout_d.last_revision())
405
408
        os.mkdir('e')
406
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())
407
435
 
408
436
 
409
437
class ChrootedTests(TestCaseWithBranch):