~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

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)
154
157
        Used before calls to self._real_bzrdir.
155
158
        """
156
159
        if not self._real_bzrdir:
 
160
            if 'hpssvfs' in debug.debug_flags:
 
161
                import traceback
 
162
                warning('VFS BzrDir access triggered\n%s',
 
163
                    ''.join(traceback.format_stack()))
157
164
            self._real_bzrdir = BzrDir.open_from_transport(
158
165
                self.root_transport, _server_formats=False)
159
166
            self._format._network_name = \
280
287
    def _get_branch_reference(self):
281
288
        path = self._path_for_remote_call(self._client)
282
289
        medium = self._client._medium
283
 
        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
284
298
            try:
285
 
                response = self._call('BzrDir.open_branchV2', path)
286
 
                if response[0] not in ('ref', 'branch'):
287
 
                    raise errors.UnexpectedSmartServerResponse(response)
288
 
                return response
 
299
                response = self._call(verb, path)
289
300
            except errors.UnknownSmartMethod:
290
 
                medium._remember_remote_is_before((1, 13))
291
 
        response = self._call('BzrDir.open_branch', path)
292
 
        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'):
293
314
            raise errors.UnexpectedSmartServerResponse(response)
294
 
        if response[1] != '':
295
 
            return ('ref', response[1])
296
 
        else:
297
 
            return ('branch', '')
 
315
        return response
298
316
 
299
317
    def _get_tree_branch(self):
300
318
        """See BzrDir._get_tree_branch()."""
597
615
        return self._custom_format._fetch_reconcile
598
616
 
599
617
    def get_format_description(self):
600
 
        return 'bzr remote repository'
 
618
        self._ensure_real()
 
619
        return 'Remote: ' + self._custom_format.get_format_description()
601
620
 
602
621
    def __eq__(self, other):
603
622
        return self.__class__ is other.__class__
946
965
    def is_write_locked(self):
947
966
        return self._lock_mode == 'w'
948
967
 
 
968
    def _warn_if_deprecated(self, branch=None):
 
969
        # If we have a real repository, the check will be done there, if we
 
970
        # don't the check will be done remotely.
 
971
        pass
 
972
 
949
973
    def lock_read(self):
950
974
        # wrong eventually - want a local lock cache context
951
975
        if not self._lock_mode:
1995
2019
                self._network_name)
1996
2020
 
1997
2021
    def get_format_description(self):
1998
 
        return 'Remote BZR Branch'
 
2022
        self._ensure_real()
 
2023
        return 'Remote: ' + self._custom_format.get_format_description()
1999
2024
 
2000
2025
    def network_name(self):
2001
2026
        return self._network_name
2812
2837
        raise NoSuchRevision(find('branch'), err.error_args[0])
2813
2838
    elif err.error_verb == 'nosuchrevision':
2814
2839
        raise NoSuchRevision(find('repository'), err.error_args[0])
2815
 
    elif err.error_tuple == ('nobranch',):
2816
 
        raise errors.NotBranchError(path=find('bzrdir').root_transport.base)
 
2840
    elif err.error_verb == 'nobranch':
 
2841
        if len(err.error_args) >= 1:
 
2842
            extra = err.error_args[0]
 
2843
        else:
 
2844
            extra = None
 
2845
        raise errors.NotBranchError(path=find('bzrdir').root_transport.base,
 
2846
            detail=extra)
2817
2847
    elif err.error_verb == 'norepository':
2818
2848
        raise errors.NoRepositoryPresent(find('bzrdir'))
2819
2849
    elif err.error_verb == 'LockContention':