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