~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
3359
3359
        remote_branch_url = self.smart_server.get_url() + 'remote'
3360
3360
        remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch()
3361
3361
        self.hpss_calls = []
3362
 
        local.repository.fetch(remote_branch.repository,
3363
 
                fetch_spec=_mod_graph.EverythingResult(remote_branch.repository))
 
3362
        local.repository.fetch(
 
3363
            remote_branch.repository,
 
3364
            fetch_spec=_mod_graph.EverythingResult(remote_branch.repository))
3364
3365
        self.assertEqual(['Repository.get_stream_1.19'], self.hpss_calls)
3365
3366
 
3366
3367
    def override_verb(self, verb_name, verb):
3381
3382
            """A version of the Repository.get_stream_1.19 verb patched to
3382
3383
            reject 'everything' searches the way 2.3 and earlier do.
3383
3384
            """
3384
 
            def recreate_search(self, repository, search_bytes, discard_excess=False):
 
3385
            def recreate_search(self, repository, search_bytes,
 
3386
                                discard_excess=False):
3385
3387
                verb_log.append(search_bytes.split('\n', 1)[0])
3386
3388
                if search_bytes == 'everything':
3387
 
                    return (None, request.FailedSmartServerResponse(('BadSearch',)))
 
3389
                    return (None,
 
3390
                            request.FailedSmartServerResponse(('BadSearch',)))
3388
3391
                return super(OldGetStreamVerb,
3389
3392
                        self).recreate_search(repository, search_bytes,
3390
3393
                            discard_excess=discard_excess)
3395
3398
        remote_branch_url = self.smart_server.get_url() + 'remote'
3396
3399
        remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch()
3397
3400
        self.hpss_calls = []
3398
 
        local.repository.fetch(remote_branch.repository,
3399
 
                fetch_spec=_mod_graph.EverythingResult(remote_branch.repository))
 
3401
        local.repository.fetch(
 
3402
            remote_branch.repository,
 
3403
            fetch_spec=_mod_graph.EverythingResult(remote_branch.repository))
3400
3404
        # make sure the overridden verb was used
3401
3405
        self.assertLength(1, verb_log)
3402
3406
        # more than one HPSS call is needed, but because it's a VFS callback
3403
3407
        # its hard to predict exactly how many.
3404
3408
        self.assertTrue(len(self.hpss_calls) > 1)
3405
3409
 
 
3410
 
 
3411
class TestUpdateBoundBranch(tests.TestCaseWithTransport):
 
3412
 
 
3413
    def test_bug_786980(self):
 
3414
        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()
 
3420
        # For unclear reasons some users have a bound_location without a final
 
3421
        # '/', 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()
 
3427
        checkout.update()
 
3428
        self.assertEquals(last_revid, checkout.last_revision())