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)
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)
404
406
checkout_d = branch_a.create_checkout('d', lightweight=True)
407
self.assertEqual('rev2', checkout_d.last_revision())
406
409
checkout_e = branch_a.create_checkout('e')
410
self.assertEqual('rev2', checkout_e.last_revision())
408
412
def test_create_anonymous_lightweight_checkout(self):
409
"""A checkout from a readonly branch should succeed."""
413
"""A lightweight checkout from a readonly branch should succeed."""
410
414
tree_a = self.make_branch_and_tree('a')
411
415
rev_id = tree_a.commit('put some content in the branch')
412
416
source_branch = bzrlib.branch.Branch.open(
417
421
checkout = source_branch.create_checkout('c', lightweight=True)
418
422
self.assertEqual(rev_id, checkout.last_revision())
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())
421
437
class ChrootedTests(TestCaseWithBranch):
422
438
"""A support class that provides readonly urls outside the local namespace.