~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Martin Pool
  • Date: 2010-01-29 14:09:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4992.
  • Revision ID: mbp@sourcefrog.net-20100129140905-2uiarb6p8di1ywsr
Correction to url

from review: https://code.edge.launchpad.net/~mbp/bzr/doc/+merge/18250

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
)
34
34
from bzrlib.branch import BranchReferenceFormat
35
35
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
36
 
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
36
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
37
37
from bzrlib.errors import (
38
38
    NoSuchRevision,
39
39
    SmartProtocolError,
89
89
class RemoteBzrDir(BzrDir, _RpcHelper):
90
90
    """Control directory on a remote server, accessed via bzr:// or similar."""
91
91
 
92
 
    def __init__(self, transport, format, _client=None):
 
92
    def __init__(self, transport, format, _client=None, _force_probe=False):
93
93
        """Construct a RemoteBzrDir.
94
94
 
95
95
        :param _client: Private parameter for testing. Disables probing and the
99
99
        # this object holds a delegated bzrdir that uses file-level operations
100
100
        # to talk to the other side
101
101
        self._real_bzrdir = None
 
102
        self._has_working_tree = None
102
103
        # 1-shot cache for the call pattern 'create_branch; open_branch' - see
103
104
        # create_branch for details.
104
105
        self._next_open_branch_result = None
108
109
            self._client = client._SmartClient(medium)
109
110
        else:
110
111
            self._client = _client
111
 
            return
112
 
 
 
112
            if not _force_probe:
 
113
                return
 
114
 
 
115
        self._probe_bzrdir()
 
116
 
 
117
    def __repr__(self):
 
118
        return '%s(%r)' % (self.__class__.__name__, self._client)
 
119
 
 
120
    def _probe_bzrdir(self):
 
121
        medium = self._client._medium
113
122
        path = self._path_for_remote_call(self._client)
 
123
        if medium._is_remote_before((2, 1)):
 
124
            self._rpc_open(path)
 
125
            return
 
126
        try:
 
127
            self._rpc_open_2_1(path)
 
128
            return
 
129
        except errors.UnknownSmartMethod:
 
130
            medium._remember_remote_is_before((2, 1))
 
131
            self._rpc_open(path)
 
132
 
 
133
    def _rpc_open_2_1(self, path):
 
134
        response = self._call('BzrDir.open_2.1', path)
 
135
        if response == ('no',):
 
136
            raise errors.NotBranchError(path=self.root_transport.base)
 
137
        elif response[0] == 'yes':
 
138
            if response[1] == 'yes':
 
139
                self._has_working_tree = True
 
140
            elif response[1] == 'no':
 
141
                self._has_working_tree = False
 
142
            else:
 
143
                raise errors.UnexpectedSmartServerResponse(response)
 
144
        else:
 
145
            raise errors.UnexpectedSmartServerResponse(response)
 
146
 
 
147
    def _rpc_open(self, path):
114
148
        response = self._call('BzrDir.open', path)
115
149
        if response not in [('yes',), ('no',)]:
116
150
            raise errors.UnexpectedSmartServerResponse(response)
117
151
        if response == ('no',):
118
 
            raise errors.NotBranchError(path=transport.base)
 
152
            raise errors.NotBranchError(path=self.root_transport.base)
119
153
 
120
154
    def _ensure_real(self):
121
155
        """Ensure that there is a _real_bzrdir set.
123
157
        Used before calls to self._real_bzrdir.
124
158
        """
125
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()))
126
164
            self._real_bzrdir = BzrDir.open_from_transport(
127
165
                self.root_transport, _server_formats=False)
128
166
            self._format._network_name = \
249
287
    def _get_branch_reference(self):
250
288
        path = self._path_for_remote_call(self._client)
251
289
        medium = self._client._medium
252
 
        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
253
298
            try:
254
 
                response = self._call('BzrDir.open_branchV2', path)
255
 
                if response[0] not in ('ref', 'branch'):
256
 
                    raise errors.UnexpectedSmartServerResponse(response)
257
 
                return response
 
299
                response = self._call(verb, path)
258
300
            except errors.UnknownSmartMethod:
259
 
                medium._remember_remote_is_before((1, 13))
260
 
        response = self._call('BzrDir.open_branch', path)
261
 
        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'):
262
314
            raise errors.UnexpectedSmartServerResponse(response)
263
 
        if response[1] != '':
264
 
            return ('ref', response[1])
265
 
        else:
266
 
            return ('branch', '')
 
315
        return response
267
316
 
268
317
    def _get_tree_branch(self):
269
318
        """See BzrDir._get_tree_branch()."""
355
404
        else:
356
405
            raise errors.NoRepositoryPresent(self)
357
406
 
 
407
    def has_workingtree(self):
 
408
        if self._has_working_tree is None:
 
409
            self._ensure_real()
 
410
            self._has_working_tree = self._real_bzrdir.has_workingtree()
 
411
        return self._has_working_tree
 
412
 
358
413
    def open_workingtree(self, recommend_upgrade=True):
359
 
        self._ensure_real()
360
 
        if self._real_bzrdir.has_workingtree():
 
414
        if self.has_workingtree():
361
415
            raise errors.NotLocalUrl(self.root_transport)
362
416
        else:
363
417
            raise errors.NoWorkingTree(self.root_transport.base)
426
480
        self._custom_format = None
427
481
        self._network_name = None
428
482
        self._creating_bzrdir = None
 
483
        self._supports_chks = None
429
484
        self._supports_external_lookups = None
430
485
        self._supports_tree_reference = None
431
486
        self._rich_root_data = None
432
487
 
 
488
    def __repr__(self):
 
489
        return "%s(_network_name=%r)" % (self.__class__.__name__,
 
490
            self._network_name)
 
491
 
433
492
    @property
434
493
    def fast_deltas(self):
435
494
        self._ensure_real()
443
502
        return self._rich_root_data
444
503
 
445
504
    @property
 
505
    def supports_chks(self):
 
506
        if self._supports_chks is None:
 
507
            self._ensure_real()
 
508
            self._supports_chks = self._custom_format.supports_chks
 
509
        return self._supports_chks
 
510
 
 
511
    @property
446
512
    def supports_external_lookups(self):
447
513
        if self._supports_external_lookups is None:
448
514
            self._ensure_real()
549
615
        return self._custom_format._fetch_reconcile
550
616
 
551
617
    def get_format_description(self):
552
 
        return 'bzr remote repository'
 
618
        self._ensure_real()
 
619
        return 'Remote: ' + self._custom_format.get_format_description()
553
620
 
554
621
    def __eq__(self, other):
555
622
        return self.__class__ is other.__class__
556
623
 
557
 
    def check_conversion_target(self, target_format):
558
 
        if self.rich_root_data and not target_format.rich_root_data:
559
 
            raise errors.BadConversionTarget(
560
 
                'Does not support rich root data.', target_format)
561
 
        if (self.supports_tree_reference and
562
 
            not getattr(target_format, 'supports_tree_reference', False)):
563
 
            raise errors.BadConversionTarget(
564
 
                'Does not support nested trees', target_format)
565
 
 
566
624
    def network_name(self):
567
625
        if self._network_name:
568
626
            return self._network_name
580
638
        return self._custom_format._serializer
581
639
 
582
640
 
583
 
class RemoteRepository(_RpcHelper):
 
641
class RemoteRepository(_RpcHelper, lock._RelockDebugMixin):
584
642
    """Repository accessed over rpc.
585
643
 
586
644
    For the moment most operations are performed using local transport-backed
907
965
    def is_write_locked(self):
908
966
        return self._lock_mode == 'w'
909
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
 
910
973
    def lock_read(self):
911
974
        # wrong eventually - want a local lock cache context
912
975
        if not self._lock_mode:
 
976
            self._note_lock('r')
913
977
            self._lock_mode = 'r'
914
978
            self._lock_count = 1
915
979
            self._unstacked_provider.enable_cache(cache_misses=True)
935
999
 
936
1000
    def lock_write(self, token=None, _skip_rpc=False):
937
1001
        if not self._lock_mode:
 
1002
            self._note_lock('w')
938
1003
            if _skip_rpc:
939
1004
                if self._lock_token is not None:
940
1005
                    if token != self._lock_token:
1043
1108
        else:
1044
1109
            raise errors.UnexpectedSmartServerResponse(response)
1045
1110
 
 
1111
    @only_raises(errors.LockNotHeld, errors.LockBroken)
1046
1112
    def unlock(self):
1047
1113
        if not self._lock_count:
1048
1114
            return lock.cant_unlock_not_held(self)
1178
1244
        self._ensure_real()
1179
1245
        return self._real_repository.get_inventory(revision_id)
1180
1246
 
1181
 
    def iter_inventories(self, revision_ids):
 
1247
    def iter_inventories(self, revision_ids, ordering=None):
1182
1248
        self._ensure_real()
1183
 
        return self._real_repository.iter_inventories(revision_ids)
 
1249
        return self._real_repository.iter_inventories(revision_ids, ordering)
1184
1250
 
1185
1251
    @needs_read_lock
1186
1252
    def get_revision(self, revision_id):
1682
1748
    def insert_stream(self, stream, src_format, resume_tokens):
1683
1749
        target = self.target_repo
1684
1750
        target._unstacked_provider.missing_keys.clear()
 
1751
        candidate_calls = [('Repository.insert_stream_1.19', (1, 19))]
1685
1752
        if target._lock_token:
1686
 
            verb = 'Repository.insert_stream_locked'
1687
 
            extra_args = (target._lock_token or '',)
1688
 
            required_version = (1, 14)
 
1753
            candidate_calls.append(('Repository.insert_stream_locked', (1, 14)))
 
1754
            lock_args = (target._lock_token or '',)
1689
1755
        else:
1690
 
            verb = 'Repository.insert_stream'
1691
 
            extra_args = ()
1692
 
            required_version = (1, 13)
 
1756
            candidate_calls.append(('Repository.insert_stream', (1, 13)))
 
1757
            lock_args = ()
1693
1758
        client = target._client
1694
1759
        medium = client._medium
1695
 
        if medium._is_remote_before(required_version):
1696
 
            # No possible way this can work.
1697
 
            return self._insert_real(stream, src_format, resume_tokens)
1698
1760
        path = target.bzrdir._path_for_remote_call(client)
1699
 
        if not resume_tokens:
1700
 
            # XXX: Ugly but important for correctness, *will* be fixed during
1701
 
            # 1.13 cycle. Pushing a stream that is interrupted results in a
1702
 
            # fallback to the _real_repositories sink *with a partial stream*.
1703
 
            # Thats bad because we insert less data than bzr expected. To avoid
1704
 
            # this we do a trial push to make sure the verb is accessible, and
1705
 
            # do not fallback when actually pushing the stream. A cleanup patch
1706
 
            # is going to look at rewinding/restarting the stream/partial
1707
 
            # buffering etc.
 
1761
        # Probe for the verb to use with an empty stream before sending the
 
1762
        # real stream to it.  We do this both to avoid the risk of sending a
 
1763
        # large request that is then rejected, and because we don't want to
 
1764
        # implement a way to buffer, rewind, or restart the stream.
 
1765
        found_verb = False
 
1766
        for verb, required_version in candidate_calls:
 
1767
            if medium._is_remote_before(required_version):
 
1768
                continue
 
1769
            if resume_tokens:
 
1770
                # We've already done the probing (and set _is_remote_before) on
 
1771
                # a previous insert.
 
1772
                found_verb = True
 
1773
                break
1708
1774
            byte_stream = smart_repo._stream_to_byte_stream([], src_format)
1709
1775
            try:
1710
1776
                response = client.call_with_body_stream(
1711
 
                    (verb, path, '') + extra_args, byte_stream)
 
1777
                    (verb, path, '') + lock_args, byte_stream)
