3408
3408
self.assertTrue(len(self.hpss_calls) > 1)
3411
class TestUpdateBoundBranch(tests.TestCaseWithTransport):
3413
def test_bug_786980(self):
3411
class TestUpdateBoundBranchWithModifiedBoundLocation(
3412
tests.TestCaseWithTransport):
3413
"""Ensure correct handling of bound_location modifications.
3415
This is tested against a smart server as http://pad.lv/786980 was about a
3416
ReadOnlyError (write attempt during a read-only transaction) which can only
3417
happen in this context.
3421
super(TestUpdateBoundBranchWithModifiedBoundLocation, self).setUp()
3414
3422
self.transport_server = test_server.SmartTCPServer_for_testing
3415
wt = self.make_branch_and_tree('master')
3416
checkout = wt.branch.create_checkout('checkout')
3417
wt.commit('add stuff')
3418
last_revid = wt.commit('even more stuff')
3419
bound_location = checkout.branch.get_bound_location()
3424
def make_master_and_checkout(self, master_name, checkout_name):
3425
# Create the master branch and its associated checkout
3426
self.master = self.make_branch_and_tree(master_name)
3427
self.checkout = self.master.branch.create_checkout(checkout_name)
3428
# Modify the master branch so there is something to update
3429
self.master.commit('add stuff')
3430
self.last_revid = self.master.commit('even more stuff')
3431
self.bound_location = self.checkout.branch.get_bound_location()
3433
def assertUpdateSucceeds(self, new_location):
3434
self.checkout.branch.set_bound_location(new_location)
3435
self.checkout.update()
3436
self.assertEquals(self.last_revid, self.checkout.last_revision())
3438
def test_without_final_slash(self):
3439
self.make_master_and_checkout('master', 'checkout')
3420
3440
# For unclear reasons some users have a bound_location without a final
3421
3441
# '/', simulate that by forcing such a value
3422
self.assertEndsWith(bound_location, '/')
3423
new_location = bound_location.rstrip('/')
3424
checkout.branch.set_bound_location(new_location)
3425
# bug 786980 was raising ReadOnlyError: A write attempt was made in a
3426
# read only transaction during the update()
3428
self.assertEquals(last_revid, checkout.last_revision())
3442
self.assertEndsWith(self.bound_location, '/')
3443
self.assertUpdateSucceeds(self.bound_location.rstrip('/'))
3445
def test_plus_sign(self):
3446
self.make_master_and_checkout('+master', 'checkout')
3447
self.assertUpdateSucceeds(self.bound_location.replace('%2B', '+', 1))
3449
def test_tilda(self):
3450
# Embed ~ in the middle of the path just to avoid any $HOME
3452
self.make_master_and_checkout('mas~ter', 'checkout')
3453
self.assertUpdateSucceeds(self.bound_location.replace('%2E', '~', 1))