/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6613.1.1 by Vincent Ladeuil
Use ssl module for the match_hostname function
1
# Copyright (C) 2005-2013, 2016 Canonical Ltd
1830.3.5 by John Arbash Meinel
make_entry refuses to create non-normalized entries.
2
#
1 by mbp at sourcefrog
import from baz patch-364
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1830.3.5 by John Arbash Meinel
make_entry refuses to create non-normalized entries.
7
#
1 by mbp at sourcefrog
import from baz patch-364
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1830.3.5 by John Arbash Meinel
make_entry refuses to create non-normalized entries.
12
#
1 by mbp at sourcefrog
import from baz patch-364
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1 by mbp at sourcefrog
import from baz patch-364
16
1185.16.61 by mbp at sourcefrog
- start introducing hct error classes
17
"""Exceptions for bzr, and reporting of them.
18
"""
19
6379.6.7 by Jelmer Vernooij
Move importing from future until after doc string, otherwise the doc string will disappear.
20
from __future__ import absolute_import
21
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
22
from .sixish import (
23
    PY3,
24
    )
25
1185.16.62 by mbp at sourcefrog
- convert NotBranchError to new exception base
26
# TODO: is there any value in providing the .args field used by standard
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
27
# python exceptions?   A list of values with no names seems less useful
1185.16.62 by mbp at sourcefrog
- convert NotBranchError to new exception base
28
# to me.
29
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
30
# TODO: Perhaps convert the exception to a string at the moment it's
1185.16.63 by Martin Pool
- more error conversion
31
# constructed to make sure it will succeed.  But that says nothing about
32
# exceptions that are never raised.
33
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
34
# TODO: selftest assertRaises should probably also check that every error
35
# raised can be formatted as a string successfully, and without giving
36
# 'unprintable'.
1662.1.12 by Martin Pool
Translate unknown sftp errors to PathError, no NoSuchFile
37
1185.16.61 by mbp at sourcefrog
- start introducing hct error classes
38
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
39
# return codes from the brz program
2830.2.9 by Martin Pool
Add EXIT_OK=0
40
EXIT_OK = 0
2713.2.1 by Martin Pool
Return exitcode 4 if an internal error occurs
41
EXIT_ERROR = 3
42
EXIT_INTERNAL_ERROR = 4
43
44
6619.3.9 by Jelmer Vernooij
Run 2to3 standarderror fixer.
45
class BzrError(Exception):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
46
    """
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
47
    Base class for errors raised by breezy.
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
48
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
49
    :cvar internal_error: if True this was probably caused by a brz bug and
5891.1.2 by Andrew Bennetts
Fix a bunch of docstring formatting nits, making pydoctor a bit happier.
50
        should be displayed with a traceback; if False (or absent) this was
51
        probably a user or environment error and they don't need the gory
52
        details.  (That can be overridden by -Derror on the command line.)
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
53
2067.3.2 by Martin Pool
Error cleanup review comments:
54
    :cvar _fmt: Format string to display the error; this is expanded
5891.1.2 by Andrew Bennetts
Fix a bunch of docstring formatting nits, making pydoctor a bit happier.
55
        by the instance's dict.
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
56
    """
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
57
2067.3.2 by Martin Pool
Error cleanup review comments:
58
    internal_error = False
1685.2.1 by Brian M. Carlson
Add a workaround for usage of the args attribute in exceptions.
59
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
60
    def __init__(self, msg=None, **kwds):
61
        """Construct a new BzrError.
62
63
        There are two alternative forms for constructing these objects.
64
        Either a preformatted string may be passed, or a set of named
65
        arguments can be given.  The first is for generic "user" errors which
66
        are not intended to be caught and so do not need a specific subclass.
67
        The second case is for use with subclasses that provide a _fmt format
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
68
        string to print the arguments.
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
69
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
70
        Keyword arguments are taken as parameters to the error, which can
71
        be inserted into the format string template.  It's recommended
72
        that subclasses override the __init__ method to require specific
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
73
        parameters.
74
2067.3.2 by Martin Pool
Error cleanup review comments:
75
        :param msg: If given, this is the literal complete text for the error,
3734.2.7 by Vincent Ladeuil
Fix python-2.6 BaseException 'message' attribute deprecation.
76
           not subject to expansion. 'msg' is used instead of 'message' because
77
           python evolved and, in 2.6, forbids the use of 'message'.
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
78
        """
6619.3.9 by Jelmer Vernooij
Run 2to3 standarderror fixer.
79
        Exception.__init__(self)
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
80
        if msg is not None:
2067.3.4 by Martin Pool
Error deprecations will come in for 0.13
81
            # I was going to deprecate this, but it actually turns out to be
82
            # quite handy - mbp 20061103.
2067.3.2 by Martin Pool
Error cleanup review comments:
83
            self._preformatted_string = msg
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
84
        else:
2067.3.2 by Martin Pool
Error cleanup review comments:
85
            self._preformatted_string = None
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
86
            for key, value in kwds.items():
87
                setattr(self, key, value)
88
3577.1.1 by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom.
89
    def _format(self):
2067.3.2 by Martin Pool
Error cleanup review comments:
90
        s = getattr(self, '_preformatted_string', None)
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
91
        if s is not None:
3577.1.3 by Andrew Bennetts
Fix test_trace failure: BzrError._format shouldn't call str() itself, it should leave that to __str__.
92
            # contains a preformatted message
93
            return s
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
94
        err = None
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
95
        try:
2067.3.2 by Martin Pool
Error cleanup review comments:
96
            fmt = self._get_format_string()
97
            if fmt:
2854.1.2 by Martin Pool
Review feedback on BzrError.message handling
98
                d = dict(self.__dict__)
2854.1.1 by Martin Pool
Fix "unprintable error" message for BzrCheckError and others
99
                s = fmt % d
2067.3.2 by Martin Pool
Error cleanup review comments:
100
                # __str__() should always return a 'str' object
101
                # never a 'unicode' object.
102
                return s
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
103
        except Exception as e:
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
104
            err = e
6318.2.3 by Martin Packman
Unify unprintable exception logic and catch all non-base exceptions
105
        return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
106
            % (self.__class__.__name__,
107
               self.__dict__,
108
               getattr(self, '_fmt', None),
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
109
               err)
110
111
    if PY3:
112
        __str__ = _format
113
    else:
114
        def __str__(self):
115
            return self._format().encode('utf-8')
116
117
        __unicode__ = _format
3577.1.1 by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom.
118
3786.4.3 by Andrew Bennetts
Add __repr__ to BzrError to make some test failure output clearer.
119
    def __repr__(self):
120
        return '%s(%s)' % (self.__class__.__name__, str(self))
121
2067.3.2 by Martin Pool
Error cleanup review comments:
122
    def _get_format_string(self):
123
        """Return format string for this exception or None"""
124
        fmt = getattr(self, '_fmt', None)
125
        if fmt is not None:
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
126
            from breezy.i18n import gettext
7143.15.2 by Jelmer Vernooij
Run autopep8.
127
            return gettext(fmt)  # _fmt strings should be ascii
2067.3.2 by Martin Pool
Error cleanup review comments:
128
3533.3.3 by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error.
129
    def __eq__(self, other):
4088.3.1 by Benjamin Peterson
compare types with 'is' not ==
130
        if self.__class__ is not other.__class__:
3533.3.3 by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error.
131
            return NotImplemented
132
        return self.__dict__ == other.__dict__
133
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
134
    def __hash__(self):
135
        return id(self)
136
1185.1.14 by Robert Collins
remove more duplicate merged hunks. Bad MERGE3, BAD.
137
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
138
class InternalBzrError(BzrError):
139
    """Base class for errors that are internal in nature.
140
141
    This is a convenience class for errors that are internal. The
142
    internal_error attribute can still be altered in subclasses, if needed.
143
    Using this class is simply an easy way to get internal errors.
144
    """
145
146
    internal_error = True
147
148
3221.11.2 by Robert Collins
Create basic stackable branch facility.
149
class BranchError(BzrError):
150
    """Base class for concrete 'errors about a branch'."""
151
152
    def __init__(self, branch):
153
        BzrError.__init__(self, branch=branch)
154
155
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
156
class BzrCheckError(InternalBzrError):
2929.3.5 by Vincent Ladeuil
New files, same warnings, same fixes.
157
158
    _fmt = "Internal check failed: %(msg)s"
159
160
    def __init__(self, msg):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
161
        BzrError.__init__(self)
2929.3.5 by Vincent Ladeuil
New files, same warnings, same fixes.
162
        self.msg = msg
1185.16.63 by Martin Pool
- more error conversion
163
164
6672.1.2 by Jelmer Vernooij
Remove breezy.api.
165
class IncompatibleVersion(BzrError):
2550.2.3 by Robert Collins
Add require_api API.
166
6672.1.2 by Jelmer Vernooij
Remove breezy.api.
167
    _fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\
168
           'is required, but current version is %(current)r.'
2550.2.3 by Robert Collins
Add require_api API.
169
6672.1.1 by Jelmer Vernooij
Simplify breezy.api.
170
    def __init__(self, api, wanted, current):
2550.2.3 by Robert Collins
Add require_api API.
171
        self.api = api
172
        self.wanted = wanted
173
        self.current = current
174
175
2634.1.1 by Robert Collins
(robertc) Reinstate the accidentally backed out external_url patch.
176
class InProcessTransport(BzrError):
177
178
    _fmt = "The transport '%(transport)s' is only accessible within this " \
179
        "process."
180
181
    def __init__(self, transport):
182
        self.transport = transport