1712
1778
            except errors.UnknownSmartMethod:
1713
1779
                medium._remember_remote_is_before(required_version)
1714
 
                return self._insert_real(stream, src_format, resume_tokens)
 
1780
            else:
 
1781
                found_verb = True
 
1782
                break
 
1783
        if not found_verb:
 
1784
            # Have to use VFS.
 
1785
            return self._insert_real(stream, src_format, resume_tokens)
 
1786
        self._last_inv_record = None
 
1787
        self._last_substream = None
 
1788
        if required_version < (1, 19):
 
1789
            # Remote side doesn't support inventory deltas.  Wrap the stream to
 
1790
            # make sure we don't send any.  If the stream contains inventory
 
1791
            # deltas we'll interrupt the smart insert_stream request and
 
1792
            # fallback to VFS.
 
1793
            stream = self._stop_stream_if_inventory_delta(stream)
1715
1794
        byte_stream = smart_repo._stream_to_byte_stream(
1716
1795
            stream, src_format)
1717
1796
        resume_tokens = ' '.join(resume_tokens)
1718
1797
        response = client.call_with_body_stream(
1719
 
            (verb, path, resume_tokens) + extra_args, byte_stream)
 
1798
            (verb, path, resume_tokens) + lock_args, byte_stream)
1720
1799
        if response[0][0] not in ('ok', 'missing-basis'):
