~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Martin Pool
  • Date: 2010-02-23 07:43:11 UTC
  • mfrom: (4797.2.20 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: mbp@sourcefrog.net-20100223074311-gnj55xdhrgz9l94e
Merge 2.1 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
114
114
 
115
115
        self._probe_bzrdir()
116
116
 
 
117
    def __repr__(self):
 
118
        return '%s(%r)' % (self.__class__.__name__, self._client)
 
119
 
117
120
    def _probe_bzrdir(self):
118
121
        medium = self._client._medium
119
122
        path = self._path_for_remote_call(self._client)
284
287
    def _get_branch_reference(self):
285
288
        path = self._path_for_remote_call(self._client)
286
289
        medium = self._client._medium
287
 
        if not medium._is_remote_before((1, 13)):
 
290
        candidate_calls = [
 
291
            ('BzrDir.open_branchV3', (2, 1)),
 
292
            ('BzrDir.open_branchV2', (1, 13)),
 
293
            ('BzrDir.open_branch', None),
 
294
            ]
 
295
        for verb, required_version in candidate_calls:
 
296
            if required_version and medium._is_remote_before(required_version):
 
297
                continue
288
298
            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
 
299
                response = self._call(verb, path)
293
300
            except errors.UnknownSmartMethod:
294
 
                medium._remember_remote_is_before((1, 13))
295
 
        response = self._call('BzrDir.open_branch', path)
296
 
        if response[0] != 'ok':
 
301
                if required_version is None:
 
302
                    raise
 
303
                medium._remember_remote_is_before(required_version)
 
304
            else:
 
305
                break
 
306
        if verb == 'BzrDir.open_branch':
 
307
            if response[0] != 'ok':
 
308
                raise errors.UnexpectedSmartServerResponse(response)
 
309
            if response[1] != '':
 
310
                return ('ref', response[1])
 
311
            else:
 
312
                return ('branch', '')
 
313
        if response[0] not in ('ref', 'branch'):
297
314
            raise errors.UnexpectedSmartServerResponse(response)
298
 
        if response[1] != '':
299
 
            return ('ref', response[1])
300
 
        else:
301
 
            return ('branch', '')
 
315
        return response
302
316
 
303
317
    def _get_tree_branch(self):
304
318
        """See BzrDir._get_tree_branch()."""
1483
1497
        return self._real_repository.get_signature_text(revision_id)
1484
1498
 
1485
1499
    @needs_read_lock
1486
 
    def get_inventory_xml(self, revision_id):
1487
 
        self._ensure_real()
1488
 
        return self._real_repository.get_inventory_xml(revision_id)
1489
 
 
1490
 
    def deserialise_inventory(self, revision_id, xml):
1491
 
        self._ensure_real()
1492
 
        return self._real_repository.deserialise_inventory(revision_id, xml)
 
1500
    def _get_inventory_xml(self, revision_id):
 
1501
        self._ensure_real()
 
1502
        return self._real_repository._get_inventory_xml(revision_id)
1493
1503
 
1494
1504
    def reconcile(self, other=None, thorough=False):
1495
1505
        self._ensure_real()
2823
2833
        raise NoSuchRevision(find('branch'), err.error_args[0])
2824
2834
    elif err.error_verb == 'nosuchrevision':
2825
2835
        raise NoSuchRevision(find('repository'), err.error_args[0])
2826
 
    elif err.error_tuple == ('nobranch',):
2827
 
        raise errors.NotBranchError(path=find('bzrdir').root_transport.base)
 
2836
    elif err.error_verb == 'nobranch':
 
2837
        if len(err.error_args) >= 1:
 
2838
            extra = err.error_args[0]
 
2839
        else:
 
2840
            extra = None
 
2841
        raise errors.NotBranchError(path=find('bzrdir').root_transport.base,
 
2842
            detail=extra)
2828
2843
    elif err.error_verb == 'norepository':
2829
2844
        raise errors.NoRepositoryPresent(find('bzrdir'))
2830
2845
    elif err.error_verb == 'LockContention':