~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-11 05:58:22 UTC
  • mto: This revision was merged to the branch mainline in revision 4965.
  • Revision ID: andrew.bennetts@canonical.com-20100111055822-npdkf88i86i1g54h
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb).

Show diffs side-by-side

added added

removed removed

Lines of Context:
284
284
    def _get_branch_reference(self):
285
285
        path = self._path_for_remote_call(self._client)
286
286
        medium = self._client._medium
287
 
        if not medium._is_remote_before((1, 13)):
 
287
        candidate_calls = [
 
288
            ('BzrDir.open_branchV3', (2, 1)),
 
289
            ('BzrDir.open_branchV2', (1, 13)),
 
290
            ('BzrDir.open_branch', None),
 
291
            ]
 
292
        for verb, required_version in candidate_calls:
 
293
            if required_version and medium._is_remote_before(required_version):
 
294
                continue
288
295
            try:
289
 
                response = self._call('BzrDir.open_branchV2', path)
290
 
                if response[0] not in ('ref', 'branch'):
291
 
                    raise errors.UnexpectedSmartServerResponse(response)
292
 
                return response
 
296
                response = self._call(verb, path)
293
297
            except errors.UnknownSmartMethod:
294
 
                medium._remember_remote_is_before((1, 13))
295
 
        response = self._call('BzrDir.open_branch', path)
296
 
        if response[0] != 'ok':
 
298
                if required_version is None:
 
299
                    raise
 
300
                medium._remember_remote_is_before(required_version)
 
301
            else:
 
302
                break
 
303
        if verb == 'BzrDir.open_branch':
 
304
            if response[0] != 'ok':
 
305
                raise errors.UnexpectedSmartServerResponse(response)
 
306
            if response[1] != '':
 
307
                return ('ref', response[1])
 
308
            else:
 
309
                return ('branch', '')
 
310
        if response[0] not in ('ref', 'branch'):
297
311
            raise errors.UnexpectedSmartServerResponse(response)
298
 
        if response[1] != '':
299
 
            return ('ref', response[1])
300
 
        else:
301
 
            return ('branch', '')
 
312
        return response
302
313
 
303
314
    def _get_tree_branch(self):
304
315
        """See BzrDir._get_tree_branch()."""
2823
2834
        raise NoSuchRevision(find('branch'), err.error_args[0])
2824
2835
    elif err.error_verb == 'nosuchrevision':
2825
2836
        raise NoSuchRevision(find('repository'), err.error_args[0])
2826
 
    elif err.error_tuple == ('nobranch',):
2827
 
        raise errors.NotBranchError(path=find('bzrdir').root_transport.base)
2828
2837
    elif err.error_verb == 'nobranch':
 
2838
        if len(err.error_args) >= 1:
 
2839
            extra = err.error_args[0]
 
2840
        else:
 
2841
            extra = None
2829
2842
        raise errors.NotBranchError(path=find('bzrdir').root_transport.base,
2830
 
            detail=err.error_args[0])
 
2843
            detail=extra)
2831
2844
    elif err.error_verb == 'norepository':
2832
2845
        raise errors.NoRepositoryPresent(find('bzrdir'))
2833
2846
    elif err.error_verb == 'LockContention':