1721
1800
            raise errors.UnexpectedSmartServerResponse(response)
 
1801
        if self._last_substream is not None:
 
1802
            # The stream included an inventory-delta record, but the remote
 
1803
            # side isn't new enough to support them.  So we need to send the
 
1804
            # rest of the stream via VFS.
 
1805
            self.target_repo.refresh_data()
 
1806
            return self._resume_stream_with_vfs(response, src_format)
1722
1807
        if response[0][0] == 'missing-basis':
1723
1808
            tokens, missing_keys = bencode.bdecode_as_tuple(response[0][1])
1724
1809
            resume_tokens = tokens
1727
1812
            self.target_repo.refresh_data()
1728
1813
            return [], set()
1729
1814
 
 
1815
    def _resume_stream_with_vfs(self, response, src_format):
 
1816
        """Resume sending a stream via VFS, first resending the record and
 
1817
        substream that couldn't be sent via an insert_stream verb.
 
1818
        """
 
1819
        if response[0][0] == 'missing-basis':
 
1820
            tokens, missing_keys = bencode.bdecode_as_tuple(response[0][1])
 
1821
            # Ignore missing_keys, we haven't finished inserting yet
 
1822
        else:
 
1823
            tokens = []
 
1824
        def resume_substream():
 
1825
            # Yield the substream that was interrupted.
 