183
184
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
185
class InvalidEntryName(InternalBzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
186
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
187
    _fmt = "Invalid entry name: %(name)s"
1740.5.6 by Martin Pool
Clean up many exception classes.
188
1185.16.63 by Martin Pool
- more error conversion
189
    def __init__(self, name):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
190
        BzrError.__init__(self)
1185.16.63 by Martin Pool
- more error conversion
191
        self.name = name
192
193
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
194
class InvalidRevisionNumber(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
195
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
196
    _fmt = "Invalid revision number %(revno)s"
197
1185.16.63 by Martin Pool
- more error conversion
198
    def __init__(self, revno):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
199
        BzrError.__init__(self)
1185.16.63 by Martin Pool
- more error conversion
200
        self.revno = revno
201
202
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
203
class InvalidRevisionId(BzrError):
204
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
205
    _fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
206
1185.16.103 by mbp at sourcefrog
Fix up all calls to InvalidRevisionId() to specify parameters.
207
    def __init__(self, revision_id, branch):
1668.5.1 by Olaf Conradi
Fix bug in knits when raising InvalidRevisionId without the required
208
        # branch can be any string or object with __str__ defined
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
209
        BzrError.__init__(self)
1185.12.90 by Aaron Bentley
Fixed InvalidRevisionID handling in Branch.get_revision_xml
210
        self.revision_id = revision_id
1185.16.103 by mbp at sourcefrog
Fix up all calls to InvalidRevisionId() to specify parameters.
211
        self.branch = branch
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
212
3006.2.1 by Alexander Belchenko
workaround for bug #81689: give a proper error message instead of traceback when symlink cannot be created (e.g. on Windows)
213
2229.2.1 by Aaron Bentley
Reject reserved ids in versiondfile, tree, branch and repository
214
class ReservedId(BzrError):
2229.2.3 by Aaron Bentley
change reserved_id to is_reserved_id, add check_not_reserved for DRY
215
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
216
    _fmt = "Reserved revision-id {%(revision_id)s}"
2229.2.3 by Aaron Bentley
change reserved_id to is_reserved_id, add check_not_reserved for DRY
217
2229.2.1 by Aaron Bentley
Reject reserved ids in versiondfile, tree, branch and repository
218
    def __init__(self, revision_id):
219
        self.revision_id = revision_id
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
220
2432.1.4 by Robert Collins
Add an explicit error for missing help topics.
221
2871.1.2 by Robert Collins
* ``CommitBuilder.record_entry_contents`` now requires the root entry of a
222
class RootMissing(InternalBzrError):
223
224
    _fmt = ("The root entry of a tree must be the first entry supplied to "
7143.15.2 by Jelmer Vernooij
Run autopep8.
225
            "the commit builder.")
2871.1.2 by Robert Collins
* ``CommitBuilder.record_entry_contents`` now requires the root entry of a
226
227
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
228
class NoPublicBranch(BzrError):
229
230
    _fmt = 'There is no public branch set for "%(branch_url)s".'
231
232
    def __init__(self, branch):
6653.6.6 by Jelmer Vernooij
Fix remaining tests.
233
        from . import urlutils
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
234
        public_location = urlutils.unescape_for_display(branch.base, 'ascii')
235
        BzrError.__init__(self, branch_url=public_location)
236
237
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
238
class NoSuchId(BzrError):
239
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
240
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
241
1988.2.1 by Robert Collins
WorkingTree has a new api ``unversion`` which allow the unversioning of
242
    def __init__(self, tree, file_id):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
243
        BzrError.__init__(self)
1988.2.1 by Robert Collins
WorkingTree has a new api ``unversion`` which allow the unversioning of
244
        self.file_id = file_id
245
        self.tree = tree
246
247
3221.11.2 by Robert Collins
Create basic stackable branch facility.
248
class NotStacked(BranchError):
249
250
    _fmt = "The branch '%(branch)s' is not stacked."
251
252
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
253
class NoWorkingTree(BzrError):
254
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
255
    _fmt = 'No WorkingTree exists for "%(base)s".'
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
256
1497 by Robert Collins
Move Branch.read_working_inventory to WorkingTree.
257
    def __init__(self, base):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
258
        BzrError.__init__(self)
1497 by Robert Collins
Move Branch.read_working_inventory to WorkingTree.
259
        self.base = base
1506 by Robert Collins
Merge Johns current integration work.
260
261
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
262
class NotLocalUrl(BzrError):
263
264
    _fmt = "%(url)s is not a local path."
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
265
1534.4.42 by Robert Collins
add working tree to the BzrDir facilities.
266
    def __init__(self, url):
267
        self.url = url
268
269
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
270
class WorkingTreeAlreadyPopulated(InternalBzrError):
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
271
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
272
    _fmt = 'Working tree already populated in "%(base)s"'
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
273
274
    def __init__(self, base):
275
        self.base = base
276
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
277
7336.2.1 by Martin
Split non-ini config methods to bedding
278
class NoWhoami(BzrError):
279
280
    _fmt = ('Unable to determine your name.\n'
281
            "Please, set your name with the 'whoami' command.\n"
282
            'E.g. brz whoami "Your Name <name@example.com>"')
283
284
7490.61.1 by Jelmer Vernooij
Rename BzrCommandError to CommandError.
285
class CommandError(BzrError):
1740.5.6 by Martin Pool
Clean up many exception classes.
286
    """Error from user command"""
1740.5.8 by Martin Pool
Review cleanups: better error reporting, put back report_exception.
287
288
    # Error from malformed user command; please avoid raising this as a
289
    # generic exception not caused by user input.
1185.54.18 by Aaron Bentley
Noted difference of opinion wrt BzrCommandError
290
    #
291
    # I think it's a waste of effort to differentiate between errors that
292
    # are not intended to be caught anyway.  UI code need not subclass
7490.61.1 by Jelmer Vernooij
Rename BzrCommandError to CommandError.
293
    # CommandError, and non-UI code should not throw a subclass of
294
    # CommandError.  ADHB 20051211
295
296
297
# Provide the old name as backup, for the moment.
7490.61.2 by Jelmer Vernooij
Fix typo.
298
BzrCommandError = CommandError
1740.5.6 by Martin Pool
Clean up many exception classes.
299
300
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
301
class NotWriteLocked(BzrError):
302
303
    _fmt = """%(not_locked)r is not write locked but needs to be."""
304
305
    def __init__(self, not_locked):
306
        self.not_locked = not_locked
307
308
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
309
class StrictCommitFailed(BzrError):
310
311
    _fmt = "Commit refused because there are unknown files in the tree"
1 by mbp at sourcefrog
import from baz patch-364
312
1185.31.41 by John Arbash Meinel
Creating a PathNotChild exception, and using relpath in HTTPTestUtil
313
1662.1.12 by Martin Pool
Translate unknown sftp errors to PathError, no NoSuchFile
314
# XXX: Should be unified with TransportError; they seem to represent the
315
# same thing
2052.6.1 by Robert Collins
``Transport.get`` has had its interface made more clear for ease of use.
316
# RBC 20060929: I think that unifiying with TransportError would be a mistake
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
317
# - this is finer than a TransportError - and more useful as such. It
2052.6.1 by Robert Collins
``Transport.get`` has had its interface made more clear for ease of use.
318
# differentiates between 'transport has failed' and 'operation on a transport
319
# has failed.'
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
320
class PathError(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
321
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
322
    _fmt = "Generic path error: %(path)r%(extra)s)"
1654.1.4 by Robert Collins
Teach `bzr init` how to init at the root of a repository.
323
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
324
    def __init__(self, path, extra=None):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
325
        BzrError.__init__(self)
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
326
        self.path = path
1908.4.11 by John Arbash Meinel
reverting changes to errors.py and local transport.
327
        if extra:
328
            self.extra = ': ' + str(extra)
329
        else:
330
            self.extra = ''
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
331
332
333
class NoSuchFile(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
334
335
    _fmt = "No such file: %(path)r%(extra)s"
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
336
337
338
class FileExists(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
339
340
    _fmt = "File exists: %(path)r%(extra)s"
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
341
342
2220.1.11 by Marius Kruger
* bzrlib/errors.py
343
class RenameFailedFilesExist(BzrError):
344
    """Used when renaming and both source and dest exist."""
345
2220.1.12 by Marius Kruger
* Fix errors.py import order
346
    _fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
347
            " (Use --after to tell brz about a rename that has already"
2967.3.6 by Daniel Watkins
Extracted the string from every use of RenameFailedFilesExist to RenameFailedFilesExist itself.
348
            " happened)%(extra)s")
2220.1.11 by Marius Kruger
* bzrlib/errors.py
349
350
    def __init__(self, source, dest, extra=None):
2206.1.5 by Marius Kruger
* errors
351
        BzrError.__init__(self)
2220.1.11 by Marius Kruger
* bzrlib/errors.py
352
        self.source = str(source)
353
        self.dest = str(dest)
2206.1.5 by Marius Kruger
* errors
354
        if extra:
2220.1.11 by Marius Kruger
* bzrlib/errors.py
355
            self.extra = ' ' + str(extra)
2206.1.5 by Marius Kruger
* errors
356
        else:
357
            self.extra = ''
358
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
359
2206.1.4 by Marius Kruger
Improved WorkingTree.move excptions. (as requested)
360
class NotADirectory(PathError):
361
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
362
    _fmt = '"%(path)s" is not a directory %(extra)s'
2206.1.4 by Marius Kruger
Improved WorkingTree.move excptions. (as requested)
363
364
365
class NotInWorkingDirectory(PathError):
366
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
367
    _fmt = '"%(path)s" is not in the working directory %(extra)s'
2206.1.4 by Marius Kruger
Improved WorkingTree.move excptions. (as requested)
368
369
1553.5.10 by Martin Pool
New DirectoryNotEmpty exception, and raise this from local and memory
370
class DirectoryNotEmpty(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
371
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
372
    _fmt = 'Directory not empty: "%(path)s"%(extra)s'
1553.5.10 by Martin Pool
New DirectoryNotEmpty exception, and raise this from local and memory
373
374
3136.1.10 by Aaron Bentley
Clean error if filesystem does not support hard-links
375
class HardLinkNotSupported(PathError):
376
377
    _fmt = 'Hard-linking "%(path)s" is not supported'
378
379
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
380
class ReadingCompleted(InternalBzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
381
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
382
    _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
383
            "called upon it - the request has been completed and no more "
384
            "data may be read.")
385
2018.2.4 by Robert Collins
separate out the client medium from the client encoding protocol for the smart server.
386
    def __init__(self, request):
387
        self.request = request
388
389
1558.10.1 by Aaron Bentley
Handle lockdirs over NFS properly
390
class ResourceBusy(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
391
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
392
    _fmt = 'Device or resource busy: "%(path)s"%(extra)s'
1558.10.1 by Aaron Bentley
Handle lockdirs over NFS properly
393
394
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
395
class PermissionDenied(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
396
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
397
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
1740.5.8 by Martin Pool
Review cleanups: better error reporting, put back report_exception.
398
399
1843.1.1 by John Arbash Meinel
Update get_transport to raise a nicer error which includes dependency info
400
class UnsupportedProtocol(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
401
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
402
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
1843.1.1 by John Arbash Meinel
Update get_transport to raise a nicer error which includes dependency info
403
6030.2.1 by Jelmer Vernooij
Create location_to_url.
404
    def __init__(self, url, extra=""):
1843.1.1 by John Arbash Meinel
Update get_transport to raise a nicer error which includes dependency info
405
        PathError.__init__(self, url, extra=extra)
406
407
4462.3.2 by Robert Collins
Do not stack on the same branch/repository anymore. This was never supported and would generally result in infinite recursion. Fixes bug 376243.
408
class UnstackableLocationError(BzrError):
409
410
    _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
411
412
    def __init__(self, branch_url, target_url):
413
        BzrError.__init__(self)
414
        self.branch_url = branch_url
415
        self.target_url = target_url
416
417
3221.11.2 by Robert Collins
Create basic stackable branch facility.
418
class UnstackableRepositoryFormat(BzrError):
419
420
    _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
7143.15.2 by Jelmer Vernooij
Run autopep8.
421
            "You will need to upgrade the repository to permit branch stacking.")
3221.11.2 by Robert Collins
Create basic stackable branch facility.
422
423
    def __init__(self, format, url):
424
        BzrError.__init__(self)
425
        self.format = format
426
        self.url = url
427
428
2052.6.1 by Robert Collins
``Transport.get`` has had its interface made more clear for ease of use.
429
class ReadError(PathError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
430
2052.6.2 by Robert Collins
Merge bzr.dev.
431
    _fmt = """Error reading from %(path)r."""
2052.6.1 by Robert Collins
``Transport.get`` has had its interface made more clear for ease of use.
432
433
2001.3.2 by John Arbash Meinel
Force all transports to raise ShortReadvError if they can
434
class ShortReadvError(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
435
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
436
    _fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
437
            ' at %(offset)s for "%(path)s"%(extra)s')
2001.3.2 by John Arbash Meinel
Force all transports to raise ShortReadvError if they can
438
2067.3.2 by Martin Pool
Error cleanup review comments:
439
    internal_error = True
2001.3.2 by John Arbash Meinel
Force all transports to raise ShortReadvError if they can
440
2001.3.3 by John Arbash Meinel
review feedback: add the actual count written to ShortReadvError
441
    def __init__(self, path, offset, length, actual, extra=None):
2001.3.2 by John Arbash Meinel
Force all transports to raise ShortReadvError if they can
442
        PathError.__init__(self, path, extra=extra)
443
        self.offset = offset
444
        self.length = length
2001.3.3 by John Arbash Meinel
review feedback: add the actual count written to ShortReadvError
445
        self.actual = actual
2001.3.2 by John Arbash Meinel
Force all transports to raise ShortReadvError if they can
446
447
2485.8.18 by Vincent Ladeuil
PathNotChild inherits from PathError, not BzrError.
448
class PathNotChild(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
449
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
450
    _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
1740.5.6 by Martin Pool
Clean up many exception classes.
451
5346.3.1 by Martin Pool
* `PathNotChild` should not give a traceback.
452
    internal_error = False
1740.5.6 by Martin Pool
Clean up many exception classes.
453
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
454
    def __init__(self, path, base, extra=None):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
455
        BzrError.__init__(self)
1185.31.41 by John Arbash Meinel
Creating a PathNotChild exception, and using relpath in HTTPTestUtil
456
        self.path = path
457
        self.base = base
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
458
        if extra:
459
            self.extra = ': ' + str(extra)
460
        else:
461
            self.extra = ''
1185.31.41 by John Arbash Meinel
Creating a PathNotChild exception, and using relpath in HTTPTestUtil
462
463
1830.3.5 by John Arbash Meinel
make_entry refuses to create non-normalized entries.
464
class InvalidNormalization(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
465
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
466
    _fmt = 'Path "%(path)s" is not unicode normalized'
1830.3.5 by John Arbash Meinel
make_entry refuses to create non-normalized entries.
467
468
1685.1.60 by Martin Pool
[broken] NotBranchError should unescape the url if possible
469
# TODO: This is given a URL; we try to unescape it but doing that from inside
470
# the exception object is a bit undesirable.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
471
# TODO: Probably this behavior of should be a common superclass
1654.1.4 by Robert Collins
Teach `bzr init` how to init at the root of a repository.
472
class NotBranchError(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
473
4734.4.7 by Andrew Bennetts
Defer checking for a repository in NotBranchError case until we format the error as a string. (test_smart currently fails)
474
    _fmt = 'Not a branch: "%(path)s"%(detail)s.'
1685.1.60 by Martin Pool
[broken] NotBranchError should unescape the url if possible
475
6653.6.4 by Jelmer Vernooij
Merge trunk.
476
    def __init__(self, path, detail=None, controldir=None):
7143.15.2 by Jelmer Vernooij
Run autopep8.
477
        from . import urlutils
478
        path = urlutils.unescape_for_display(path, 'ascii')
479
        if detail is not None:
480
            detail = ': ' + detail
481
        self.detail = detail
482
        self.controldir = controldir
483
        PathError.__init__(self, path=path)
4734.4.7 by Andrew Bennetts
Defer checking for a repository in NotBranchError case until we format the error as a string. (test_smart currently fails)
484
5050.60.1 by Andrew Bennetts
Override __repr__ in NotBranchError to avoid side-effects during repr(e).
485
    def __repr__(self):
486
        return '<%s %r>' % (self.__class__.__name__, self.__dict__)
487
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
488
    def _get_format_string(self):
489
        # GZ 2017-06-08: Not the best place to lazy fill detail in.
4734.4.7 by Andrew Bennetts
Defer checking for a repository in NotBranchError case until we format the error as a string. (test_smart currently fails)
490
        if self.detail is None:
7143.15.2 by Jelmer Vernooij
Run autopep8.
491
            self.detail = self._get_detail()
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
492
        return super(NotBranchError, self)._get_format_string()
493
494
    def _get_detail(self):
6653.6.4 by Jelmer Vernooij
Merge trunk.
495
        if self.controldir is not None:
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
496
            try:
6653.6.4 by Jelmer Vernooij
Merge trunk.
497
                self.controldir.open_repository()
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
498
            except NoRepositoryPresent:
499
                return ''
500
            except Exception as e:
501
                # Just ignore unexpected errors.  Raising arbitrary errors
502
                # during str(err) can provoke strange bugs.  Concretely
503
                # Launchpad's codehosting managed to raise NotBranchError
504
                # here, and then get stuck in an infinite loop/recursion
505
                # trying to str() that error.  All this error really cares
506
                # about that there's no working repository there, and if
507
                # open_repository() fails, there probably isn't.
508
                return ': ' + e.__class__.__name__
4734.4.7 by Andrew Bennetts
Defer checking for a repository in NotBranchError case until we format the error as a string. (test_smart currently fails)
509
            else:
6670.3.1 by Martin
Initial work to make errors module Python 3 compatible
510
                return ': location is a repository'
511
        return ''
1654.1.4 by Robert Collins
Teach `bzr init` how to init at the root of a repository.
512
513
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
514
class NoSubmitBranch(PathError):
515
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
516
    _fmt = 'No submit branch available for branch "%(path)s"'
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
517
518
    def __init__(self, branch):
7143.15.2 by Jelmer Vernooij
Run autopep8.
519
        from . import urlutils
520
        self.path = urlutils.unescape_for_display(branch.base, 'ascii')
1551.10.32 by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs
521
522
6437.10.2 by Jelmer Vernooij
Raise AlreadyControlDirError.
523
class AlreadyControlDirError(PathError):
524
525
    _fmt = 'A control directory already exists: "%(path)s".'
526
527
1654.1.4 by Robert Collins
Teach `bzr init` how to init at the root of a repository.
528
class AlreadyBranchError(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
529
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
530
    _fmt = 'Already a branch: "%(path)s".'
1662.1.19 by Martin Pool
Better error message when initting existing tree
531
532
6478.2.3 by Jelmer Vernooij
s/InvalidEntryName/InvalidBranchName/
533
class InvalidBranchName(PathError):
534
535
    _fmt = "Invalid branch name: %(name)s"
536
537
    def __init__(self, name):
538
        BzrError.__init__(self)
539
        self.name = name
540
541
6437.18.2 by Jelmer Vernooij
Check for slashes in branch names.
542
class ParentBranchExists(AlreadyBranchError):
543
544
    _fmt = 'Parent branch already exists: "%(path)s".'
545
546
1662.1.19 by Martin Pool
Better error message when initting existing tree
547
class BranchExistsWithoutWorkingTree(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
548
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
549
    _fmt = 'Directory contains a branch, but no working tree \
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
550
(use brz checkout if you wish to build a working tree): "%(path)s"'
1755.3.6 by John Arbash Meinel
Add a test suite for Atomic File, and clean it up so that it really does set the mode properly.
551
552
1864.7.2 by John Arbash Meinel
Test that we copy the parent across properly (if it is available)
553
class InaccessibleParent(PathError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
554
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
555
    _fmt = ('Parent not accessible given base "%(base)s" and'
556
            ' relative path "%(path)s"')
1864.7.2 by John Arbash Meinel
Test that we copy the parent across properly (if it is available)
557
558
    def __init__(self, path, base):
559
        PathError.__init__(self, path)
560
        self.base = base
561
562
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
563
class NoRepositoryPresent(BzrError):
564
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
565
    _fmt = 'No repository present: "%(path)s"'
7143.15.2 by Jelmer Vernooij
Run autopep8.
566
6653.6.4 by Jelmer Vernooij
Merge trunk.
567
    def __init__(self, controldir):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
568
        BzrError.__init__(self)
6653.6.4 by Jelmer Vernooij
Merge trunk.
569
        self.path = controldir.transport.clone('..').base
1534.4.47 by Robert Collins
Split out repository into .bzr/repository
570
571
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
572
class UnsupportedFormatError(BzrError):
2379.4.1 by John Arbash Meinel
(John Arbash Meinel) Make it clearer what to do if you have a (very) old branch.
573
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
574
    _fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
575
576
577
class UnknownFormatError(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
578
3246.3.1 by Daniel Watkins
Modified UnknownFormatError to allow a kind to be specified.
579
    _fmt = "Unknown %(kind)s format: %(format)r"
580
581
    def __init__(self, format, kind='branch'):
582
        self.kind = kind
583
        self.format = format
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
584
585
586
class IncompatibleFormat(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
587
6653.6.4 by Jelmer Vernooij
Merge trunk.
588
    _fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
1534.4.44 by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory.
589
6653.6.4 by Jelmer Vernooij
Merge trunk.
590
    def __init__(self, format, controldir_format):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
591
        BzrError.__init__(self)
1534.4.44 by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory.
592
        self.format = format
6653.6.4 by Jelmer Vernooij
Merge trunk.
593
        self.controldir = controldir_format
1534.4.44 by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory.
594
595
6213.1.53 by Jelmer Vernooij
Add ParseFormatError.
596
class ParseFormatError(BzrError):
597
598
    _fmt = "Parse error on line %(lineno)d of %(format)s format: %(line)s"
599
600
    def __init__(self, format, lineno, line, text):
601
        BzrError.__init__(self)
602
        self.format = format
603
        self.lineno = lineno
604
        self.line = line
605
        self.text = text
606
607
2323.8.2 by Aaron Bentley
Give a nicer error on fetch when repos are in incompatible formats
608
class IncompatibleRepositories(BzrError):
4650.2.1 by Robert Collins
Deserialise IncompatibleRepositories errors in the client, generating
609
    """Report an error that two repositories are not compatible.
610
611
    Note that the source and target repositories are permitted to be strings:
612
    this exception is thrown from the smart server and may refer to a
613
    repository the client hasn't opened.
614
    """
2323.8.2 by Aaron Bentley
Give a nicer error on fetch when repos are in incompatible formats
615
3582.1.2 by Martin Pool
Default InterRepository.fetch raises IncompatibleRepositories
616
    _fmt = "%(target)s\n" \
7143.15.2 by Jelmer Vernooij
Run autopep8.
617
        "is not compatible with\n" \
618
        "%(source)s\n" \
619
        "%(details)s"
2323.8.2 by Aaron Bentley
Give a nicer error on fetch when repos are in incompatible formats
620
3582.1.2 by Martin Pool
Default InterRepository.fetch raises IncompatibleRepositories
621
    def __init__(self, source, target, details=None):
3582.1.5 by Martin Pool
style tweak
622
        if details is None:
3582.1.2 by Martin Pool
Default InterRepository.fetch raises IncompatibleRepositories
623
            details = "(no details)"
624
        BzrError.__init__(self, target=target, source=source, details=details)
2323.8.2 by Aaron Bentley
Give a nicer error on fetch when repos are in incompatible formats
625
626
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
627
class IncompatibleRevision(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
628
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
629
    _fmt = "Revision is not compatible with %(repo_format)s"
1910.2.60 by Aaron Bentley
Ensure that new-model revisions aren't installed into old-model repos
630
631
    def __init__(self, repo_format):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
632
        BzrError.__init__(self)
1910.2.60 by Aaron Bentley
Ensure that new-model revisions aren't installed into old-model repos
633
        self.repo_format = repo_format
634
635
2206.1.5 by Marius Kruger
* errors
636
class AlreadyVersionedError(BzrError):
2206.1.7 by Marius Kruger
* errors
637
    """Used when a path is expected not to be versioned, but it is."""
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
638
2745.3.1 by Daniel Watkins
Modified errors.py to quote paths just before full stops. Also added some full stops to error messages without them.
639
    _fmt = "%(context_info)s%(path)s is already versioned."
2206.1.5 by Marius Kruger
* errors
640
2206.1.7 by Marius Kruger
* errors
641
    def __init__(self, path, context_info=None):
2255.2.29 by Robert Collins
Change the error raised from Dirstate.add for an unversioned parent path to match the WorkingTree interface.
642
        """Construct a new AlreadyVersionedError.
2206.1.5 by Marius Kruger
* errors
643
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
644
        :param path: This is the path which is versioned,
5891.1.2 by Andrew Bennetts
Fix a bunch of docstring formatting nits, making pydoctor a bit happier.
645
            which should be in a user friendly form.
2206.1.7 by Marius Kruger
* errors
646
        :param context_info: If given, this is information about the context,
5891.1.2 by Andrew Bennetts
Fix a bunch of docstring formatting nits, making pydoctor a bit happier.
647
            which could explain why this is expected to not be versioned.
2206.1.5 by Marius Kruger
* errors
648
        """
649
        BzrError.__init__(self)
650
        self.path = path
2206.1.7 by Marius Kruger
* errors
651
        if context_info is None:
652
            self.context_info = ''
2206.1.5 by Marius Kruger
* errors
653
        else:
2206.1.7 by Marius Kruger
* errors
654
            self.context_info = context_info + ". "
2206.1.5 by Marius Kruger
* errors
655
656
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
657
class NotVersionedError(BzrError):
2206.1.7 by Marius Kruger
* errors
658
    """Used when a path is expected to be versioned, but it is not."""
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
659
2745.3.1 by Daniel Watkins
Modified errors.py to quote paths just before full stops. Also added some full stops to error messages without them.
660
    _fmt = "%(context_info)s%(path)s is not versioned."
2206.1.2 by Marius Kruger
* Made whitespace and puntuation improvements, as requested.
661
2206.1.7 by Marius Kruger
* errors
662
    def __init__(self, path, context_info=None):
2206.1.2 by Marius Kruger
* Made whitespace and puntuation improvements, as requested.
663
        """Construct a new NotVersionedError.
664
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
665
        :param path: This is the path which is not versioned,
5891.1.2 by Andrew Bennetts
Fix a bunch of docstring formatting nits, making pydoctor a bit happier.
666
            which should be in a user friendly form.
2206.1.7 by Marius Kruger
* errors
667
        :param context_info: If given, this is information about the context,
5891.1.2 by Andrew Bennetts
Fix a bunch of docstring formatting nits, making pydoctor a bit happier.
668
            which could explain why this is expected to be versioned.
2206.1.2 by Marius Kruger
* Made whitespace and puntuation improvements, as requested.
669
        """
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
670
        BzrError.__init__(self)
1185.16.72 by Martin Pool
[merge] from robert and fix up tests
671
        self.path = path
2206.1.7 by Marius Kruger
* errors
672
        if context_info is None:
673
            self.context_info = ''
2206.1.2 by Marius Kruger
* Made whitespace and puntuation improvements, as requested.
674
        else:
2206.1.7 by Marius Kruger
* errors
675
            self.context_info = context_info + ". "
2206.1.8 by Marius Kruger
Converted move/rename error messages to show source => target.
676
677
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
678
class PathsNotVersionedError(BzrError):
2206.1.7 by Marius Kruger
* errors
679
    """Used when reporting several paths which are not versioned"""
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
680
681
    _fmt = "Path(s) are not versioned: %(paths_as_string)s"
1658.1.9 by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619)
682
683
    def __init__(self, paths):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
684
        from breezy.osutils import quotefn
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
685
        BzrError.__init__(self)
1658.1.9 by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619)
686
        self.paths = paths
687
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
688
689
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
690
class PathsDoNotExist(BzrError):
691
2206.1.5 by Marius Kruger
* errors
692
    _fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
1662.1.14 by Martin Pool
(PathsDoNotExist) review style comments
693
1662.1.9 by Martin Pool
Give a clear error for bzr status of an unversioned, nonexistent file. (Malone #3619)
694
    # used when reporting that paths are neither versioned nor in the working
695
    # tree
696
2206.1.5 by Marius Kruger
* errors
697
    def __init__(self, paths, extra=None):
1662.1.14 by Martin Pool
(PathsDoNotExist) review style comments
698
        # circular import
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
699
        from breezy.osutils import quotefn
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
700
        BzrError.__init__(self)
1662.1.9 by Martin Pool
Give a clear error for bzr status of an unversioned, nonexistent file. (Malone #3619)
701
        self.paths = paths
702
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
2206.1.5 by Marius Kruger
* errors
703
        if extra:
704
            self.extra = ': ' + str(extra)
705
        else:
706
            self.extra = ''
1662.1.9 by Martin Pool
Give a clear error for bzr status of an unversioned, nonexistent file. (Malone #3619)
707
708
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
709
class BadFileKindError(BzrError):
710
2100.3.21 by Aaron Bentley
Work on checking out by-reference trees
711
    _fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
712
713
    def __init__(self, filename, kind):
714
        BzrError.__init__(self, filename=filename, kind=kind)
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
715
716
3287.20.2 by John Arbash Meinel
Raise a clear error about the offending filename when there is a filename with bad characters.
717
class BadFilenameEncoding(BzrError):
718
719
    _fmt = ('Filename %(filename)r is not valid in your current filesystem'
720
            ' encoding %(fs_encoding)s')
721
722
    def __init__(self, filename, fs_encoding):
723
        BzrError.__init__(self)
724
        self.filename = filename
725
        self.fs_encoding = fs_encoding
726
727
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
728
class ForbiddenControlFileError(BzrError):
729
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
730
    _fmt = 'Cannot operate on "%(filename)s" because it is a control file'
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
731
732
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
733
class LockError(InternalBzrError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
734
2321.3.6 by Alexander Belchenko
LockError produce unprintable exception on Python 2.5 because it try to override StandardError.message attribute
735
    _fmt = "Lock error: %(msg)s"
2221.2.2 by Aaron Bentley
PEP8-correctness
736
1185.16.63 by Martin Pool
- more error conversion
737
    # All exceptions from the lock/unlock functions should be from
738
    # this exception class.  They will be translated as necessary. The
739
    # original exception is available as e.original_error
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
740
    #
741
    # New code should prefer to raise specific subclasses
5050.8.1 by Parth Malwankar
added test to ensure that BzrError subclasses dont use "message" as a name
742
    def __init__(self, msg):
743
        self.msg = msg
882 by Martin Pool
- Optionally raise EmptyCommit if there are no changes. Test for this.
744
745
2255.2.145 by Robert Collins
Support unbreakable locks for trees.
746
class LockActive(LockError):
747
748
    _fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
749
750
    internal_error = False
751
752
    def __init__(self, lock_description):
753
        self.lock_description = lock_description
754
755
1417.1.6 by Robert Collins
introduce transactions for grouping actions done to and with branches
756
class CommitNotPossible(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
757
758
    _fmt = "A commit was attempted but we do not have a write lock open."
2067.3.2 by Martin Pool
Error cleanup review comments:
759
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
760
    def __init__(self):
761
        pass
1417.1.6 by Robert Collins
introduce transactions for grouping actions done to and with branches
762
763
764
class AlreadyCommitted(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
765
766
    _fmt = "A rollback was requested, but is not able to be accomplished."
2067.3.2 by Martin Pool
Error cleanup review comments:
767
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
768
    def __init__(self):
769
        pass
1417.1.6 by Robert Collins
introduce transactions for grouping actions done to and with branches
770
771
1417.1.8 by Robert Collins
use transactions in the weave store interface, which enables caching for log
772
class ReadOnlyError(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
773
774
    _fmt = "A write attempt was made in a read only transaction on %(obj)s"
2067.3.2 by Martin Pool
Error cleanup review comments:
775
2255.2.158 by Martin Pool
Most of the integration of dirstate and subtree
776
    # TODO: There should also be an error indicating that you need a write
777
    # lock and don't have any lock at all... mbp 20070226
778
1553.5.33 by Martin Pool
LockDir review comment fixes
779
    def __init__(self, obj):
780
        self.obj = obj
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
781
782
2872.5.1 by Martin Pool
Avoid internal error tracebacks on failure to lock on readonly transport (#129701).
783
class LockFailed(LockError):
784
785
    internal_error = False
786
787
    _fmt = "Cannot lock %(lock)s: %(why)s"
788
789
    def __init__(self, lock, why):
790
        LockError.__init__(self, '')
791
        self.lock = lock
792
        self.why = why
793
794
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
795
class OutSideTransaction(BzrError):
796
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
797
    _fmt = ("A transaction related operation was attempted after"
798
            " the transaction finished.")
1594.2.21 by Robert Collins
Teach versioned files to prevent mutation after finishing.
799
800
1553.5.36 by Martin Pool
Clean up duplicate BranchNotLocked error and rename to ObjectNotLocked
801
class ObjectNotLocked(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
802
803
    _fmt = "%(obj)r is not locked"
1740.5.8 by Martin Pool
Review cleanups: better error reporting, put back report_exception.
804
1553.5.36 by Martin Pool
Clean up duplicate BranchNotLocked error and rename to ObjectNotLocked
805
    # this can indicate that any particular object is not locked; see also
806
    # LockNotHeld which means that a particular *lock* object is not held by
807
    # the caller -- perhaps they should be unified.
808
    def __init__(self, obj):
809
        self.obj = obj
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
810
811
812
class ReadOnlyObjectDirtiedError(ReadOnlyError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
813
814
    _fmt = "Cannot change object %(obj)r in read only transaction"
2067.3.2 by Martin Pool
Error cleanup review comments:
815
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
816
    def __init__(self, obj):
817
        self.obj = obj
818
819
820
class UnlockableTransport(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
821
2872.5.1 by Martin Pool
Avoid internal error tracebacks on failure to lock on readonly transport (#129701).
822
    internal_error = False
823
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
824
    _fmt = "Cannot lock: transport is read only: %(transport)s"
2067.3.2 by Martin Pool
Error cleanup review comments:
825
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
826
    def __init__(self, transport):
827
        self.transport = transport
828
829
830
class LockContention(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
831
4121.1.1 by Martin Pool
Python2.6 dislikes the attribute name Exception.message
832
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
2221.2.2 by Aaron Bentley
PEP8-correctness
833
2221.2.1 by Aaron Bentley
Make most lock errors internal
834
    internal_error = False
2353.4.3 by John Arbash Meinel
Implement a 'ReadLock.temporary_write_lock()' to upgrade to a write-lock in-process.
835
4121.1.1 by Martin Pool
Python2.6 dislikes the attribute name Exception.message
836
    def __init__(self, lock, msg=''):
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
837
        self.lock = lock
4121.1.1 by Martin Pool
Python2.6 dislikes the attribute name Exception.message
838
        self.msg = msg
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
839
840
1553.5.23 by Martin Pool
Start LockDir.confirm method and LockBroken exception
841
class LockBroken(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
842
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
843
    _fmt = ("Lock was broken while still open: %(lock)s"
844
            " - check storage consistency!")
2221.2.2 by Aaron Bentley
PEP8-correctness
845
2221.2.1 by Aaron Bentley
Make most lock errors internal
846
    internal_error = False
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
847
1553.5.23 by Martin Pool
Start LockDir.confirm method and LockBroken exception
848
    def __init__(self, lock):
849
        self.lock = lock
850
851
1553.5.27 by Martin Pool
Confirm that only the intended holder of a lock was broken.
852
class LockBreakMismatch(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
853
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
854
    _fmt = ("Lock was released and re-acquired before being broken:"
855
            " %(lock)s: held by %(holder)r, wanted to break %(target)r")
2221.2.2 by Aaron Bentley
PEP8-correctness
856
2221.2.1 by Aaron Bentley
Make most lock errors internal
857
    internal_error = False
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
858
1553.5.27 by Martin Pool
Confirm that only the intended holder of a lock was broken.
859
    def __init__(self, lock, holder, target):
860
        self.lock = lock
861
        self.holder = holder
862
        self.target = target
863
864
4634.161.1 by Andrew Bennetts
Add LockCorrupt error, and use it to provide nicer handling of unparseable lock/held/info files.
865
class LockCorrupt(LockError):
866
867
    _fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
868
            "Use 'brz break-lock' to clear it")
4634.161.1 by Andrew Bennetts
Add LockCorrupt error, and use it to provide nicer handling of unparseable lock/held/info files.
869
870
    internal_error = False
871
872
    def __init__(self, corruption_info, file_data=None):
873
        self.corruption_info = corruption_info
874
        self.file_data = file_data
875
876
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
877
class LockNotHeld(LockError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
878
879
    _fmt = "Lock not held: %(lock)s"
2221.2.2 by Aaron Bentley
PEP8-correctness
880
2221.2.1 by Aaron Bentley
Make most lock errors internal
881
    internal_error = False
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
882
1553.5.11 by Martin Pool
Change some lock and transaction related exceptions to BzrNewException style
883
    def __init__(self, lock):
884
        self.lock = lock
885
886
2279.7.1 by Andrew Bennetts
``LockableFiles.lock_write()`` now accepts a ``token`` keyword argument, so that
887
class TokenLockingNotSupported(LockError):
888
889
    _fmt = "The object %(obj)s does not support token specifying a token when locking."
890
891
    def __init__(self, obj):
892
        self.obj = obj
893
894
2018.5.78 by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the
895
class TokenMismatch(LockBroken):
2279.7.1 by Andrew Bennetts
``LockableFiles.lock_write()`` now accepts a ``token`` keyword argument, so that
896
897
    _fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
898
899
    internal_error = True
900
901
    def __init__(self, given_token, lock_token):
902
        self.given_token = given_token
903
        self.lock_token = lock_token
904
905
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
906
class UpgradeReadonly(BzrError):
907
908
    _fmt = "Upgrade URL cannot work with readonly URLs."
909
910
911
class UpToDateFormat(BzrError):
912
913
    _fmt = "The branch format %(format)s is already at the most recent format."
1534.5.7 by Robert Collins
Start factoring out the upgrade policy logic.
914
915
    def __init__(self, format):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
916
        BzrError.__init__(self)
1534.5.7 by Robert Collins
Start factoring out the upgrade policy logic.
917
        self.format = format
918
919
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
920
class NoSuchRevision(InternalBzrError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
921
2696.3.3 by Martin Pool
Start setting the default format to dirstate-tags
922
    _fmt = "%(branch)s has no revision %(revision)s"
1740.5.6 by Martin Pool
Clean up many exception classes.
923
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
924
    def __init__(self, branch, revision):
2696.3.3 by Martin Pool
Start setting the default format to dirstate-tags
925
        # 'branch' may sometimes be an internal object like a KnitRevisionStore
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
926
        BzrError.__init__(self, branch=branch, revision=revision)
927
928
2745.4.4 by Lukáš Lalinsky
- Make the description of --change more general
929
class RangeInChangeOption(BzrError):
930
931
    _fmt = "Option --change does not accept revision ranges"
932
933
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
934
class NoSuchRevisionSpec(BzrError):
935
936
    _fmt = "No namespace registered for string: %(spec)r"
1948.4.25 by John Arbash Meinel
Check that invalid specs are properly handled
937
938
    def __init__(self, spec):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
939
        BzrError.__init__(self, spec=spec)
940
941
1908.11.1 by Robert Collins
Add a new method ``Tree.revision_tree`` which allows access to cached
942
class NoSuchRevisionInTree(NoSuchRevision):
1908.11.5 by John Arbash Meinel
[merge] bzr.dev 2240
943
    """When using Tree.revision_tree, and the revision is not accessible."""
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
944
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
945
    _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
1908.11.1 by Robert Collins
Add a new method ``Tree.revision_tree`` which allows access to cached
946
947
    def __init__(self, tree, revision_id):
1908.11.5 by John Arbash Meinel
[merge] bzr.dev 2240
948
        BzrError.__init__(self)
1908.11.1 by Robert Collins
Add a new method ``Tree.revision_tree`` which allows access to cached
949
        self.tree = tree
950
        self.revision_id = revision_id
951
952
2230.3.40 by Aaron Bentley
Rename strict_revision_history to append_revisions_only
953
class AppendRevisionsOnlyViolation(BzrError):
2230.3.32 by Aaron Bentley
Implement strict history policy
954
2221.5.14 by Dmitry Vasiliev
Wrapped long lines
955
    _fmt = ('Operation denied because it would change the main history,'
7143.15.2 by Jelmer Vernooij
Run autopep8.
956
            ' which is not permitted by the append_revisions_only setting on'
957
            ' branch "%(location)s".')
2230.3.39 by Aaron Bentley
Improve history violation message
958
959
    def __init__(self, location):
7143.15.2 by Jelmer Vernooij
Run autopep8.
960
        import breezy.urlutils as urlutils
961
        location = urlutils.unescape_for_display(location, 'ascii')
962
        BzrError.__init__(self, location=location)
2230.3.32 by Aaron Bentley
Implement strict history policy
963
964
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
965
class DivergedBranches(BzrError):
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
966
967
    _fmt = ("These branches have diverged."
4297.3.1 by Samuel Bronson
Add suggestion to use "missing" to message for DivergedBranches.
968
            " Use the missing command to see how.\n"
4297.3.2 by Jelmer Vernooij
Remove extra space.
969
            "Use the merge command to reconcile them.")
1740.5.6 by Martin Pool
Clean up many exception classes.
970
1185.2.1 by Lalo Martins
moving DivergedBranches from bzrlib.branch to bzrlib.errors, obeying:
971
    def __init__(self, branch1, branch2):
972
        self.branch1 = branch1
973
        self.branch2 = branch2
974
1390 by Robert Collins
pair programming worx... merge integration and weave
975
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
976
class NotLefthandHistory(InternalBzrError):
2230.3.44 by Aaron Bentley
Change asserts to specific errors for left-hand history violations
977
978
    _fmt = "Supplied history does not follow left-hand parents"
979
980
    def __init__(self, history):
981
        BzrError.__init__(self, history=history)
982
983
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
984
class UnrelatedBranches(BzrError):
2067.3.2 by Martin Pool
Error cleanup review comments:
985
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
986
    _fmt = ("Branches have no common ancestor, and"
987
            " no merge base revision was specified.")
2067.3.2 by Martin Pool
Error cleanup review comments:
988
1740.5.6 by Martin Pool
Clean up many exception classes.
989
3062.2.7 by Aaron Bentley
Prevent reverse cherry-picking with weave
990
class CannotReverseCherrypick(BzrError):
991
992
    _fmt = ('Selected merge cannot perform reverse cherrypicks.  Try merge3'
993
            ' or diff3.')
994
995
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
996
class NoCommonAncestor(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
997
2067.3.2 by Martin Pool
Error cleanup review comments:
998
    _fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1740.5.6 by Martin Pool
Clean up many exception classes.
999
974.1.80 by Aaron Bentley
Improved merge error handling and testing
1000
    def __init__(self, revision_a, revision_b):
1740.5.6 by Martin Pool
Clean up many exception classes.
1001
        self.revision_a = revision_a
1002
        self.revision_b = revision_b
974.1.80 by Aaron Bentley
Improved merge error handling and testing
1003
1551.2.1 by Aaron Bentley
recommit 1527 PEP8 fixes
1004
974.1.80 by Aaron Bentley
Improved merge error handling and testing
1005
class NoCommonRoot(BzrError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1006
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1007
    _fmt = ("Revisions are not derived from the same root: "
7143.15.2 by Jelmer Vernooij
Run autopep8.
1008
            "%(revision_a)s %(revision_b)s.")
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1009
974.1.80 by Aaron Bentley
Improved merge error handling and testing
1010
    def __init__(self, revision_a, revision_b):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1011
        BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
1551.2.1 by Aaron Bentley
recommit 1527 PEP8 fixes
1012
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
1013
974.2.7 by aaron.bentley at utoronto
Merged from bzr.24
1014
class NotAncestor(BzrError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1015
1016
    _fmt = "Revision %(rev_id)s is not an ancestor of %(not_ancestor_id)s"
1017
974.2.7 by aaron.bentley at utoronto
Merged from bzr.24
1018
    def __init__(self, rev_id, not_ancestor_id):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1019
        BzrError.__init__(self, rev_id=rev_id,
7143.15.2 by Jelmer Vernooij
Run autopep8.
1020
                          not_ancestor_id=not_ancestor_id)
1185.1.12 by Robert Collins
merge in lsdiff/filterdiff friendliness
1021
1022
3221.11.2 by Robert Collins
Create basic stackable branch facility.
1023
class NoCommits(BranchError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1024
1025
    _fmt = "Branch %(branch)s has no commits."
1948.4.20 by John Arbash Meinel
Make NoCommits a BzrNewError
1026
1551.2.1 by Aaron Bentley
recommit 1527 PEP8 fixes
1027
1185.10.1 by Aaron Bentley
Added --basis option to bzr branch
1028
class UnlistableStore(BzrError):
2067.3.2 by Martin Pool
Error cleanup review comments:
1029
1185.10.1 by Aaron Bentley
Added --basis option to bzr branch
1030
    def __init__(self, store):
1031
        BzrError.__init__(self, "Store %s is not listable" % store)
1032
1551.2.1 by Aaron Bentley
recommit 1527 PEP8 fixes
1033
1185.10.1 by Aaron Bentley
Added --basis option to bzr branch
1034
class UnlistableBranch(BzrError):
2067.3.2 by Martin Pool
Error cleanup review comments:
1035
1185.10.1 by Aaron Bentley
Added --basis option to bzr branch
1036
    def __init__(self, br):
1037
        BzrError.__init__(self, "Stores for branch %s are not listable" % br)
1392 by Robert Collins
reinstate testfetch test case
1038
1039
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1040
class BoundBranchOutOfDate(BzrError):
1041
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
1042
    _fmt = ("Bound branch %(branch)s is out of date with master branch"
5066.1.1 by Gary van der Merwe
Make it possible to detect a BoundBranchOutOfDate from commit.
1043
            " %(master)s.%(extra_help)s")
2067.3.2 by Martin Pool
Error cleanup review comments:
1044
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
1045
    def __init__(self, branch, master):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1046
        BzrError.__init__(self)
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
1047
        self.branch = branch
1048
        self.master = master
5066.1.1 by Gary van der Merwe
Make it possible to detect a BoundBranchOutOfDate from commit.
1049
        self.extra_help = ''
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
1050
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1051
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1052
class CommitToDoubleBoundBranch(BzrError):
1053
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
1054
    _fmt = ("Cannot commit to branch %(branch)s."
1055
            " It is bound to %(master)s, which is bound to %(remote)s.")
2067.3.2 by Martin Pool
Error cleanup review comments:
1056
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
1057
    def __init__(self, branch, master, remote):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1058
        BzrError.__init__(self)
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
1059
        self.branch = branch
1060
        self.master = master
1061
        self.remote = remote
1062
1505.1.25 by John Arbash Meinel
Updated pull. Now all paths which call set_revision_history maintain the branch invariant. All tests pass.
1063
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1064
class OverwriteBoundBranch(BzrError):
1065
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
1066
    _fmt = "Cannot pull --overwrite to a branch which is bound %(branch)s"
2067.3.2 by Martin Pool
Error cleanup review comments:
1067
1505.1.25 by John Arbash Meinel
Updated pull. Now all paths which call set_revision_history maintain the branch invariant. All tests pass.
1068
    def __init__(self, branch):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1069
        BzrError.__init__(self)
1505.1.25 by John Arbash Meinel
Updated pull. Now all paths which call set_revision_history maintain the branch invariant. All tests pass.
1070
        self.branch = branch
1071
1505.1.29 by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree
1072
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1073
class BoundBranchConnectionFailure(BzrError):
1074
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1075
    _fmt = ("Unable to connect to target of bound branch %(branch)s"
1076
            " => %(target)s: %(error)s")
2067.3.2 by Martin Pool
Error cleanup review comments:
1077
1505.1.29 by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree
1078
    def __init__(self, branch, target, error):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1079
        BzrError.__init__(self)
1505.1.29 by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree
1080
        self.branch = branch
1081
        self.target = target
1082
        self.error = error
1083
1084
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1085
class VersionedFileError(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1086
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1087
    _fmt = "Versioned file error"
1563.2.1 by Robert Collins
Merge in a variation of the versionedfile api from versioned-file.
1088
1089
1090
class RevisionNotPresent(VersionedFileError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1091
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
1092
    _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1563.2.1 by Robert Collins
Merge in a variation of the versionedfile api from versioned-file.
1093
1094
    def __init__(self, revision_id, file_id):
1095
        VersionedFileError.__init__(self)
1096
        self.revision_id = revision_id
1097
        self.file_id = file_id
1098
1099
1100
class RevisionAlreadyPresent(VersionedFileError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1101
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
1102
    _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1563.2.1 by Robert Collins
Merge in a variation of the versionedfile api from versioned-file.
1103
1104
    def __init__(self, revision_id, file_id):
1105
        VersionedFileError.__init__(self)
1106
        self.revision_id = revision_id
1107
        self.file_id = file_id
1108
1109
2520.4.71 by Aaron Bentley
Update test to accept VersionedFileInvalidChecksum instead of TestamentMismatch
1110
class VersionedFileInvalidChecksum(VersionedFileError):
1111
5050.8.1 by Parth Malwankar
added test to ensure that BzrError subclasses dont use "message" as a name
1112
    _fmt = "Text did not match its checksum: %(msg)s"
2520.4.71 by Aaron Bentley
Update test to accept VersionedFileInvalidChecksum instead of TestamentMismatch
1113
1114
3789.2.1 by John Arbash Meinel
_DirectPackAccess can now raise RetryWithNewPacks when we think something has happened.
1115
class RetryWithNewPacks(BzrError):
1116
    """Raised when we realize that the packs on disk have changed.
1117
1118
    This is meant as more of a signaling exception, to trap between where a
1119
    local error occurred and the code that can actually handle the error and
1120
    code that can retry appropriately.
1121
    """
1122
1123
    internal_error = True
1124
3789.2.27 by John Arbash Meinel
Add some context information to the Retry exceptions.
1125
    _fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1126
            " %(orig_error)s")
3789.2.1 by John Arbash Meinel
_DirectPackAccess can now raise RetryWithNewPacks when we think something has happened.
1127
3789.2.27 by John Arbash Meinel
Add some context information to the Retry exceptions.
1128
    def __init__(self, context, reload_occurred, exc_info):
3789.2.20 by John Arbash Meinel
The autopack code can now trigger itself to retry when _copy_revision_texts fails.
1129
        """create a new RetryWithNewPacks error.
3789.2.1 by John Arbash Meinel
_DirectPackAccess can now raise RetryWithNewPacks when we think something has happened.
1130
1131
        :param reload_occurred: Set to True if we know that the packs have
1132
            already been reloaded, and we are failing because of an in-memory
1133
            cache miss. If set to True then we will ignore if a reload says
1134
            nothing has changed, because we assume it has already reloaded. If
1135
            False, then a reload with nothing changed will force an error.
1136
        :param exc_info: The original exception traceback, so if there is a
1137
            problem we can raise the original error (value from sys.exc_info())
1138
        """
1139
        BzrError.__init__(self)
5609.58.1 by Andrew Bennetts
Fix 'Unprintable exception' when displaying RetryWithNewPacks error.
1140
        self.context = context
3789.2.1 by John Arbash Meinel
_DirectPackAccess can now raise RetryWithNewPacks when we think something has happened.
1141
        self.reload_occurred = reload_occurred
1142
        self.exc_info = exc_info
3789.2.10 by John Arbash Meinel
The first function for KnitVersionedFiles can now retry on request.
1143
        self.orig_error = exc_info[1]
3789.2.1 by John Arbash Meinel
_DirectPackAccess can now raise RetryWithNewPacks when we think something has happened.
1144
        # TODO: The global error handler should probably treat this by
1145
        #       raising/printing the original exception with a bit about
1146
        #       RetryWithNewPacks also not being caught
1147
1148
3789.2.20 by John Arbash Meinel
The autopack code can now trigger itself to retry when _copy_revision_texts fails.
1149
class RetryAutopack(RetryWithNewPacks):
1150
    """Raised when we are autopacking and we find a missing file.
1151
1152
    Meant as a signaling exception, to tell the autopack code it should try
1153
    again.
1154
    """
1155
3789.2.22 by John Arbash Meinel
We need the Packer class to cleanup if it is getting a Retry it isn't handling.
1156
    internal_error = True
1157
3789.2.27 by John Arbash Meinel
Add some context information to the Retry exceptions.
1158
    _fmt = ("Pack files have changed, reload and try autopack again."
1159
            " context: %(context)s %(orig_error)s")
3789.2.20 by John Arbash Meinel
The autopack code can now trigger itself to retry when _copy_revision_texts fails.
1160
1161
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1162
class NoSuchExportFormat(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1163
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1164
    _fmt = "Export format %(format)r not supported"
1165
1185.31.12 by John Arbash Meinel
Refactored the export code to make it easier to add new export formats.
1166
    def __init__(self, format):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1167
        BzrError.__init__(self)
1185.31.12 by John Arbash Meinel
Refactored the export code to make it easier to add new export formats.
1168
        self.format = format
1169
1170
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1171
class TransportError(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1172
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1173
    _fmt = "Transport error: %(msg)s %(orig_error)s"
1824.2.1 by Johan Rydberg
Let TransportError inherit BzrNerError.
1174
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1175
    def __init__(self, msg=None, orig_error=None):
1176
        if msg is None and orig_error is not None:
1177
            msg = str(orig_error)
1824.2.1 by Johan Rydberg
Let TransportError inherit BzrNerError.
1178
        if orig_error is None:
1179
            orig_error = ''
1180
        if msg is None:
7143.15.2 by Jelmer Vernooij
Run autopep8.
1181
            msg = ''
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1182
        self.msg = msg
1183
        self.orig_error = orig_error
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1184
        BzrError.__init__(self)
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1185
1551.2.1 by Aaron Bentley
recommit 1527 PEP8 fixes
1186
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
1187
class TooManyConcurrentRequests(InternalBzrError):
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
1188
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1189
    _fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
2221.5.14 by Dmitry Vasiliev
Wrapped long lines
1190
            " Be sure to finish_writing and finish_reading on the"
2018.5.134 by Andrew Bennetts
Fix the TooManyConcurrentRequests error message.
1191
            " currently open request.")
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
1192
1193
    def __init__(self, medium):
1194
        self.medium = medium
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1195
1551.2.1 by Aaron Bentley
recommit 1527 PEP8 fixes
1196
1910.19.14 by Robert Collins
Fix up all tests to pass, remove a couple more deprecated function calls, and break the dependency on sftp for the smart transport.
1197
class SmartProtocolError(TransportError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1198
1199
    _fmt = "Generic bzr smart protocol error: %(details)s"
1910.19.13 by Andrew Bennetts
Address various review comments.
1200
1201
    def __init__(self, details):
1202
        self.details = details
1203
1204
3245.4.42 by Andrew Bennetts
Make _SmartClient automatically detect and use the highest protocol version compatible with the server.
1205
class UnexpectedProtocolVersionMarker(TransportError):
1206
3245.4.56 by Andrew Bennetts
Clearer message for UnexpectedProtocolVersionMarker.
1207
    _fmt = "Received bad protocol version marker: %(marker)r"
3245.4.42 by Andrew Bennetts
Make _SmartClient automatically detect and use the highest protocol version compatible with the server.
1208
1209
    def __init__(self, marker):
1210
        self.marker = marker
1211
1212
3297.3.1 by Andrew Bennetts
Raise UnknownSmartMethod automatically from read_response_tuple.
1213
class UnknownSmartMethod(InternalBzrError):
1214
1215
    _fmt = "The server does not recognise the '%(verb)s' request."
1216
1217
    def __init__(self, verb):
1218
        self.verb = verb
1219
1220
3245.4.49 by Andrew Bennetts
Distinguish between errors in decoding a message into message parts from errors in handling decoded message parts, and use that to make sure that entire requests are read even when they result in exceptions.
1221
class SmartMessageHandlerError(InternalBzrError):
1222
3695.2.2 by Andrew Bennetts
Rough cut of implementing and using a VersionedFiles.get_parent_map RPC.
1223
    _fmt = ("The message handler raised an exception:\n"
3883.2.3 by Andrew Bennetts
Add test, tweak traceback formatting.
1224
            "%(traceback_text)s")
3245.4.49 by Andrew Bennetts
Distinguish between errors in decoding a message into message parts from errors in handling decoded message parts, and use that to make sure that entire requests are read even when they result in exceptions.
1225
1226
    def __init__(self, exc_info):
3695.2.2 by Andrew Bennetts
Rough cut of implementing and using a VersionedFiles.get_parent_map RPC.
1227
        import traceback
5340.15.1 by John Arbash Meinel
supersede exc-info branch
1228
        # GZ 2010-08-10: Cycle with exc_tb/exc_info affects at least one test
3695.2.2 by Andrew Bennetts
Rough cut of implementing and using a VersionedFiles.get_parent_map RPC.
1229
        self.exc_type, self.exc_value, self.exc_tb = exc_info
1230
        self.exc_info = exc_info
3883.2.3 by Andrew Bennetts
Add test, tweak traceback formatting.
1231
        traceback_strings = traceback.format_exception(
7143.15.2 by Jelmer Vernooij
Run autopep8.
1232
            self.exc_type, self.exc_value, self.exc_tb)
3883.2.3 by Andrew Bennetts
Add test, tweak traceback formatting.
1233
        self.traceback_text = ''.join(traceback_strings)
3695.2.2 by Andrew Bennetts
Rough cut of implementing and using a VersionedFiles.get_parent_map RPC.
1234
3245.4.49 by Andrew Bennetts
Distinguish between errors in decoding a message into message parts from errors in handling decoded message parts, and use that to make sure that entire requests are read even when they result in exceptions.
1235
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1236
# A set of semi-meaningful errors which can be thrown
1237
class TransportNotPossible(TransportError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1238
1239
    _fmt = "Transport operation not possible: %(msg)s %(orig_error)s"
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1240
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
1241
1242
class ConnectionError(TransportError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1243
1244
    _fmt = "Connection error: %(msg)s %(orig_error)s"
1185.31.44 by John Arbash Meinel
Cleaned up Exceptions for all transports.
1245
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1246
2052.4.4 by John Arbash Meinel
Create a SocketConnectionError to make creating nice errors easier
1247
class SocketConnectionError(ConnectionError):
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
1248
1249
    _fmt = "%(msg)s %(host)s%(port)s%(orig_error)s"
2052.4.4 by John Arbash Meinel
Create a SocketConnectionError to make creating nice errors easier
1250
1251
    def __init__(self, host, port=None, msg=None, orig_error=None):
1252
        if msg is None:
1253
            msg = 'Failed to connect to'
1254
        if orig_error is None:
1255
            orig_error = ''
1256
        else:
1257
            orig_error = '; ' + str(orig_error)
1258
        ConnectionError.__init__(self, msg=msg, orig_error=orig_error)
1259
        self.host = host
1260
        if port is None:
1261
            self.port = ''
1262
        else:
1263
            self.port = ':%s' % port
1264
1265
4070.8.1 by Martin Pool
Remove 'try -Dhpss' from error messages
1266
# XXX: This is also used for unexpected end of file, which is different at the
1267
# TCP level from "connection reset".
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1268
class ConnectionReset(TransportError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1269
1270
    _fmt = "Connection closed: %(msg)s %(orig_error)s"
1185.11.9 by John Arbash Meinel
Most tests pass, some problems with unavailable socket recv
1271
1551.2.1 by Aaron Bentley
recommit 1527 PEP8 fixes
1272
6133.4.11 by John Arbash Meinel
It turns out that if we don't explicitly close the socket, it hangs around somewhere.
1273
class ConnectionTimeout(ConnectionError):
1274
6133.4.34 by John Arbash Meinel
get the blackbox tests passing.
1275
    _fmt = "Connection Timeout: %(msg)s%(orig_error)s"
6133.4.11 by John Arbash Meinel
It turns out that if we don't explicitly close the socket, it hangs around somewhere.
1276
1277
1786.1.8 by John Arbash Meinel
[merge] Johan Rydberg test updates
1278
class InvalidRange(TransportError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1279
3059.2.2 by Vincent Ladeuil
Read http responses on demand without buffering the whole body
1280
    _fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1281
1282
    def __init__(self, path, offset, msg=None):
1283
        TransportError.__init__(self, msg)
1979.1.1 by John Arbash Meinel
Fix bug #57723, parse boundary="" correctly, since Squid uses it
1284
        self.path = path
1285
        self.offset = offset
1786.1.8 by John Arbash Meinel
[merge] Johan Rydberg test updates
1286
1287
1786.1.17 by John Arbash Meinel
Adding tests for _parse_boundary.
1288
class InvalidHttpResponse(TransportError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1289
5609.39.8 by Vincent Ladeuil
Stop swallowing details about the original error
1290
    _fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1786.1.17 by John Arbash Meinel
Adding tests for _parse_boundary.
1291
1786.1.31 by John Arbash Meinel
Update http errors to properly use BzrNewError
1292
    def __init__(self, path, msg, orig_error=None):
1786.1.17 by John Arbash Meinel
Adding tests for _parse_boundary.
1293
        self.path = path
5609.39.8 by Vincent Ladeuil
Stop swallowing details about the original error
1294
        if orig_error is None:
1295
            orig_error = ''
1296
        else:
1297
            # This is reached for obscure and unusual errors so we want to
1298
            # preserve as much info as possible to ease debug.
1299
            orig_error = ': %r' % (orig_error,)
1786.1.31 by John Arbash Meinel
Update http errors to properly use BzrNewError
1300
        TransportError.__init__(self, msg, orig_error=orig_error)
1786.1.17 by John Arbash Meinel
Adding tests for _parse_boundary.
1301
1302
7490.90.6 by Jelmer Vernooij
More fixes for hg probing.
1303
class UnexpectedHttpStatus(InvalidHttpResponse):
1304
1305
    _fmt = "Unexpected HTTP status %(code)d for %(path)s"
1306
1307
    def __init__(self, path, code, msg=None):
1308
        self.path = path
1309
        self.code = code
1310
        self.msg = msg
1311
        full_msg = 'status code %d unexpected' % code
1312
        if msg is not None:
1313
            full_msg += ': ' + msg
1314
        InvalidHttpResponse.__init__(
1315
            self, path, full_msg)
1316
1317
1318
class BadHttpRequest(UnexpectedHttpStatus):
1319
1320
    _fmt = "Bad http request for %(path)s: %(reason)s"
1321
1322
    def __init__(self, path, reason):
1323
        self.path = path
1324
        self.reason = reason
1325
        TransportError.__init__(self, reason)
1326
1327
1786.1.17 by John Arbash Meinel
Adding tests for _parse_boundary.
1328
class InvalidHttpRange(InvalidHttpResponse):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1329
1330
    _fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
3059.2.2 by Vincent Ladeuil
Read http responses on demand without buffering the whole body
1331
1786.1.13 by John Arbash Meinel
Found a few bugs in error handling code, updated tests
1332
    def __init__(self, path, range, msg):
1333
        self.range = range
1786.1.17 by John Arbash Meinel
Adding tests for _parse_boundary.
1334
        InvalidHttpResponse.__init__(self, path, msg)
1335
1336
5609.52.1 by Martin Pool
Cope with buggy squids interrupting the response before a mime multipart boundary
1337
class HttpBoundaryMissing(InvalidHttpResponse):
1338
    """A multipart response ends with no boundary marker.
1339
1340
    This is a special case caused by buggy proxies, described in
1341
    <https://bugs.launchpad.net/bzr/+bug/198646>.
1342
    """
1343
1344
    _fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1345
1346
    def __init__(self, path, msg):
1347
        InvalidHttpResponse.__init__(self, path, msg)
1348
1349
1786.1.17 by John Arbash Meinel
Adding tests for _parse_boundary.
1350
class InvalidHttpContentType(InvalidHttpResponse):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1351
1352
    _fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
3059.2.2 by Vincent Ladeuil
Read http responses on demand without buffering the whole body
1353
1786.1.17 by John Arbash Meinel
Adding tests for _parse_boundary.
1354
    def __init__(self, path, ctype, msg):
1355
        self.ctype = ctype
1356
        InvalidHttpResponse.__init__(self, path, msg)
1786.1.13 by John Arbash Meinel
Found a few bugs in error handling code, updated tests
1357
1358
2164.2.1 by v.ladeuil+lp at free
First rough http branch redirection implementation.
1359
class RedirectRequested(TransportError):
1360
1361
    _fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1362
3878.4.4 by Vincent Ladeuil
Cleanup.
1363
    def __init__(self, source, target, is_permanent=False):
2164.2.1 by v.ladeuil+lp at free
First rough http branch redirection implementation.
1364
        self.source = source
1365
        self.target = target
2949.4.1 by Vincent Ladeuil
Fix typo (is_permament => is_permanent) reported on IRC
1366
        if is_permanent:
2164.2.1 by v.ladeuil+lp at free
First rough http branch redirection implementation.
1367
            self.permanently = ' permanently'
1368
        else:
1369
            self.permanently = ''
2164.2.7 by v.ladeuil+lp at free
First implementation of transport hints.
1370
        TransportError.__init__(self)
1371
2164.2.22 by Vincent Ladeuil
Take Aaron's review comments into account.
1372
1373
class TooManyRedirections(TransportError):
1374
1375
    _fmt = "Too many redirections"
2164.2.7 by v.ladeuil+lp at free
First implementation of transport hints.
1376
2930.1.1 by Ian Clatworthy
error msg instead of assert when connection over bzr+ssh fails (#115601)
1377
1185.14.10 by Aaron Bentley
Commit aborts with conflicts in the tree.
1378
class ConflictsInTree(BzrError):
2067.3.2 by Martin Pool
Error cleanup review comments:
1379
1380
    _fmt = "Working tree has conflicts."
1185.12.49 by Aaron Bentley
Switched to ConfigObj
1381
1551.2.1 by Aaron Bentley
recommit 1527 PEP8 fixes
1382
5971.1.35 by Jonathan Riddell
set gpgme in tests.features
1383
class DependencyNotPresent(BzrError):
1384
1385
    _fmt = 'Unable to import library "%(library)s": %(error)s'
1386
1387
    def __init__(self, library, error):
1388
        BzrError.__init__(self, library=library, error=error)
1389
1390
1185.12.83 by Aaron Bentley
Preliminary weave merge support
1391
class WorkingTreeNotRevision(BzrError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1392
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1393
    _fmt = ("The working tree for %(basedir)s has changed since"
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1394
            " the last commit, but weave merge requires that it be"
1395
            " unchanged")
1396
1185.12.83 by Aaron Bentley
Preliminary weave merge support
1397
    def __init__(self, tree):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1398
        BzrError.__init__(self, basedir=tree.basedir)
1399
1400
1401
class GraphCycleError(BzrError):
1402
1403
    _fmt = "Cycle in graph %(graph)r"
2067.3.2 by Martin Pool
Error cleanup review comments:
1404
1185.16.114 by mbp at sourcefrog
Improved topological sort
1405
    def __init__(self, graph):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1406
        BzrError.__init__(self)
1185.16.114 by mbp at sourcefrog
Improved topological sort
1407
        self.graph = graph
1185.35.1 by Aaron Bentley
Implemented conflicts.restore
1408
1505.1.23 by John Arbash Meinel
Whitespace cleanup of bzrlib.errors
1409
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
1410
class WritingCompleted(InternalBzrError):
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
1411
1412
    _fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1413
            "called upon it - accept bytes may not be called anymore.")
1414
1415
    def __init__(self, request):
1416
        self.request = request
1417
1418
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
1419
class WritingNotComplete(InternalBzrError):
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
1420
1421
    _fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1422
            "called upon it - until the write phase is complete no "
1423
            "data may be read.")
1424
1425
    def __init__(self, request):
1426
        self.request = request
1427
1428
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1429
class NotConflicted(BzrError):
1430
1431
    _fmt = "File %(filename)s is not conflicted."
1534.3.1 by Robert Collins
* bzrlib.osutils.safe_unicode now exists to provide parameter coercion
1432
1185.35.1 by Aaron Bentley
Implemented conflicts.restore
1433
    def __init__(self, filename):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1434
        BzrError.__init__(self)
1185.35.1 by Aaron Bentley
Implemented conflicts.restore
1435
        self.filename = filename
1185.35.13 by Aaron Bentley
Merged Martin
1436
1505.1.23 by John Arbash Meinel
Whitespace cleanup of bzrlib.errors
1437
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
1438
class MediumNotConnected(InternalBzrError):
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
1439
1440
    _fmt = """The medium '%(medium)s' is not connected."""
1441
2018.2.3 by Andrew Bennetts
Starting factoring out the smart server client "medium" from the protocol.
1442
    def __init__(self, medium):
1443
        self.medium = medium
1444
1445
1492 by Robert Collins
Support decoration of commands.
1446
class MustUseDecorated(Exception):
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1447
1448
    _fmt = "A decorating function has requested its original command be used."
1449
1185.82.3 by John Arbash Meinel
Working on creating a factor for serializing changesets.
1450
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1451
class NoBundleFound(BzrError):
1452
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
1453
    _fmt = 'No bundle was found in "%(filename)s".'
2067.3.2 by Martin Pool
Error cleanup review comments:
1454
1185.82.3 by John Arbash Meinel
Working on creating a factor for serializing changesets.
1455
    def __init__(self, filename):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1456
        BzrError.__init__(self)
1185.82.3 by John Arbash Meinel
Working on creating a factor for serializing changesets.
1457
        self.filename = filename
1458
1459
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1460
class BundleNotSupported(BzrError):
1461
1462
    _fmt = "Unable to handle bundle version %(version)s: %(msg)s"
2067.3.2 by Martin Pool
Error cleanup review comments:
1463
1185.82.3 by John Arbash Meinel
Working on creating a factor for serializing changesets.
1464
    def __init__(self, version, msg):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1465
        BzrError.__init__(self)
1185.82.3 by John Arbash Meinel
Working on creating a factor for serializing changesets.
1466
        self.version = version
1467
        self.msg = msg
1468
1469
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1470
class MissingText(BzrError):
1471
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1472
    _fmt = ("Branch %(base)s is missing revision"
1473
            " %(text_revision)s of %(file_id)s")
1534.3.1 by Robert Collins
* bzrlib.osutils.safe_unicode now exists to provide parameter coercion
1474
1185.35.42 by Aaron Bentley
Fixed fetch to be safer wrt ghosts and corrupt branches
1475
    def __init__(self, branch, text_revision, file_id):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1476
        BzrError.__init__(self)
1185.35.42 by Aaron Bentley
Fixed fetch to be safer wrt ghosts and corrupt branches
1477
        self.branch = branch
1478
        self.base = branch.base
1479
        self.text_revision = text_revision
1480
        self.file_id = file_id
1534.7.5 by Aaron Bentley
Got unique_add under test
1481
2671.6.2 by Robert Collins
Prevent the duplicate additions of names to FileNames collections.
1482
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1483
class DuplicateKey(BzrError):
1484
1485
    _fmt = "Key %(key)s is already present in map"
1486
1487
2432.1.19 by Robert Collins
Ensure each HelpIndex has a unique prefix.
1488
class DuplicateHelpPrefix(BzrError):
1489
1490
    _fmt = "The prefix %(prefix)s is in the help search path twice."
1491
1492
    def __init__(self, prefix):
1493
        self.prefix = prefix
1494
1495
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
1496
class BzrBadParameter(InternalBzrError):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1497
1498
    _fmt = "Bad parameter: %(param)r"
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
1499
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1500
    # This exception should never be thrown, but it is a base class for all
1501
    # parameter-to-function errors.
1502
1534.3.1 by Robert Collins
* bzrlib.osutils.safe_unicode now exists to provide parameter coercion
1503
    def __init__(self, param):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1504
        BzrError.__init__(self)
1534.3.1 by Robert Collins
* bzrlib.osutils.safe_unicode now exists to provide parameter coercion
1505
        self.param = param
1534.7.32 by Aaron Bentley
Got conflict handling working when conflicts involve existing files
1506
1534.4.3 by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats.
1507
1185.65.29 by Robert Collins
Implement final review suggestions.
1508
class BzrBadParameterNotUnicode(BzrBadParameter):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1509
1510
    _fmt = "Parameter %(param)s is neither unicode nor utf8."
1511
5279.2.14 by Eric Moritz
Deleted trailing whitespace
1512
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1513
class BzrMoveFailedError(BzrError):
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
1514
5609.8.3 by Martin
Ugly cheaty hack to make BzrMoveFailedError do something reasonable with non-ascii contents
1515
    _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
7143.15.2 by Jelmer Vernooij
Run autopep8.
1516
            "%(_has_extra)s%(extra)s")
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1517
2220.1.3 by Marius Kruger
* errors.py
1518
    def __init__(self, from_path='', to_path='', extra=None):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
1519
        from breezy.osutils import splitpath
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1520
        BzrError.__init__(self)
1521
        if extra:
5609.8.3 by Martin
Ugly cheaty hack to make BzrMoveFailedError do something reasonable with non-ascii contents
1522
            self.extra, self._has_extra = extra, ': '
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1523
        else:
5609.8.3 by Martin
Ugly cheaty hack to make BzrMoveFailedError do something reasonable with non-ascii contents
1524
            self.extra = self._has_extra = ''
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
1525
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1526
        has_from = len(from_path) > 0
1527
        has_to = len(to_path) > 0
1528
        if has_from:
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
1529
            self.from_path = splitpath(from_path)[-1]
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1530
        else:
1531
            self.from_path = ''
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
1532
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1533
        if has_to:
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
1534
            self.to_path = splitpath(to_path)[-1]
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1535
        else:
1536
            self.to_path = ''
1537
1538
        self.operator = ""
1539
        if has_from and has_to:
1540
            self.operator = " =>"
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
1541
        elif has_from:
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1542
            self.from_path = "from " + from_path
1543
        elif has_to:
1544
            self.operator = "to"
1545
        else:
1546
            self.operator = "file"
1547
1548
1549
class BzrRenameFailedError(BzrMoveFailedError):
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
1550
5609.8.3 by Martin
Ugly cheaty hack to make BzrMoveFailedError do something reasonable with non-ascii contents
1551
    _fmt = ("Could not rename %(from_path)s%(operator)s %(to_path)s"
7143.15.2 by Jelmer Vernooij
Run autopep8.
1552
            "%(_has_extra)s%(extra)s")
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
1553
2206.1.9 by Marius Kruger
* Change move/rename errors yet again
1554
    def __init__(self, from_path, to_path, extra=None):
1555
        BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1556
5609.8.3 by Martin
Ugly cheaty hack to make BzrMoveFailedError do something reasonable with non-ascii contents
1557
1185.65.29 by Robert Collins
Implement final review suggestions.
1558
class BzrBadParameterNotString(BzrBadParameter):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1559
1560
    _fmt = "Parameter %(param)s is not a string or unicode string."
1185.62.24 by John Arbash Meinel
Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.
1561
1562
1534.4.44 by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory.
1563
class BzrBadParameterMissing(BzrBadParameter):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1564
5609.1.1 by Vincent Ladeuil
Release 2.3b5
1565
    _fmt = "Parameter %(param)s is required but not present."
1534.4.44 by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory.
1566
1567
1666.1.6 by Robert Collins
Make knit the default format.
1568
class BzrBadParameterUnicode(BzrBadParameter):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1569
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1570
    _fmt = ("Parameter %(param)s is unicode but"
1571
            " only byte-strings are permitted.")
1666.1.6 by Robert Collins
Make knit the default format.
1572
1573
1574
class BzrBadParameterContainsNewline(BzrBadParameter):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1575
1576
    _fmt = "Parameter %(param)s contains a newline."
1577
1578
1185.62.24 by John Arbash Meinel
Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.
1579
class ParamikoNotPresent(DependencyNotPresent):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1580
1581
    _fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1185.62.24 by John Arbash Meinel
Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.
1582
1583
    def __init__(self, error):
1584
        DependencyNotPresent.__init__(self, 'paramiko', error)
1585
1586
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1587
class PointlessMerge(BzrError):
1588
1589
    _fmt = "Nothing to merge."
1590
1591
1592
class UninitializableFormat(BzrError):
1593
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
1594
    _fmt = "Format %(format)s cannot be initialised by this version of brz."
1534.4.3 by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats.
1595
1596
    def __init__(self, format):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1597
        BzrError.__init__(self)
1534.4.3 by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats.
1598
        self.format = format
1551.3.4 by Aaron Bentley
Implemented default command options
1599
1534.7.156 by Aaron Bentley
PEP8 fixes
1600
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1601
class BadConversionTarget(BzrError):
1602
4608.1.3 by Martin Pool
BadConversionTarget error includes source format
1603
    _fmt = "Cannot convert from format %(from_format)s to format %(format)s." \
7143.15.2 by Jelmer Vernooij
Run autopep8.
1604
        "    %(problem)s"
1910.2.12 by Aaron Bentley
Implement knit repo format 2
1605
4608.1.3 by Martin Pool
BadConversionTarget error includes source format
1606
    def __init__(self, problem, format, from_format=None):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1607
        BzrError.__init__(self)
1910.2.12 by Aaron Bentley
Implement knit repo format 2
1608
        self.problem = problem
1609
        self.format = format
4608.1.3 by Martin Pool
BadConversionTarget error includes source format
1610
        self.from_format = from_format or '(unspecified)'
1910.2.12 by Aaron Bentley
Implement knit repo format 2
1611
1612
3009.2.28 by Aaron Bentley
Add from_diff_tree factories
1613
class NoDiffFound(BzrError):
3009.2.19 by Aaron Bentley
Implement directory diffing
1614
1615
    _fmt = 'Could not find an appropriate Differ for file "%(path)s"'
1616
1617
    def __init__(self, path):
1618
        BzrError.__init__(self, path)
1619
1620
3145.1.1 by Aaron Bentley
Handle missing tools gracefully in diff --using
1621
class ExecutableMissing(BzrError):
1622
1623
    _fmt = "%(exe_name)s could not be found on this machine"
1624
1625
    def __init__(self, exe_name):
1626
        BzrError.__init__(self, exe_name=exe_name)
1627
1628
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1629
class NoDiff(BzrError):
1630
1631
    _fmt = "Diff is not installed on this machine: %(msg)s"
1711.2.56 by John Arbash Meinel
Raise NoDiff if 'diff' not present.
1632
1633
    def __init__(self, msg):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1634
        BzrError.__init__(self, msg=msg)
1635
1636
1637
class NoDiff3(BzrError):
1638
1639
    _fmt = "Diff3 is not installed on this machine."
1640
1641
1642
class ExistingLimbo(BzrError):
1643
1644
    _fmt = """This tree contains left-over files from a failed operation.
1645
    Please examine %(limbo_dir)s to see if it contains any files you wish to
1646
    keep, and delete it when you are done."""
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1647
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1648
    def __init__(self, limbo_dir):
7143.15.2 by Jelmer Vernooij
Run autopep8.
1649
        BzrError.__init__(self)
1650
        self.limbo_dir = limbo_dir
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1651
1652
2733.2.11 by Aaron Bentley
Detect irregularities with the pending-deletion directory
1653
class ExistingPendingDeletion(BzrError):
1654
1655
    _fmt = """This tree contains left-over files from a failed operation.
1656
    Please examine %(pending_deletion)s to see if it contains any files you
1657
    wish to keep, and delete it when you are done."""
1658
1659
    def __init__(self, pending_deletion):
7143.15.2 by Jelmer Vernooij
Run autopep8.
1660
        BzrError.__init__(self, pending_deletion=pending_deletion)
2733.2.11 by Aaron Bentley
Detect irregularities with the pending-deletion directory
1661
1662
1663
class ImmortalPendingDeletion(BzrError):
1664
2978.2.1 by Alexander Belchenko
fix formatting of ImmortalPendingDeletion error message.
1665
    _fmt = ("Unable to delete transform temporary directory "
7143.15.2 by Jelmer Vernooij
Run autopep8.
1666
            "%(pending_deletion)s.  Please examine %(pending_deletion)s to see if it "
1667
            "contains any files you wish to keep, and delete it when you are done.")
2733.2.11 by Aaron Bentley
Detect irregularities with the pending-deletion directory
1668
1669
    def __init__(self, pending_deletion):
7143.15.2 by Jelmer Vernooij
Run autopep8.
1670
        BzrError.__init__(self, pending_deletion=pending_deletion)
2733.2.11 by Aaron Bentley
Detect irregularities with the pending-deletion directory
1671
1672
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1673
class OutOfDateTree(BzrError):
1674
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
1675
    _fmt = "Working tree is out of date, please run 'brz update'.%(more)s"
1508.1.25 by Robert Collins
Update per review comments.
1676
4487.2.6 by Vincent Ladeuil
Fixed as per jam's review.
1677
    def __init__(self, tree, more=None):
1678
        if more is None:
1679
            more = ''
1680
        else:
1681
            more = ' ' + more
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1682
        BzrError.__init__(self)
1508.1.25 by Robert Collins
Update per review comments.
1683
        self.tree = tree
4487.2.6 by Vincent Ladeuil
Fixed as per jam's review.
1684
        self.more = more
1534.7.196 by Aaron Bentley
Switched to Rio format for merge-modified list
1685
1563.2.22 by Robert Collins
Move responsibility for repository.has_revision into RevisionStore
1686
1551.12.5 by Aaron Bentley
Get MergeDirective.from_objects working
1687
class PublicBranchOutOfDate(BzrError):
1688
1689
    _fmt = 'Public branch "%(public_location)s" lacks revision '\
1690
        '"%(revstring)s".'
1691
1692
    def __init__(self, public_location, revstring):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
1693
        import breezy.urlutils as urlutils
1551.12.5 by Aaron Bentley
Get MergeDirective.from_objects working
1694
        public_location = urlutils.unescape_for_display(public_location,
1695
                                                        'ascii')
1696
        BzrError.__init__(self, public_location=public_location,
1697
                          revstring=revstring)
1698
1699
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1700
class MergeModifiedFormatError(BzrError):
1701
1702
    _fmt = "Error in merge modified format"
1703
1704
1705
class ConflictFormatError(BzrError):
1706
1707
    _fmt = "Format error in conflict listings"
1708
1709
1710
class CorruptRepository(BzrError):
1711
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1712
    _fmt = ("An error has been detected in the repository %(repo_path)s.\n"
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
1713
            "Please run brz reconcile on this repository.")
1570.1.13 by Robert Collins
Check for incorrect revision parentage in the weave during revision access.
1714
1715
    def __init__(self, repo):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1716
        BzrError.__init__(self)
5158.6.9 by Martin Pool
Simplify various code to use user_url
1717
        self.repo_path = repo.user_url
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
1718
1719
3207.2.2 by John Arbash Meinel
Fix bug #187169, when an invalid delta is supplied to update_basis_by_delta
1720
class InconsistentDelta(BzrError):
1721
    """Used when we get a delta that is not valid."""
1722
1723
    _fmt = ("An inconsistent delta was supplied involving %(path)r,"
3221.1.4 by Martin Pool
Fix format string for InconsistentDelta
1724
            " %(file_id)r\nreason: %(reason)s")
3207.2.2 by John Arbash Meinel
Fix bug #187169, when an invalid delta is supplied to update_basis_by_delta
1725
1726
    def __init__(self, path, file_id, reason):
1727
        BzrError.__init__(self)
1728
        self.path = path
1729
        self.file_id = file_id
1730
        self.reason = reason
1731
1732
4505.5.1 by Robert Collins
Add more generic InconsistentDeltaDelta error class for use when the exact cause of an inconsistent delta isn't trivially accessible.
1733
class InconsistentDeltaDelta(InconsistentDelta):
1734
    """Used when we get a delta that is not valid."""
1735
1736
    _fmt = ("An inconsistent delta was supplied: %(delta)r"
1737
            "\nreason: %(reason)s")
1738
1739
    def __init__(self, delta, reason):
1740
        BzrError.__init__(self)
1741
        self.delta = delta
1742
        self.reason = reason
1743
1744
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1745
class UpgradeRequired(BzrError):
1746
1747
    _fmt = "To use this feature you must upgrade your branch at %(path)s."
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
1748
1749
    def __init__(self, path):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1750
        BzrError.__init__(self)
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
1751
        self.path = path
1752
1587.1.8 by Robert Collins
Local commits on unbound branches fail.
1753
3349.1.2 by Aaron Bentley
Change ValueError to RepositoryUpgradeRequired
1754
class RepositoryUpgradeRequired(UpgradeRequired):
1755
1756
    _fmt = "To use this feature you must upgrade your repository at %(path)s."
1757
1758
4416.6.1 by Neil Martinsen-Burrell
Fix #220067 adding more specificity to the error message when split fails
1759
class RichRootUpgradeRequired(UpgradeRequired):
1760
4446.1.1 by Ian Clatworthy
(igc) better message when split fails (Neil Martinsen-Burrell)
1761
    _fmt = ("To use this feature you must upgrade your branch at %(path)s to"
7143.15.2 by Jelmer Vernooij
Run autopep8.
1762
            " a format which supports rich roots.")
4416.6.1 by Neil Martinsen-Burrell
Fix #220067 adding more specificity to the error message when split fails
1763
1764
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1765
class LocalRequiresBoundBranch(BzrError):
1766
1767
    _fmt = "Cannot perform local-only commits on unbound branches."
1768
1769
1770
class UnsupportedOperation(BzrError):
1771
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1772
    _fmt = ("The method %(mname)s is not supported on"
1773
            " objects of type %(tname)s.")
2067.3.2 by Martin Pool
Error cleanup review comments:
1774
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
1775
    def __init__(self, method, method_self):
1776
        self.method = method
1777
        self.mname = method.__name__
1778
        self.tname = type(method_self).__name__
1558.15.1 by Aaron Bentley
Add text_file function
1779
1780
6862.4.2 by Jelmer Vernooij
Move to errors.
1781
class FetchLimitUnsupported(UnsupportedOperation):
1782
1783
    fmt = ("InterBranch %(interbranch)r does not support fetching limits.")
1784
1785
    def __init__(self, interbranch):
1786
        BzrError.__init__(self, interbranch=interbranch)
1787
1788
2150.2.2 by Robert Collins
Change the commit builder selected-revision-id test to use a unicode revision id where possible, leading to stricter testing of the hypothetical unicode revision id support in bzr.
1789
class NonAsciiRevisionId(UnsupportedOperation):
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1790
    """Raised when a commit is attempting to set a non-ascii revision id
1791
       but cant.
1792
    """
2150.2.2 by Robert Collins
Change the commit builder selected-revision-id test to use a unicode revision id where possible, leading to stricter testing of the hypothetical unicode revision id support in bzr.
1793
1794
7385.2.2 by Jelmer Vernooij
Raise exception when requesting shared repository be created.
1795
class SharedRepositoriesUnsupported(UnsupportedOperation):
1796
    _fmt = "Shared repositories are not supported by %(format)r."
1797
1798
    def __init__(self, format):
1799
        BzrError.__init__(self, format=format)
1800
1801
6123.4.2 by Jelmer Vernooij
Tags containers can indicate whether they support ghost tags.
1802
class GhostTagsNotSupported(BzrError):
1803
1804
    _fmt = "Ghost tags not supported by format %(format)r."
1805
1806
    def __init__(self, format):
1807
        self.format = format
1808
1809
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1810
class BinaryFile(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1811
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1812
    _fmt = "File is binary but should be text."
1813
1814
1815
class IllegalPath(BzrError):
1816
1817
    _fmt = "The path %(path)s is not permitted on this platform"
1551.2.55 by abentley
Fix fileid involed tests on win32 (by skipping them for unescaped weave formats)
1818
1819
    def __init__(self, path):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1820
        BzrError.__init__(self)
1551.2.55 by abentley
Fix fileid involed tests on win32 (by skipping them for unescaped weave formats)
1821
        self.path = path
1185.82.118 by Aaron Bentley
Ensure that StrictTestament handles execute bit differences
1822
1823
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1824
class TestamentMismatch(BzrError):
1825
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1826
    _fmt = """Testament did not match expected value.
1827
       For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1828
       {%(measured)s}"""
1829
1185.82.118 by Aaron Bentley
Ensure that StrictTestament handles execute bit differences
1830
    def __init__(self, revision_id, expected, measured):
1831
        self.revision_id = revision_id
1832
        self.expected = expected
1833
        self.measured = measured
1185.82.131 by Aaron Bentley
Move BadBundle error (and subclasses) to errors.py
1834
1835
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1836
class NotABundle(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1837
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1838
    _fmt = "Not a bzr revision-bundle: %(text)r"
1185.82.142 by Aaron Bentley
Update for review comments
1839
1185.82.139 by Aaron Bentley
Raise NotABundle when a non-bundle is supplied
1840
    def __init__(self, text):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1841
        BzrError.__init__(self)
1907.2.1 by Hermann Kraus
Convert bundle errors from Exception to BzrNewError.
1842
        self.text = text
1843
1844
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1845
class BadBundle(BzrError):
1846
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1847
    _fmt = "Bad bzr revision-bundle: %(text)r"
1907.2.1 by Hermann Kraus
Convert bundle errors from Exception to BzrNewError.
1848
1849
    def __init__(self, text):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1850
        BzrError.__init__(self)
1907.2.1 by Hermann Kraus
Convert bundle errors from Exception to BzrNewError.
1851
        self.text = text
1852
1853
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1854
class MalformedHeader(BadBundle):
1855
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1856
    _fmt = "Malformed bzr revision-bundle header: %(text)r"
1907.2.1 by Hermann Kraus
Convert bundle errors from Exception to BzrNewError.
1857
1858
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1859
class MalformedPatches(BadBundle):
1860
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1861
    _fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1907.2.1 by Hermann Kraus
Convert bundle errors from Exception to BzrNewError.
1862
1863
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1864
class MalformedFooter(BadBundle):
1865
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1866
    _fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1907.2.2 by Hermann Kraus
Detect wrong eol markers.
1867
1752.3.14 by Andrew Bennetts
Fix shallow bug (bad conflict resolution?) in errors.UnsupportedEOLMarker
1868
1907.2.2 by Hermann Kraus
Detect wrong eol markers.
1869
class UnsupportedEOLMarker(BadBundle):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1870
1871
    _fmt = "End of line marker was not \\n in bzr revision-bundle"
1907.2.2 by Hermann Kraus
Detect wrong eol markers.
1872
1873
    def __init__(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1874
        # XXX: BadBundle's constructor assumes there's explanatory text,
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1875
        # but for this there is not
1876
        BzrError.__init__(self)
1877
1878
1879
class IncompatibleBundleFormat(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1880
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1881
    _fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1910.2.49 by Aaron Bentley
Ensure that 0.8 bundles aren't used with KnitRepository2
1882
1883
    def __init__(self, bundle_format, other):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1884
        BzrError.__init__(self)
1910.2.49 by Aaron Bentley
Ensure that 0.8 bundles aren't used with KnitRepository2
1885
        self.bundle_format = bundle_format
1886
        self.other = other
1887
1888
2100.3.5 by Aaron Bentley
Merge nested-trees work
1889
class RootNotRich(BzrError):
1890
1891
    _fmt = """This operation requires rich root data storage"""
1892
1893
2871.1.1 by Robert Collins
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
1894
class NoSmartMedium(InternalBzrError):
2067.3.3 by Martin Pool
merge bzr.dev and reconcile several changes, also some test fixes
1895
1896
    _fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
2100.3.30 by Aaron Bentley
Merge from bzr.dev
1897
2018.2.3 by Andrew Bennetts
Starting factoring out the smart server client "medium" from the protocol.
1898
    def __init__(self, transport):
1899
        self.transport = transport
1900
1901
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1902
class UnknownSSH(BzrError):
1903
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
1904
    _fmt = "Unrecognised value for BRZ_SSH environment variable: %(vendor)s"
1951.1.8 by Andrew Bennetts
Make _get_ssh_vendor return the vendor object, rather than just a string.
1905
1906
    def __init__(self, vendor):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1907
        BzrError.__init__(self)
1951.1.8 by Andrew Bennetts
Make _get_ssh_vendor return the vendor object, rather than just a string.
1908
        self.vendor = vendor
1909
1908.5.16 by Robert Collins
Merge bzr.dev to resolve conflicts for merging.
1910
2221.5.1 by Dmitry Vasiliev
Added support for Putty's SSH implementation
1911
class SSHVendorNotFound(BzrError):
1912
2221.5.9 by Dmitry Vasiliev
Removed trailing whitespaces and wrapped all long lines
1913
    _fmt = ("Don't know how to handle SSH connections."
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
1914
            " Please set BRZ_SSH environment variable.")
2221.5.1 by Dmitry Vasiliev
Added support for Putty's SSH implementation
1915
1916
3445.1.1 by John Arbash Meinel
Start working on a new Graph api to make finding revision numbers faster.
1917
class GhostRevisionsHaveNoRevno(BzrError):
1918
    """When searching for revnos, if we encounter a ghost, we are stuck"""
1919
1920
    _fmt = ("Could not determine revno for {%(revision_id)s} because"
1921
            " its ancestry shows a ghost at {%(ghost_revision_id)s}")
1922
1923
    def __init__(self, revision_id, ghost_revision_id):
1924
        self.revision_id = revision_id
1925
        self.ghost_revision_id = ghost_revision_id
1926
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1927
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1928
class GhostRevisionUnusableHere(BzrError):
1929
1930
    _fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
1931
1932
    def __init__(self, revision_id):
2067.3.1 by Martin Pool
Clean up BzrNewError, other exception classes and users.
1933
        BzrError.__init__(self)
1908.5.9 by Robert Collins
Add a guard against setting the tree last-revision value to a ghost in the new tree parent management api.
1934
        self.revision_id = revision_id
1996.1.16 by John Arbash Meinel
Raise an exception when ScopeReplacer has been misused
1935
1936
1551.12.49 by Aaron Bentley
Proper error when deserializing junk
1937
class NotAMergeDirective(BzrError):
1938
    """File starting with %(firstline)r is not a merge directive"""
7143.15.2 by Jelmer Vernooij
Run autopep8.
1939
1551.12.49 by Aaron Bentley
Proper error when deserializing junk
1940
    def __init__(self, firstline):
1941
        BzrError.__init__(self, firstline=firstline)
1942
1943
1551.12.2 by Aaron Bentley
Got directives round-tripping, with bundles and everything
1944
class NoMergeSource(BzrError):
1945
    """Raise if no merge source was specified for a merge directive"""
1946
1947
    _fmt = "A merge directive must provide either a bundle or a public"\
1551.12.5 by Aaron Bentley
Get MergeDirective.from_objects working
1948
        " branch location."
1551.12.2 by Aaron Bentley
Got directives round-tripping, with bundles and everything
1949
1950
2520.4.105 by Aaron Bentley
Implement patch verification
1951
class PatchVerificationFailed(BzrError):
1952
    """A patch from a merge directive could not be verified"""
1953
2520.4.106 by Aaron Bentley
Clarify what patch verification failure means
1954
    _fmt = "Preview patch does not match requested changes."
2520.4.105 by Aaron Bentley
Implement patch verification
1955
1956
1551.12.2 by Aaron Bentley
Got directives round-tripping, with bundles and everything
1957
class PatchMissing(BzrError):
1958
    """Raise a patch type was specified but no patch supplied"""
1959
2872.5.1 by Martin Pool
Avoid internal error tracebacks on failure to lock on readonly transport (#129701).
1960
    _fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
1551.12.2 by Aaron Bentley
Got directives round-tripping, with bundles and everything
1961
1962
    def __init__(self, patch_type):
1963
        BzrError.__init__(self)
1964
        self.patch_type = patch_type
1551.12.25 by Aaron Bentley
Merge bzr.dev
1965
1966
3535.8.1 by James Westby
Handle something that isn't a branch being specified in target_branch.
1967
class TargetNotBranch(BzrError):
1968
    """A merge directive's target branch is required, but isn't a branch"""
1969
1970
    _fmt = ("Your branch does not have all of the revisions required in "
3535.8.4 by James Westby
Replace "however" with "and" at John's request.
1971
            "order to merge this merge directive and the target "
3535.8.3 by James Westby
Use location instead of branch as suggested by Robert.
1972
            "location specified in the merge directive is not a branch: "
3535.8.1 by James Westby
Handle something that isn't a branch being specified in target_branch.
1973
            "%(location)s.")
1974
1975
    def __init__(self, location):
1976
        BzrError.__init__(self)
1977
        self.location = location
1978
1979
2100.3.9 by Aaron Bentley
Clean up BzrNewError usage
1980
class BadSubsumeSource(BzrError):
1981
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
1982
    _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
1731.2.5 by Aaron Bentley
Ensure versionedfile will be produced for subsumed tree root
1983
1731.2.2 by Aaron Bentley
Test subsume failure modes
1984
    def __init__(self, tree, other_tree, reason):
1985
        self.tree = tree
1986
        self.other_tree = other_tree
1987
        self.reason = reason
1731.2.5 by Aaron Bentley
Ensure versionedfile will be produced for subsumed tree root
1988
1989
2100.3.9 by Aaron Bentley
Clean up BzrNewError usage
1990
class SubsumeTargetNeedsUpgrade(BzrError):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
1991
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
1992
    _fmt = """Subsume target %(other_tree)s needs to be upgraded."""
1731.2.5 by Aaron Bentley
Ensure versionedfile will be produced for subsumed tree root
1993
1994
    def __init__(self, other_tree):
1995
        self.other_tree = other_tree
2100.3.8 by Aaron Bentley
Add add_reference
1996
1997
2220.2.2 by Martin Pool
Add tag command and basic implementation
1998
class NoSuchTag(BzrError):
1999
2000
    _fmt = "No such tag: %(tag_name)s"
2001
2002
    def __init__(self, tag_name):
2003
        self.tag_name = tag_name
2220.2.4 by Martin Pool
Repositories which don't support tags now give a better message
2004
2005
2006
class TagsNotSupported(BzrError):
2007
2221.5.14 by Dmitry Vasiliev
Wrapped long lines
2008
    _fmt = ("Tags not supported by %(branch)s;"
7290.24.1 by Jelmer Vernooij
Suggest full command to run when tags are unsupported.
2009
            " you may be able to use 'brz upgrade %(branch_url)s'.")
2220.2.5 by Martin Pool
Better TagsNotSupported message
2010
2220.2.21 by Martin Pool
Add tag --delete command and implementation
2011
    def __init__(self, branch):
2220.2.23 by Martin Pool
Fix TagsNotSupportedError
2012
        self.branch = branch
7290.24.1 by Jelmer Vernooij
Suggest full command to run when tags are unsupported.
2013
        self.branch_url = branch.user_url
2220.2.42 by Martin Pool
Tag command refuses to replace existing tags unless you force it.
2014
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
2015
2220.2.42 by Martin Pool
Tag command refuses to replace existing tags unless you force it.
2016
class TagAlreadyExists(BzrError):
2017
2018
    _fmt = "Tag %(tag_name)s already exists."
2019
2020
    def __init__(self, tag_name):
2021
        self.tag_name = tag_name
2018.5.163 by Andrew Bennetts
Deal with various review comments from Robert.
2022
2023
2024
class UnexpectedSmartServerResponse(BzrError):
2025
2026
    _fmt = "Could not understand response from smart server: %(response_tuple)r"
2027
2028
    def __init__(self, response_tuple):
2029
        self.response_tuple = response_tuple
2506.2.1 by Andrew Bennetts
Start implementing container format reading and writing.
2030
2031
3245.4.5 by Andrew Bennetts
Implement interrupting body streams with an error.
2032
class ErrorFromSmartServer(BzrError):
3690.1.1 by Andrew Bennetts
Unexpected error responses from a smart server no longer cause the client to traceback.
2033
    """An error was received from a smart server.
2034
3690.1.2 by Andrew Bennetts
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer.
2035
    :seealso: UnknownErrorFromSmartServer
3690.1.1 by Andrew Bennetts
Unexpected error responses from a smart server no longer cause the client to traceback.
2036
    """
3245.4.5 by Andrew Bennetts
Implement interrupting body streams with an error.
2037
2038
    _fmt = "Error received from smart server: %(error_tuple)r"
2039
2040
    internal_error = True
2041
2042
    def __init__(self, error_tuple):
2043
        self.error_tuple = error_tuple
3245.4.53 by Andrew Bennetts
Add some missing 'raise' statements to test_remote.
2044
        try:
2045
            self.error_verb = error_tuple[0]
2046
        except IndexError:
2047
            self.error_verb = None
3245.4.52 by Andrew Bennetts
Add 'error_verb' and 'error_args' attributes to ErrorFromSmartServer.
2048
        self.error_args = error_tuple[1:]
3245.4.5 by Andrew Bennetts
Implement interrupting body streams with an error.
2049
2050
3690.1.2 by Andrew Bennetts
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer.
2051
class UnknownErrorFromSmartServer(BzrError):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
2052
    """An ErrorFromSmartServer could not be translated into a typical breezy
3690.1.1 by Andrew Bennetts
Unexpected error responses from a smart server no longer cause the client to traceback.
2053
    error.
2054
2055
    This is distinct from ErrorFromSmartServer so that it is possible to
2056
    distinguish between the following two cases:
5891.1.2 by Andrew Bennetts
Fix a bunch of docstring formatting nits, making pydoctor a bit happier.
2057
2058
    - ErrorFromSmartServer was uncaught.  This is logic error in the client
2059
      and so should provoke a traceback to the user.
2060
    - ErrorFromSmartServer was caught but its error_tuple could not be
2061
      translated.  This is probably because the server sent us garbage, and
2062
      should not provoke a traceback.
3690.1.1 by Andrew Bennetts
Unexpected error responses from a smart server no longer cause the client to traceback.
2063
    """
2064
2065
    _fmt = "Server sent an unexpected error: %(error_tuple)r"
2066
2067
    internal_error = False
2068
2069
    def __init__(self, error_from_smart_server):
2070
        """Constructor.
2071
2072
        :param error_from_smart_server: An ErrorFromSmartServer instance.
2073
        """
2074
        self.error_from_smart_server = error_from_smart_server
2075
        self.error_tuple = error_from_smart_server.error_tuple
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
2076
3690.1.1 by Andrew Bennetts
Unexpected error responses from a smart server no longer cause the client to traceback.
2077
2506.2.1 by Andrew Bennetts
Start implementing container format reading and writing.
2078
class ContainerError(BzrError):
2079
    """Base class of container errors."""
2080
2081
2082
class UnknownContainerFormatError(ContainerError):
2083
2084
    _fmt = "Unrecognised container format: %(container_format)r"
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
2085
2506.2.1 by Andrew Bennetts
Start implementing container format reading and writing.
2086
    def __init__(self, container_format):
2087
        self.container_format = container_format
2088
2089
2090
class UnexpectedEndOfContainerError(ContainerError):
2091
2092
    _fmt = "Unexpected end of container stream"
2093
2094
2095
class UnknownRecordTypeError(ContainerError):
2096
2097
    _fmt = "Unknown record type: %(record_type)r"
2098
2099
    def __init__(self, record_type):
2100
        self.record_type = record_type
2101
2102
2506.3.1 by Andrew Bennetts
More progress:
2103
class InvalidRecordError(ContainerError):
2104
2105
    _fmt = "Invalid record: %(reason)s"
2106
2107
    def __init__(self, reason):
2108
        self.reason = reason
2109
2506.2.6 by Andrew Bennetts
Add validate method to ContainerReader and BytesRecordReader.
2110
2111
class ContainerHasExcessDataError(ContainerError):
2112
2113
    _fmt = "Container has data after end marker: %(excess)r"
2114
2115
    def __init__(self, excess):
2116
        self.excess = excess
2117
2506.6.1 by Andrew Bennetts
Return a callable instead of a str from read, and add more validation.
2118
2119
class DuplicateRecordNameError(ContainerError):
2120
2745.3.3 by Daniel Watkins
Changed to remove need for escaping of quotes.
2121
    _fmt = "Container has multiple records with the same name: %(name)s"
2506.6.1 by Andrew Bennetts
Return a callable instead of a str from read, and add more validation.
2122
2123
    def __init__(self, name):
6112.5.11 by Jonathan Riddell
resolve that _fmt strings should be ascii so no longer allow for unicode prior to gettext()
2124
        self.name = name.decode("utf-8")
2506.6.1 by Andrew Bennetts
Return a callable instead of a str from read, and add more validation.
2125
2520.4.107 by Aaron Bentley
Merge bzr.dev
2126
2535.3.42 by Andrew Bennetts
Merge from bzr.dev
2127
class RepositoryDataStreamError(BzrError):
2128
2129
    _fmt = "Corrupt or incompatible data stream: %(reason)s"
2130
2131
    def __init__(self, reason):
2132
        self.reason = reason
2133
2134
2796.2.1 by Aaron Bentley
Begin work on reconfigure command
2135
class UncommittedChanges(BzrError):
2136
4487.2.4 by Vincent Ladeuil
Start addressing jam's concerns.
2137
    _fmt = ('Working tree "%(display_url)s" has uncommitted changes'
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
2138
            ' (See brz status).%(more)s')
2796.2.1 by Aaron Bentley
Begin work on reconfigure command
2139
4487.2.6 by Vincent Ladeuil
Fixed as per jam's review.
2140
    def __init__(self, tree, more=None):
2141
        if more is None:
2142
            more = ''
2143
        else:
2144
            more = ' ' + more
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
2145
        import breezy.urlutils as urlutils
5368.1.1 by Jelmer Vernooij
Allow passing a tree without a user_url attribute to UncommittedChanges.
2146
        user_url = getattr(tree, "user_url", None)
2147
        if user_url is None:
2148
            display_url = str(tree)
2149
        else:
2150
            display_url = urlutils.unescape_for_display(user_url, 'ascii')
4487.2.6 by Vincent Ladeuil
Fixed as per jam's review.
2151
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
3006.2.1 by Alexander Belchenko
workaround for bug #81689: give a proper error message instead of traceback when symlink cannot be created (e.g. on Windows)
2152
2153
6538.1.31 by Aaron Bentley
Support foreign branches.
2154
class StoringUncommittedNotSupported(BzrError):
2155
2156
    _fmt = ('Branch "%(display_url)s" does not support storing uncommitted'
2157
            ' changes.')
2158
2159
    def __init__(self, branch):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
2160
        import breezy.urlutils as urlutils
6538.1.31 by Aaron Bentley
Support foreign branches.
2161
        user_url = getattr(branch, "user_url", None)
2162
        if user_url is None:
2163
            display_url = str(branch)
2164
        else:
2165
            display_url = urlutils.unescape_for_display(user_url, 'ascii')
2166
        BzrError.__init__(self, branch=branch, display_url=display_url)
2167
2168
5268.3.1 by Matt Giuca
remove-tree now refuses to run without --force if there are shelved changes.
2169
class ShelvedChanges(UncommittedChanges):
2170
2171
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
2172
            ' (See brz shelve --list).%(more)s')
5268.3.1 by Matt Giuca
remove-tree now refuses to run without --force if there are shelved changes.
2173
2174
3234.2.6 by Alexander Belchenko
because every mail client has different rules to compose command line we should encode arguments to 8 bit string only when needed.
2175
class UnableEncodePath(BzrError):
2176
3234.2.8 by Alexander Belchenko
fix grammar in formatting string of UnableEncodePath error.
2177
    _fmt = ('Unable to encode %(kind)s path %(path)r in '
3234.2.6 by Alexander Belchenko
because every mail client has different rules to compose command line we should encode arguments to 8 bit string only when needed.
2178
            'user encoding %(user_encoding)s')
2179
2180
    def __init__(self, path, kind):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
2181
        from breezy.osutils import get_user_encoding
3234.2.6 by Alexander Belchenko
because every mail client has different rules to compose command line we should encode arguments to 8 bit string only when needed.
2182
        self.path = path
2183
        self.kind = kind
6318.2.4 by Martin Packman
Remove module level osutils import
2184
        self.user_encoding = get_user_encoding()
3365.1.1 by Andrea Corbellini
Handle errors raised by socket.bind() (bug 200575)
2185
3408.4.1 by Ian Clatworthy
Nicer error when smart server started on an address already in use (Andrea Corbellini)
2186
2900.3.7 by Tim Penhey
Updates from Aaron's review.
2187
class NoSuchAlias(BzrError):
2188
2189
    _fmt = ('The alias "%(alias_name)s" does not exist.')
2190
2191
    def __init__(self, alias_name):
2192
        BzrError.__init__(self, alias_name=alias_name)
2900.3.13 by Tim Penhey
Merge bzr.dev and resolve conflicts.
2193
2194
3365.1.1 by Andrea Corbellini
Handle errors raised by socket.bind() (bug 200575)
2195
class CannotBindAddress(BzrError):
2196
2197
    _fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2198
2199
    def __init__(self, host, port, orig_error):
4634.1.5 by Martin Pool
python2.4 socket.error doesn't have a useful repr
2200
        # nb: in python2.4 socket.error doesn't have a useful repr
3365.1.1 by Andrea Corbellini
Handle errors raised by socket.bind() (bug 200575)
2201
        BzrError.__init__(self, host=host, port=port,
7143.15.2 by Jelmer Vernooij
Run autopep8.
2202
                          orig_error=repr(orig_error.args))
3398.1.29 by Ian Clatworthy
add UnknownRules class & test
2203
2204
3577.1.1 by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom.
2205
class TipChangeRejected(BzrError):
2206
    """A pre_change_branch_tip hook function may raise this to cleanly and
2207
    explicitly abort a change to a branch tip.
2208
    """
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
2209
3577.1.1 by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom.
2210
    _fmt = u"Tip change rejected: %(msg)s"
2211
2212
    def __init__(self, msg):
2213
        self.msg = msg
2214
0.12.68 by Aaron Bentley
Update docs, move items to proper files.
2215
4294.2.8 by Robert Collins
Reduce round trips pushing new branches substantially.
2216
class JailBreak(BzrError):
2217
2218
    _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2219
2220
    def __init__(self, url):
2221
        BzrError.__init__(self, url=url)
2222
2223
0.16.103 by Aaron Bentley
raise UserAbort instead of doing sys.exit
2224
class UserAbort(BzrError):
2225
2226
    _fmt = 'The user aborted the operation.'
3983.1.8 by Daniel Watkins
Added MustHaveWorkingTree error and accompanying test.
2227
2228
4002.1.7 by Andrew Bennetts
Rename UnresumableWriteGroups to UnresumableWriteGroup.
2229
class UnresumableWriteGroup(BzrError):
4032.1.2 by John Arbash Meinel
Track down a few more files that have trailing whitespace.
2230
4002.1.7 by Andrew Bennetts
Rename UnresumableWriteGroups to UnresumableWriteGroup.
2231
    _fmt = ("Repository %(repository)s cannot resume write group "
4002.1.1 by Andrew Bennetts
Implement suspend_write_group/resume_write_group.
2232
            "%(write_groups)r: %(reason)s")
2233
2234
    internal_error = True
2235
2236
    def __init__(self, repository, write_groups, reason):
2237
        self.repository = repository
2238
        self.write_groups = write_groups
2239
        self.reason = reason
2240
2241
2242
class UnsuspendableWriteGroup(BzrError):
4032.1.2 by John Arbash Meinel
Track down a few more files that have trailing whitespace.
2243
4002.1.1 by Andrew Bennetts
Implement suspend_write_group/resume_write_group.
2244
    _fmt = ("Repository %(repository)s cannot suspend a write group.")
2245
2246
    internal_error = True
2247
2248
    def __init__(self, repository):
2249
        self.repository = repository
4347.2.1 by Jelmer Vernooij
Move dpush onto an InterBranch object.
2250
2251
4347.2.3 by Jelmer Vernooij
Clarify name for LossyPushToSameVCS exception.
2252
class LossyPushToSameVCS(BzrError):
2253
2254
    _fmt = ("Lossy push not possible between %(source_branch)r and "
2255
            "%(target_branch)r that are in the same VCS.")
2256
2257
    internal_error = True
2258
2259
    def __init__(self, source_branch, target_branch):
2260
        self.source_branch = source_branch
2261
        self.target_branch = target_branch
4925.1.1 by Jelmer Vernooij
Print a proper error when attempting to push to a foreign VCS for which
2262
2263
2264
class NoRoundtrippingSupport(BzrError):
2265
2266
    _fmt = ("Roundtripping is not supported between %(source_branch)r and "
2267
            "%(target_branch)r.")
2268
2269
    internal_error = True
2270
2271
    def __init__(self, source_branch, target_branch):
2272
        self.source_branch = source_branch
2273
        self.target_branch = target_branch
4976.1.1 by Jelmer Vernooij
Add FileTimestampUnavailable exception.
2274
2275
5051.3.1 by Jelmer Vernooij
Add optional name argument to BzrDir.destroy_branch.
2276
class NoColocatedBranchSupport(BzrError):
2277
6653.6.4 by Jelmer Vernooij
Merge trunk.
2278
    _fmt = ("%(controldir)r does not support co-located branches.")
5051.3.1 by Jelmer Vernooij
Add optional name argument to BzrDir.destroy_branch.
2279
6653.6.4 by Jelmer Vernooij
Merge trunk.
2280
    def __init__(self, controldir):
2281
        self.controldir = controldir
5187.2.6 by Parth Malwankar
lockdir no long mandates whoami but uses unicode version of getuser
2282
5050.7.2 by Parth Malwankar
recursive binding now shows a clear error
2283
2284
class RecursiveBind(BzrError):
2285
5050.7.5 by Parth Malwankar
better error message for RecursiveBind
2286
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
7143.15.2 by Jelmer Vernooij
Run autopep8.
2287
            'Please use `brz unbind` to fix.')
5050.7.5 by Parth Malwankar
better error message for RecursiveBind
2288
2289
    def __init__(self, branch_url):
2290
        self.branch_url = branch_url
5050.7.2 by Parth Malwankar
recursive binding now shows a clear error
2291
5676.1.4 by Jelmer Vernooij
merge bzr.dev.
2292
6217.2.1 by Jelmer Vernooij
Allow tree implementations to not support kind changes.
2293
class UnsupportedKindChange(BzrError):
2294
6217.2.2 by Jelmer Vernooij
Tweak error message.
2295
    _fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2296
            "%(path)s not supported by format %(format)r")
6217.2.1 by Jelmer Vernooij
Allow tree implementations to not support kind changes.
2297
6217.2.2 by Jelmer Vernooij
Tweak error message.
2298
    def __init__(self, path, from_kind, to_kind, format):
6217.2.1 by Jelmer Vernooij
Allow tree implementations to not support kind changes.
2299
        self.path = path
6217.2.2 by Jelmer Vernooij
Tweak error message.
2300
        self.from_kind = from_kind
2301
        self.to_kind = to_kind
2302
        self.format = format
6289.2.1 by Jelmer Vernooij
Move the primary definition of the patches exceptions to bzrlib.errors.
2303
2304
7490.61.1 by Jelmer Vernooij
Rename BzrCommandError to CommandError.
2305
class ChangesAlreadyStored(CommandError):
6538.1.4 by Aaron Bentley
Implement store_uncommitted.
2306
2307
    _fmt = ('Cannot store uncommitted changes because this branch already'
2308
            ' stores uncommitted changes.')
7290.19.3 by Jelmer Vernooij
More tests.
2309
2310
2311
class RevnoOutOfBounds(InternalBzrError):
2312
2313
    _fmt = ("The requested revision number %(revno)d is outside of the "
2314
            "expected boundaries (%(minimum)d <= %(maximum)d).")
2315
2316
    def __init__(self, revno, bounds):
2317
        InternalBzrError.__init__(
2318
            self, revno=revno, minimum=bounds[0], maximum=bounds[1])