1826
            for record in self._last_substream:
 
1827
                yield record
 
1828
            self._last_substream = None
 
1829
        def resume_stream():
 
1830
            # Finish sending the interrupted substream
 
1831
            yield ('inventory-deltas', resume_substream())
 
1832
            # Then simply continue sending the rest of the stream.
 
1833
            for substream_kind, substream in self._last_stream:
 
1834
                yield substream_kind, substream
 
1835
        return self._insert_real(resume_stream(), src_format, tokens)
 
1836
 
 
1837
    def _stop_stream_if_inventory_delta(self, stream):
 
1838
        """Normally this just lets the original stream pass-through unchanged.
 
1839
 
 
1840
        However if any 'inventory-deltas' substream occurs it will stop
 
1841
        streaming, and store the interrupted substream and stream in
 
1842
        self._last_substream and self._last_stream so that the stream can be
 
1843
        resumed by _resume_stream_with_vfs.
 
1844
        """
 
1845
                    
 
1846
        stream_iter = iter(stream)
 
1847
        for substream_kind, substream in stream_iter:
 
1848
            if substream_kind == 'inventory-deltas':
 
1849
                self._last_substream = substream
 
1850
                self._last_stream = stream_iter
 
1851
                return
 
1852
            else:
 
1853
                yield substream_kind, substream
 
1854
            
1730
1855
 
1731
1856
class RemoteStreamSource(repository.StreamSource):
1732
1857
    """Stream data from a remote server."""
1747
1872
            sources.append(repo)
1748
1873
        return self.missing_parents_chain(search, sources)
1749
1874
 
 
1875
    def get_stream_for_missing_keys(self, missing_keys):
 
1876
        self.from_repository._ensure_real()
 
1877
        real_repo = self.from_repository._real_repository
 
1878
        real_source = real_repo._get_source(self.to_format)
 
1879
        return real_source.get_stream_for_missing_keys(missing_keys)
 
1880
 
1750
1881
    def _real_stream(self, repo, search):
1751
1882
        """Get a stream for search from repo.
1752
1883
        
1758
1889
        """
1759
1890
        source = repo._get_source(self.to_format)
1760
1891
        if isinstance(source, RemoteStreamSource):
1761
 
            return repository.StreamSource.get_stream(source, search)
 
1892
            repo._ensure_real()
 
1893
            source = repo._real_repository._get_source(self.to_format)
1762
1894
        return source.get_stream(search)
1763
1895
 
1764
1896
    def _get_stream(self, repo, search):
1781
1913
            return self._real_stream(repo, search)
1782
1914
        client = repo._client
1783
1915
        medium = client._medium
1784
 
        if medium._is_remote_before((1, 13)):
1785
 
            # streaming was added in 1.13
1786
 
            return self._real_stream(repo, search)
1787
1916
        path = repo.bzrdir._path_for_remote_call(client)
1788
 
        try:
1789
 
            search_bytes = repo._serialise_search_result(search)
1790
 
            response = repo._call_with_body_bytes_expecting_body(
1791
 
                'Repository.get_stream',
1792
 
                (path, self.to_format.network_name()), search_bytes)
1793
 
            response_tuple, response_handler = response
1794
 
        except errors.UnknownSmartMethod:
1795
 
            medium._remember_remote_is_before((1,13))
 
1917
        search_bytes = repo._serialise_search_result(search)
 
1918
        args = (path, self.to_format.network_name())
 
1919
        candidate_verbs = [
 
1920
            ('Repository.get_stream_1.19', (1, 19)),
 
1921
            ('Repository.get_stream', (1, 13))]
 
1922
        found_verb = False
 
1923
        for verb, version in candidate_verbs:
 
1924
            if medium._is_remote_before(version):
 
1925
                continue
 
1926
            try:
 
1927
                response = repo._call_with_body_bytes_expecting_body(
 
1928
                    verb, args, search_bytes)
 
1929
            except errors.UnknownSmartMethod:
 
1930
                medium._remember_remote_is_before(version)
 
1931
            else:
 
1932
                response_tuple, response_handler = response
 
1933
                found_verb = True
 
1934
                break
 
1935
        if not found_verb:
1796
1936
            return self._real_stream(repo, search)
1797
1937
        if response_tuple[0] != 'ok':
1798
1938
            raise errors.UnexpectedSmartServerResponse(response_tuple)
1810
1950
        :param search: The overall search to satisfy with streams.
1811
1951
        :param sources: A list of Repository objects to query.
1812
1952
        """
1813
 
        self.serialiser = self.to_format._serializer
 
1953
        self.from_serialiser = self.from_repository._format._serializer
1814
1954
        self.seen_revs = set()
1815
1955
        self.referenced_revs = set()
1816
1956
        # If there are heads in the search, or the key count is > 0, we are not
1833
1973
    def missing_parents_rev_handler(self, substream):
1834
1974
        for content in substream:
1835
1975
            revision_bytes = content.get_bytes_as('fulltext')
1836
 
            revision = self.serialiser.read_revision_from_string(revision_bytes)
 
1976
            revision = self.from_serialiser.read_revision_from_string(
 
1977
                revision_bytes)
1837
1978
            self.seen_revs.add(content.key[-1])
1838
1979
            self.referenced_revs.update(revision.parent_ids)
1839
1980
            yield content
1878
2019
                self._network_name)
1879
2020
 
1880
2021
    def get_format_description(self):
1881
 
        return 'Remote BZR Branch'
 
2022
        self._ensure_real()
 
2023
        return 'Remote: ' + self._custom_format.get_format_description()
1882
2024
 
1883
2025
    def network_name(self):
1884
2026
        return self._network_name
1967
2109
        return self._custom_format.supports_set_append_revisions_only()
1968
2110
 
1969
2111
 
1970
 
class RemoteBranch(branch.Branch, _RpcHelper):
 
2112
class RemoteBranch(branch.Branch, _RpcHelper, lock._RelockDebugMixin):
1971
2113
    """Branch stored on a server accessed by HPSS RPC.
1972
2114
 
1973
2115
    At the moment most operations are mapped down to simple file operations.
2027
2169
                    self._real_branch._format.network_name()
2028
2170
        else:
2029
2171
            self._format = format
 
2172
        # when we do _ensure_real we may need to pass ignore_fallbacks to the
 
2173
        # branch.open_branch method.
 
2174
        self._real_ignore_fallbacks = not setup_stacking
2030
2175
        if not self._format._network_name:
2031
2176
            # Did not get from open_branchV2 - old server.
2032
2177
            self._ensure_real()
2077
2222
                raise AssertionError('smart server vfs must be enabled '
2078
2223
                    'to use vfs implementation')
2079
2224
            self.bzrdir._ensure_real()
2080
 
            self._real_branch = self.bzrdir._real_bzrdir.open_branch()
 
2225
            self._real_branch = self.bzrdir._real_bzrdir.open_branch(
 
2226
                ignore_fallbacks=self._real_ignore_fallbacks)
2081
2227
            if self.repository._real_repository is None:
2082
2228
                # Give the remote repository the matching real repo.
2083
2229
                real_repo = self._real_branch.repository
2187
2333
        medium = self._client._medium
2188
2334
        if medium._is_remote_before((1, 18)):
2189
2335
            self._vfs_set_tags_bytes(bytes)
 
2336
            return
2190
2337
        try:
2191
2338
            args = (
2192
2339
                self._remote_path(), self._lock_token, self._repo_lock_token)
2199
2346
    def lock_read(self):
2200
2347
        self.repository.lock_read()
2201
2348
        if not self._lock_mode:
 
2349
            self._note_lock('r')
2202
2350
            self._lock_mode = 'r'
2203
2351
            self._lock_count = 1
2204
2352
            if self._real_branch is not None:
2224
2372
 
2225
2373
    def lock_write(self, token=None):
2226
2374
        if not self._lock_mode:
 
2375
            self._note_lock('w')
2227
2376
            # Lock the branch and repo in one remote call.
2228
2377
            remote_tokens = self._remote_lock_write(token)
2229
2378
            self._lock_token, self._repo_lock_token = remote_tokens
2264
2413
            return
2265
2414
        raise errors.UnexpectedSmartServerResponse(response)
2266
2415
 
 
2416
    @only_raises(errors.LockNotHeld, errors.LockBroken)
2267
2417
    def unlock(self):
2268
2418
        try:
2269
2419
            self._lock_count -= 1
2309
2459
            raise NotImplementedError(self.dont_leave_lock_in_place)
2310
2460
        self._leave_lock = False
2311
2461
 
 
2462
    @needs_read_lock
2312
2463
    def get_rev_id(self, revno, history=None):
2313
2464
        if revno == 0:
2314
2465
            return _mod_revision.NULL_REVISION
2679
2830
                    'Missing key %r in context %r', key_err.args[0], context)
2680
2831
                raise err
2681
2832
 
2682
 
    if err.error_verb == 'NoSuchRevision':
 
2833
    if err.error_verb == 'IncompatibleRepositories':
 
2834
        raise errors.IncompatibleRepositories(err.error_args[0],
 
2835
            err.error_args[1], err.error_args[2])
 
2836
    elif err.error_verb == 'NoSuchRevision':
2683
2837
        raise NoSuchRevision(find('branch'), err.error_args[0])
2684
2838
    elif err.error_verb == 'nosuchrevision':
2685
2839
        raise NoSuchRevision(find('repository'), err.error_args[0])
2686
 
    elif err.error_tuple == ('nobranch',):
2687
 
        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)
2688
2847
    elif err.error_verb == 'norepository':
2689
2848
        raise errors.NoRepositoryPresent(find('bzrdir'))
2690
2849
    elif err.error_verb == 'LockContention':