/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

Merge from bzr.dev, resolving conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2013, 2016 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Exceptions for bzr, and reporting of them.
18
18
"""
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
 
from .sixish import (
23
 
    PY3,
24
 
    )
 
20
 
 
21
from bzrlib import (
 
22
    osutils,
 
23
    symbol_versioning,
 
24
    )
 
25
from bzrlib.patches import (
 
26
    MalformedHunkHeader,
 
27
    MalformedLine,
 
28
    MalformedPatchHeader,
 
29
    PatchConflict,
 
30
    PatchSyntax,
 
31
    )
 
32
 
25
33
 
26
34
# TODO: is there any value in providing the .args field used by standard
27
 
# python exceptions?   A list of values with no names seems less useful
 
35
# python exceptions?   A list of values with no names seems less useful 
28
36
# to me.
29
37
 
30
 
# TODO: Perhaps convert the exception to a string at the moment it's
 
38
# TODO: Perhaps convert the exception to a string at the moment it's 
31
39
# constructed to make sure it will succeed.  But that says nothing about
32
40
# exceptions that are never raised.
33
41
 
36
44
# 'unprintable'.
37
45
 
38
46
 
39
 
# return codes from the brz program
40
 
EXIT_OK = 0
41
 
EXIT_ERROR = 3
42
 
EXIT_INTERNAL_ERROR = 4
43
 
 
44
 
 
45
 
class BzrError(Exception):
 
47
class BzrError(StandardError):
46
48
    """
47
 
    Base class for errors raised by breezy.
 
49
    Base class for errors raised by bzrlib.
48
50
 
49
 
    :cvar internal_error: if True this was probably caused by a brz bug and
50
 
        should be displayed with a traceback; if False (or absent) this was
51
 
        probably a user or environment error and they don't need the gory
52
 
        details.  (That can be overridden by -Derror on the command line.)
 
51
    :cvar internal_error: if true (or absent) this was probably caused by a
 
52
    bzr bug and should be displayed with a traceback; if False this was
 
53
    probably a user or environment error and they don't need the gory details.
 
54
    (That can be overridden by -Derror on the command line.)
53
55
 
54
56
    :cvar _fmt: Format string to display the error; this is expanded
55
 
        by the instance's dict.
 
57
    by the instance's dict.
56
58
    """
57
 
 
 
59
    
58
60
    internal_error = False
59
61
 
60
62
    def __init__(self, msg=None, **kwds):
65
67
        arguments can be given.  The first is for generic "user" errors which
66
68
        are not intended to be caught and so do not need a specific subclass.
67
69
        The second case is for use with subclasses that provide a _fmt format
68
 
        string to print the arguments.
 
70
        string to print the arguments.  
69
71
 
70
 
        Keyword arguments are taken as parameters to the error, which can
71
 
        be inserted into the format string template.  It's recommended
72
 
        that subclasses override the __init__ method to require specific
 
72
        Keyword arguments are taken as parameters to the error, which can 
 
73
        be inserted into the format string template.  It's recommended 
 
74
        that subclasses override the __init__ method to require specific 
73
75
        parameters.
74
76
 
75
77
        :param msg: If given, this is the literal complete text for the error,
76
 
           not subject to expansion. 'msg' is used instead of 'message' because
77
 
           python evolved and, in 2.6, forbids the use of 'message'.
 
78
        not subject to expansion.
78
79
        """
79
 
        Exception.__init__(self)
 
80
        StandardError.__init__(self)
80
81
        if msg is not None:
81
82
            # I was going to deprecate this, but it actually turns out to be
82
83
            # quite handy - mbp 20061103.
86
87
            for key, value in kwds.items():
87
88
                setattr(self, key, value)
88
89
 
89
 
    def _format(self):
 
90
    def __str__(self):
90
91
        s = getattr(self, '_preformatted_string', None)
91
92
        if s is not None:
92
 
            # contains a preformatted message
93
 
            return s
94
 
        err = None
 
93
            # contains a preformatted message; must be cast to plain str
 
94
            return str(s)
95
95
        try:
96
96
            fmt = self._get_format_string()
97
97
            if fmt:
98
 
                d = dict(self.__dict__)
99
 
                s = fmt % d
 
98
                s = fmt % self.__dict__
100
99
                # __str__() should always return a 'str' object
101
100
                # never a 'unicode' object.
 
101
                if isinstance(s, unicode):
 
102
                    return s.encode('utf8')
102
103
                return s
103
 
        except Exception as e:
104
 
            err = e
105
 
        return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
 
104
        except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
 
105
            return 'Unprintable exception %s: dict=%r, fmt=%r, error=%s' \
 
106
                % (self.__class__.__name__,
 
107
                   self.__dict__,
 
108
                   getattr(self, '_fmt', None),
 
109
                   str(e))
 
110
 
 
111
    def _get_format_string(self):
 
112
        """Return format string for this exception or None"""
 
113
        fmt = getattr(self, '_fmt', None)
 
114
        if fmt is not None:
 
115
            return fmt
 
116
        fmt = getattr(self, '__doc__', None)
 
117
        if fmt is not None:
 
118
            symbol_versioning.warn("%s uses its docstring as a format, "
 
119
                    "it should use _fmt instead" % self.__class__.__name__,
 
120
                    DeprecationWarning)
 
121
            return fmt
 
122
        return 'Unprintable exception %s: dict=%r, fmt=%r' \
106
123
            % (self.__class__.__name__,
107
124
               self.__dict__,
108
125
               getattr(self, '_fmt', None),
109
 
               err)
110
 
 
111
 
    if PY3:
112
 
        __str__ = _format
113
 
    else:
114
 
        def __str__(self):
115
 
            return self._format().encode('utf-8')
116
 
 
117
 
        __unicode__ = _format
118
 
 
119
 
    def __repr__(self):
120
 
        return '%s(%s)' % (self.__class__.__name__, str(self))
121
 
 
122
 
    def _get_format_string(self):
123
 
        """Return format string for this exception or None"""
124
 
        fmt = getattr(self, '_fmt', None)
125
 
        if fmt is not None:
126
 
            from breezy.i18n import gettext
127
 
            return gettext(fmt) # _fmt strings should be ascii
128
 
 
129
 
    def __eq__(self, other):
130
 
        if self.__class__ is not other.__class__:
131
 
            return NotImplemented
132
 
        return self.__dict__ == other.__dict__
133
 
 
134
 
    def __hash__(self):
135
 
        return id(self)
136
 
 
137
 
 
138
 
class InternalBzrError(BzrError):
139
 
    """Base class for errors that are internal in nature.
140
 
 
141
 
    This is a convenience class for errors that are internal. The
142
 
    internal_error attribute can still be altered in subclasses, if needed.
143
 
    Using this class is simply an easy way to get internal errors.
144
 
    """
145
 
 
146
 
    internal_error = True
147
 
 
148
 
 
149
 
class BranchError(BzrError):
150
 
    """Base class for concrete 'errors about a branch'."""
151
 
 
152
 
    def __init__(self, branch):
153
 
        BzrError.__init__(self, branch=branch)
154
 
 
155
 
 
156
 
class BzrCheckError(InternalBzrError):
157
 
 
158
 
    _fmt = "Internal check failed: %(msg)s"
159
 
 
160
 
    def __init__(self, msg):
161
 
        BzrError.__init__(self)
162
 
        self.msg = msg
163
 
 
164
 
 
165
 
class IncompatibleVersion(BzrError):
166
 
 
167
 
    _fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\
168
 
           'is required, but current version is %(current)r.'
169
 
 
170
 
    def __init__(self, api, wanted, current):
171
 
        self.api = api
172
 
        self.wanted = wanted
173
 
        self.current = current
174
 
 
175
 
 
176
 
class InProcessTransport(BzrError):
177
 
 
178
 
    _fmt = "The transport '%(transport)s' is only accessible within this " \
179
 
        "process."
180
 
 
181
 
    def __init__(self, transport):
182
 
        self.transport = transport
183
 
 
184
 
 
185
 
class InvalidEntryName(InternalBzrError):
186
 
 
 
126
               )
 
127
 
 
128
 
 
129
class BzrNewError(BzrError):
 
130
    """Deprecated error base class."""
 
131
    # base classes should override the docstring with their human-
 
132
    # readable explanation
 
133
 
 
134
    def __init__(self, *args, **kwds):
 
135
        # XXX: Use the underlying BzrError to always generate the args
 
136
        # attribute if it doesn't exist.  We can't use super here, because
 
137
        # exceptions are old-style classes in python2.4 (but new in 2.5).
 
138
        # --bmc, 20060426
 
139
        symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
 
140
             'please convert %s to use BzrError instead'
 
141
             % self.__class__.__name__,
 
142
             DeprecationWarning,
 
143
             stacklevel=2)
 
144
        BzrError.__init__(self, *args)
 
145
        for key, value in kwds.items():
 
146
            setattr(self, key, value)
 
147
 
 
148
    def __str__(self):
 
149
        try:
 
150
            # __str__() should always return a 'str' object
 
151
            # never a 'unicode' object.
 
152
            s = self.__doc__ % self.__dict__
 
153
            if isinstance(s, unicode):
 
154
                return s.encode('utf8')
 
155
            return s
 
156
        except (TypeError, NameError, ValueError, KeyError), e:
 
157
            return 'Unprintable exception %s(%r): %s' \
 
158
                % (self.__class__.__name__,
 
159
                   self.__dict__, str(e))
 
160
 
 
161
 
 
162
class AlreadyBuilding(BzrError):
 
163
    
 
164
    _fmt = "The tree builder is already building a tree."
 
165
 
 
166
 
 
167
class BzrCheckError(BzrError):
 
168
    
 
169
    _fmt = "Internal check failed: %(message)s"
 
170
 
 
171
    internal_error = True
 
172
 
 
173
    def __init__(self, message):
 
174
        BzrError.__init__(self)
 
175
        self.message = message
 
176
 
 
177
 
 
178
class DisabledMethod(BzrError):
 
179
 
 
180
    _fmt = "The smart server method '%(class_name)s' is disabled."
 
181
 
 
182
    internal_error = True
 
183
 
 
184
    def __init__(self, class_name):
 
185
        BzrError.__init__(self)
 
186
        self.class_name = class_name
 
187
 
 
188
 
 
189
class InvalidEntryName(BzrError):
 
190
    
187
191
    _fmt = "Invalid entry name: %(name)s"
188
192
 
 
193
    internal_error = True
 
194
 
189
195
    def __init__(self, name):
190
196
        BzrError.__init__(self)
191
197
        self.name = name
192
198
 
193
199
 
194
200
class InvalidRevisionNumber(BzrError):
195
 
 
 
201
    
196
202
    _fmt = "Invalid revision number %(revno)s"
197
203
 
198
204
    def __init__(self, revno):
210
216
        self.revision_id = revision_id
211
217
        self.branch = branch
212
218
 
213
 
 
214
219
class ReservedId(BzrError):
215
220
 
216
221
    _fmt = "Reserved revision-id {%(revision_id)s}"
218
223
    def __init__(self, revision_id):
219
224
        self.revision_id = revision_id
220
225
 
221
 
 
222
 
class RootMissing(InternalBzrError):
223
 
 
224
 
    _fmt = ("The root entry of a tree must be the first entry supplied to "
225
 
        "the commit builder.")
226
 
 
227
 
 
228
 
class NoPublicBranch(BzrError):
229
 
 
230
 
    _fmt = 'There is no public branch set for "%(branch_url)s".'
231
 
 
232
 
    def __init__(self, branch):
233
 
        from . import urlutils
234
 
        public_location = urlutils.unescape_for_display(branch.base, 'ascii')
235
 
        BzrError.__init__(self, branch_url=public_location)
236
 
 
237
 
 
238
226
class NoSuchId(BzrError):
239
227
 
240
 
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
241
 
 
 
228
    _fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
 
229
    
242
230
    def __init__(self, tree, file_id):
243
231
        BzrError.__init__(self)
244
232
        self.file_id = file_id
245
233
        self.tree = tree
246
234
 
247
235
 
248
 
class NotStacked(BranchError):
249
 
 
250
 
    _fmt = "The branch '%(branch)s' is not stacked."
251
 
 
252
 
 
253
 
class InventoryModified(InternalBzrError):
 
236
class InventoryModified(BzrError):
254
237
 
255
238
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
256
239
            " so a clean inventory cannot be read without data loss.")
257
240
 
 
241
    internal_error = True
 
242
 
258
243
    def __init__(self, tree):
259
244
        self.tree = tree
260
245
 
261
246
 
262
247
class NoWorkingTree(BzrError):
263
248
 
264
 
    _fmt = 'No WorkingTree exists for "%(base)s".'
265
 
 
 
249
    _fmt = "No WorkingTree exists for %(base)s."
 
250
    
266
251
    def __init__(self, base):
267
252
        BzrError.__init__(self)
268
253
        self.base = base
269
254
 
270
255
 
 
256
class NotBuilding(BzrError):
 
257
 
 
258
    _fmt = "Not currently building a tree."
 
259
 
 
260
 
271
261
class NotLocalUrl(BzrError):
272
262
 
273
263
    _fmt = "%(url)s is not a local path."
276
266
        self.url = url
277
267
 
278
268
 
279
 
class WorkingTreeAlreadyPopulated(InternalBzrError):
280
 
 
281
 
    _fmt = 'Working tree already populated in "%(base)s"'
 
269
class WorkingTreeAlreadyPopulated(BzrError):
 
270
 
 
271
    _fmt = """Working tree already populated in %(base)s"""
 
272
 
 
273
    internal_error = True
282
274
 
283
275
    def __init__(self, base):
284
276
        self.base = base
285
277
 
286
 
 
287
278
class BzrCommandError(BzrError):
288
279
    """Error from user command"""
289
280
 
 
281
    internal_error = False
 
282
 
290
283
    # Error from malformed user command; please avoid raising this as a
291
284
    # generic exception not caused by user input.
292
285
    #
294
287
    # are not intended to be caught anyway.  UI code need not subclass
295
288
    # BzrCommandError, and non-UI code should not throw a subclass of
296
289
    # BzrCommandError.  ADHB 20051211
 
290
    def __init__(self, msg):
 
291
        # Object.__str__() must return a real string
 
292
        # returning a Unicode string is a python error.
 
293
        if isinstance(msg, unicode):
 
294
            self.msg = msg.encode('utf8')
 
295
        else:
 
296
            self.msg = msg
 
297
 
 
298
    def __str__(self):
 
299
        return self.msg
297
300
 
298
301
 
299
302
class NotWriteLocked(BzrError):
304
307
        self.not_locked = not_locked
305
308
 
306
309
 
 
310
class BzrOptionError(BzrCommandError):
 
311
 
 
312
    _fmt = "Error in command line options"
 
313
 
 
314
 
 
315
class BadOptionValue(BzrError):
 
316
 
 
317
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
 
318
 
 
319
    def __init__(self, name, value):
 
320
        BzrError.__init__(self, name=name, value=value)
 
321
 
 
322
    
307
323
class StrictCommitFailed(BzrError):
308
324
 
309
325
    _fmt = "Commit refused because there are unknown files in the tree"
311
327
 
312
328
# XXX: Should be unified with TransportError; they seem to represent the
313
329
# same thing
314
 
# RBC 20060929: I think that unifiying with TransportError would be a mistake
315
 
# - this is finer than a TransportError - and more useful as such. It
316
 
# differentiates between 'transport has failed' and 'operation on a transport
317
 
# has failed.'
318
330
class PathError(BzrError):
319
 
 
 
331
    
320
332
    _fmt = "Generic path error: %(path)r%(extra)s)"
321
333
 
322
334
    def __init__(self, path, extra=None):
342
354
    """Used when renaming and both source and dest exist."""
343
355
 
344
356
    _fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
345
 
            " (Use --after to tell brz about a rename that has already"
346
 
            " happened)%(extra)s")
 
357
            "%(extra)s")
347
358
 
348
359
    def __init__(self, source, dest, extra=None):
349
360
        BzrError.__init__(self)
357
368
 
358
369
class NotADirectory(PathError):
359
370
 
360
 
    _fmt = '"%(path)s" is not a directory %(extra)s'
 
371
    _fmt = "%(path)r is not a directory %(extra)s"
361
372
 
362
373
 
363
374
class NotInWorkingDirectory(PathError):
364
375
 
365
 
    _fmt = '"%(path)s" is not in the working directory %(extra)s'
 
376
    _fmt = "%(path)r is not in the working directory %(extra)s"
366
377
 
367
378
 
368
379
class DirectoryNotEmpty(PathError):
369
380
 
370
 
    _fmt = 'Directory not empty: "%(path)s"%(extra)s'
371
 
 
372
 
 
373
 
class HardLinkNotSupported(PathError):
374
 
 
375
 
    _fmt = 'Hard-linking "%(path)s" is not supported'
376
 
 
377
 
 
378
 
class ReadingCompleted(InternalBzrError):
379
 
 
 
381
    _fmt = "Directory not empty: %(path)r%(extra)s"
 
382
 
 
383
 
 
384
class ReadingCompleted(BzrError):
 
385
    
380
386
    _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
381
387
            "called upon it - the request has been completed and no more "
382
388
            "data may be read.")
383
389
 
 
390
    internal_error = True
 
391
 
384
392
    def __init__(self, request):
385
393
        self.request = request
386
394
 
387
395
 
388
396
class ResourceBusy(PathError):
389
397
 
390
 
    _fmt = 'Device or resource busy: "%(path)s"%(extra)s'
 
398
    _fmt = "Device or resource busy: %(path)r%(extra)s"
391
399
 
392
400
 
393
401
class PermissionDenied(PathError):
394
402
 
395
 
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
396
 
 
397
 
 
398
 
class UnavailableRepresentation(InternalBzrError):
399
 
 
400
 
    _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
401
 
        "is encoded as '%(native)s'.")
402
 
 
403
 
    def __init__(self, key, wanted, native):
404
 
        InternalBzrError.__init__(self)
405
 
        self.wanted = wanted
406
 
        self.native = native
407
 
        self.key = key
 
403
    _fmt = "Permission denied: %(path)r%(extra)s"
 
404
 
 
405
 
 
406
class InvalidURL(PathError):
 
407
 
 
408
    _fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
 
409
 
 
410
 
 
411
class InvalidURLJoin(PathError):
 
412
 
 
413
    _fmt = "Invalid URL join request: %(args)s%(extra)s"
 
414
 
 
415
    def __init__(self, msg, base, args):
 
416
        PathError.__init__(self, base, msg)
 
417
        self.args = [base] + list(args)
 
418
 
 
419
 
 
420
class UnknownHook(BzrError):
 
421
 
 
422
    _fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
 
423
 
 
424
    def __init__(self, hook_type, hook_name):
 
425
        BzrError.__init__(self)
 
426
        self.type = hook_type
 
427
        self.hook = hook_name
408
428
 
409
429
 
410
430
class UnsupportedProtocol(PathError):
411
431
 
412
432
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
413
433
 
414
 
    def __init__(self, url, extra=""):
 
434
    def __init__(self, url, extra):
415
435
        PathError.__init__(self, url, extra=extra)
416
436
 
417
437
 
418
 
class UnstackableLocationError(BzrError):
419
 
 
420
 
    _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
421
 
 
422
 
    def __init__(self, branch_url, target_url):
423
 
        BzrError.__init__(self)
424
 
        self.branch_url = branch_url
425
 
        self.target_url = target_url
426
 
 
427
 
 
428
 
class UnstackableRepositoryFormat(BzrError):
429
 
 
430
 
    _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
431
 
        "You will need to upgrade the repository to permit branch stacking.")
432
 
 
433
 
    def __init__(self, format, url):
434
 
        BzrError.__init__(self)
435
 
        self.format = format
436
 
        self.url = url
437
 
 
438
 
 
439
 
class ReadError(PathError):
440
 
 
441
 
    _fmt = """Error reading from %(path)r."""
442
 
 
443
 
 
444
438
class ShortReadvError(PathError):
445
439
 
446
 
    _fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
447
 
            ' at %(offset)s for "%(path)s"%(extra)s')
 
440
    _fmt = ("readv() read %(actual)s bytes rather than %(length)s bytes"
 
441
            " at %(offset)s for %(path)s%(extra)s")
448
442
 
449
443
    internal_error = True
450
444
 
455
449
        self.actual = actual
456
450
 
457
451
 
458
 
class PathNotChild(PathError):
459
 
 
460
 
    _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
461
 
 
462
 
    internal_error = False
 
452
class PathNotChild(BzrError):
 
453
 
 
454
    _fmt = "Path %(path)r is not a child of path %(base)r%(extra)s"
 
455
 
 
456
    internal_error = True
463
457
 
464
458
    def __init__(self, path, base, extra=None):
465
459
        BzrError.__init__(self)
473
467
 
474
468
class InvalidNormalization(PathError):
475
469
 
476
 
    _fmt = 'Path "%(path)s" is not unicode normalized'
 
470
    _fmt = "Path %(path)r is not unicode normalized"
477
471
 
478
472
 
479
473
# TODO: This is given a URL; we try to unescape it but doing that from inside
480
474
# the exception object is a bit undesirable.
481
 
# TODO: Probably this behavior of should be a common superclass
 
475
# TODO: Probably this behavior of should be a common superclass 
482
476
class NotBranchError(PathError):
483
477
 
484
 
    _fmt = 'Not a branch: "%(path)s"%(detail)s.'
485
 
 
486
 
    def __init__(self, path, detail=None, controldir=None):
487
 
       from . import urlutils
488
 
       path = urlutils.unescape_for_display(path, 'ascii')
489
 
       if detail is not None:
490
 
           detail = ': ' + detail
491
 
       self.detail = detail
492
 
       self.controldir = controldir
493
 
       PathError.__init__(self, path=path)
494
 
 
495
 
    def __repr__(self):
496
 
        return '<%s %r>' % (self.__class__.__name__, self.__dict__)
497
 
 
498
 
    def _get_format_string(self):
499
 
        # GZ 2017-06-08: Not the best place to lazy fill detail in.
500
 
        if self.detail is None:
501
 
           self.detail = self._get_detail()
502
 
        return super(NotBranchError, self)._get_format_string()
503
 
 
504
 
    def _get_detail(self):
505
 
        if self.controldir is not None:
506
 
            try:
507
 
                self.controldir.open_repository()
508
 
            except NoRepositoryPresent:
509
 
                return ''
510
 
            except Exception as e:
511
 
                # Just ignore unexpected errors.  Raising arbitrary errors
512
 
                # during str(err) can provoke strange bugs.  Concretely
513
 
                # Launchpad's codehosting managed to raise NotBranchError
514
 
                # here, and then get stuck in an infinite loop/recursion
515
 
                # trying to str() that error.  All this error really cares
516
 
                # about that there's no working repository there, and if
517
 
                # open_repository() fails, there probably isn't.
518
 
                return ': ' + e.__class__.__name__
519
 
            else:
520
 
                return ': location is a repository'
521
 
        return ''
 
478
    _fmt = "Not a branch: %(path)s"
 
479
 
 
480
    def __init__(self, path):
 
481
       import bzrlib.urlutils as urlutils
 
482
       self.path = urlutils.unescape_for_display(path, 'ascii')
522
483
 
523
484
 
524
485
class NoSubmitBranch(PathError):
526
487
    _fmt = 'No submit branch available for branch "%(path)s"'
527
488
 
528
489
    def __init__(self, branch):
529
 
       from . import urlutils
 
490
       import bzrlib.urlutils as urlutils
530
491
       self.path = urlutils.unescape_for_display(branch.base, 'ascii')
531
492
 
532
493
 
533
 
class AlreadyControlDirError(PathError):
534
 
 
535
 
    _fmt = 'A control directory already exists: "%(path)s".'
536
 
 
537
 
 
538
494
class AlreadyBranchError(PathError):
539
495
 
540
 
    _fmt = 'Already a branch: "%(path)s".'
541
 
 
542
 
 
543
 
class InvalidBranchName(PathError):
544
 
 
545
 
    _fmt = "Invalid branch name: %(name)s"
546
 
 
547
 
    def __init__(self, name):
548
 
        BzrError.__init__(self)
549
 
        self.name = name
550
 
 
551
 
 
552
 
class ParentBranchExists(AlreadyBranchError):
553
 
 
554
 
    _fmt = 'Parent branch already exists: "%(path)s".'
 
496
    _fmt = "Already a branch: %(path)s."
555
497
 
556
498
 
557
499
class BranchExistsWithoutWorkingTree(PathError):
558
500
 
559
 
    _fmt = 'Directory contains a branch, but no working tree \
560
 
(use brz checkout if you wish to build a working tree): "%(path)s"'
 
501
    _fmt = "Directory contains a branch, but no working tree \
 
502
(use bzr checkout if you wish to build a working tree): %(path)s"
 
503
 
 
504
 
 
505
class AtomicFileAlreadyClosed(PathError):
 
506
 
 
507
    _fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
 
508
            " %(path)s")
 
509
 
 
510
    def __init__(self, path, function):
 
511
        PathError.__init__(self, path=path, extra=None)
 
512
        self.function = function
561
513
 
562
514
 
563
515
class InaccessibleParent(PathError):
564
516
 
565
 
    _fmt = ('Parent not accessible given base "%(base)s" and'
566
 
            ' relative path "%(path)s"')
 
517
    _fmt = ("Parent not accessible given base %(base)s and"
 
518
            " relative path %(path)s")
567
519
 
568
520
    def __init__(self, path, base):
569
521
        PathError.__init__(self, path)
572
524
 
573
525
class NoRepositoryPresent(BzrError):
574
526
 
575
 
    _fmt = 'No repository present: "%(path)s"'
576
 
    def __init__(self, controldir):
577
 
        BzrError.__init__(self)
578
 
        self.path = controldir.transport.clone('..').base
 
527
    _fmt = "No repository present: %(path)r"
 
528
    def __init__(self, bzrdir):
 
529
        BzrError.__init__(self)
 
530
        self.path = bzrdir.transport.clone('..').base
 
531
 
 
532
 
 
533
class FileInWrongBranch(BzrError):
 
534
 
 
535
    _fmt = "File %(path)s in not in branch %(branch_base)s."
 
536
 
 
537
    def __init__(self, branch, path):
 
538
        BzrError.__init__(self)
 
539
        self.branch = branch
 
540
        self.branch_base = branch.base
 
541
        self.path = path
579
542
 
580
543
 
581
544
class UnsupportedFormatError(BzrError):
582
545
 
583
 
    _fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
 
546
    _fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
584
547
 
585
548
 
586
549
class UnknownFormatError(BzrError):
587
 
 
588
 
    _fmt = "Unknown %(kind)s format: %(format)r"
589
 
 
590
 
    def __init__(self, format, kind='branch'):
591
 
        self.kind = kind
592
 
        self.format = format
 
550
    
 
551
    _fmt = "Unknown branch format: %(format)r"
593
552
 
594
553
 
595
554
class IncompatibleFormat(BzrError):
596
 
 
597
 
    _fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
598
 
 
599
 
    def __init__(self, format, controldir_format):
600
 
        BzrError.__init__(self)
601
 
        self.format = format
602
 
        self.controldir = controldir_format
603
 
 
604
 
 
605
 
class ParseFormatError(BzrError):
606
 
 
607
 
    _fmt = "Parse error on line %(lineno)d of %(format)s format: %(line)s"
608
 
 
609
 
    def __init__(self, format, lineno, line, text):
610
 
        BzrError.__init__(self)
611
 
        self.format = format
612
 
        self.lineno = lineno
613
 
        self.line = line
614
 
        self.text = text
 
555
    
 
556
    _fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
 
557
 
 
558
    def __init__(self, format, bzrdir_format):
 
559
        BzrError.__init__(self)
 
560
        self.format = format
 
561
        self.bzrdir = bzrdir_format
615
562
 
616
563
 
617
564
class IncompatibleRepositories(BzrError):
618
 
    """Report an error that two repositories are not compatible.
619
 
 
620
 
    Note that the source and target repositories are permitted to be strings:
621
 
    this exception is thrown from the smart server and may refer to a
622
 
    repository the client hasn't opened.
623
 
    """
624
 
 
625
 
    _fmt = "%(target)s\n" \
626
 
            "is not compatible with\n" \
627
 
            "%(source)s\n" \
628
 
            "%(details)s"
629
 
 
630
 
    def __init__(self, source, target, details=None):
631
 
        if details is None:
632
 
            details = "(no details)"
633
 
        BzrError.__init__(self, target=target, source=source, details=details)
 
565
 
 
566
    _fmt = "Repository %(target)s is not compatible with repository"\
 
567
        " %(source)s"
 
568
 
 
569
    def __init__(self, source, target):
 
570
        BzrError.__init__(self, target=target, source=source)
634
571
 
635
572
 
636
573
class IncompatibleRevision(BzrError):
637
 
 
 
574
    
638
575
    _fmt = "Revision is not compatible with %(repo_format)s"
639
576
 
640
577
    def __init__(self, repo_format):
645
582
class AlreadyVersionedError(BzrError):
646
583
    """Used when a path is expected not to be versioned, but it is."""
647
584
 
648
 
    _fmt = "%(context_info)s%(path)s is already versioned."
 
585
    _fmt = "%(context_info)s%(path)s is already versioned"
649
586
 
650
587
    def __init__(self, path, context_info=None):
651
588
        """Construct a new AlreadyVersionedError.
652
589
 
653
590
        :param path: This is the path which is versioned,
654
 
            which should be in a user friendly form.
 
591
        which should be in a user friendly form.
655
592
        :param context_info: If given, this is information about the context,
656
 
            which could explain why this is expected to not be versioned.
 
593
        which could explain why this is expected to not be versioned.
657
594
        """
658
595
        BzrError.__init__(self)
659
596
        self.path = path
666
603
class NotVersionedError(BzrError):
667
604
    """Used when a path is expected to be versioned, but it is not."""
668
605
 
669
 
    _fmt = "%(context_info)s%(path)s is not versioned."
 
606
    _fmt = "%(context_info)s%(path)s is not versioned"
670
607
 
671
608
    def __init__(self, path, context_info=None):
672
609
        """Construct a new NotVersionedError.
673
610
 
674
611
        :param path: This is the path which is not versioned,
675
 
            which should be in a user friendly form.
 
612
        which should be in a user friendly form.
676
613
        :param context_info: If given, this is information about the context,
677
 
            which could explain why this is expected to be versioned.
 
614
        which could explain why this is expected to be versioned.
678
615
        """
679
616
        BzrError.__init__(self)
680
617
        self.path = path
690
627
    _fmt = "Path(s) are not versioned: %(paths_as_string)s"
691
628
 
692
629
    def __init__(self, paths):
693
 
        from breezy.osutils import quotefn
 
630
        from bzrlib.osutils import quotefn
694
631
        BzrError.__init__(self)
695
632
        self.paths = paths
696
633
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
705
642
 
706
643
    def __init__(self, paths, extra=None):
707
644
        # circular import
708
 
        from breezy.osutils import quotefn
 
645
        from bzrlib.osutils import quotefn
709
646
        BzrError.__init__(self)
710
647
        self.paths = paths
711
648
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
723
660
        BzrError.__init__(self, filename=filename, kind=kind)
724
661
 
725
662
 
726
 
class BadFilenameEncoding(BzrError):
727
 
 
728
 
    _fmt = ('Filename %(filename)r is not valid in your current filesystem'
729
 
            ' encoding %(fs_encoding)s')
730
 
 
731
 
    def __init__(self, filename, fs_encoding):
732
 
        BzrError.__init__(self)
733
 
        self.filename = filename
734
 
        self.fs_encoding = fs_encoding
735
 
 
736
 
 
737
663
class ForbiddenControlFileError(BzrError):
738
664
 
739
 
    _fmt = 'Cannot operate on "%(filename)s" because it is a control file'
740
 
 
741
 
 
742
 
class LockError(InternalBzrError):
 
665
    _fmt = "Cannot operate on %(filename)s because it is a control file"
 
666
 
 
667
 
 
668
class LockError(BzrError):
743
669
 
744
670
    _fmt = "Lock error: %(msg)s"
745
671
 
 
672
    internal_error = True
 
673
 
746
674
    # All exceptions from the lock/unlock functions should be from
747
675
    # this exception class.  They will be translated as necessary. The
748
676
    # original exception is available as e.original_error
749
677
    #
750
678
    # New code should prefer to raise specific subclasses
751
 
    def __init__(self, msg):
752
 
        self.msg = msg
 
679
    def __init__(self, message):
 
680
        # Python 2.5 uses a slot for StandardError.message,
 
681
        # so use a different variable name
 
682
        # so it is exposed in self.__dict__
 
683
        self.msg = message
753
684
 
754
685
 
755
686
class LockActive(LockError):
789
720
        self.obj = obj
790
721
 
791
722
 
792
 
class LockFailed(LockError):
793
 
 
794
 
    internal_error = False
795
 
 
796
 
    _fmt = "Cannot lock %(lock)s: %(why)s"
797
 
 
798
 
    def __init__(self, lock, why):
 
723
class ReadOnlyLockError(LockError):
 
724
 
 
725
    _fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
 
726
 
 
727
    def __init__(self, fname, msg):
799
728
        LockError.__init__(self, '')
800
 
        self.lock = lock
801
 
        self.why = why
 
729
        self.fname = fname
 
730
        self.msg = msg
802
731
 
803
732
 
804
733
class OutSideTransaction(BzrError):
828
757
 
829
758
class UnlockableTransport(LockError):
830
759
 
831
 
    internal_error = False
832
 
 
833
760
    _fmt = "Cannot lock: transport is read only: %(transport)s"
834
761
 
835
762
    def __init__(self, transport):
838
765
 
839
766
class LockContention(LockError):
840
767
 
841
 
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
 
768
    _fmt = "Could not acquire lock %(lock)s"
 
769
    # TODO: show full url for lock, combining the transport and relative
 
770
    # bits?
842
771
 
843
772
    internal_error = False
844
773
 
845
 
    def __init__(self, lock, msg=''):
 
774
    def __init__(self, lock):
846
775
        self.lock = lock
847
 
        self.msg = msg
848
776
 
849
777
 
850
778
class LockBroken(LockError):
871
799
        self.target = target
872
800
 
873
801
 
874
 
class LockCorrupt(LockError):
875
 
 
876
 
    _fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
877
 
            "Use 'brz break-lock' to clear it")
878
 
 
879
 
    internal_error = False
880
 
 
881
 
    def __init__(self, corruption_info, file_data=None):
882
 
        self.corruption_info = corruption_info
883
 
        self.file_data = file_data
884
 
 
885
 
 
886
802
class LockNotHeld(LockError):
887
803
 
888
804
    _fmt = "Lock not held: %(lock)s"
897
813
 
898
814
    _fmt = "The object %(obj)s does not support token specifying a token when locking."
899
815
 
 
816
    internal_error = True
 
817
 
900
818
    def __init__(self, obj):
901
819
        self.obj = obj
902
820
 
912
830
        self.lock_token = lock_token
913
831
 
914
832
 
 
833
class PointlessCommit(BzrError):
 
834
 
 
835
    _fmt = "No changes to commit"
 
836
 
 
837
 
915
838
class UpgradeReadonly(BzrError):
916
839
 
917
840
    _fmt = "Upgrade URL cannot work with readonly URLs."
926
849
        self.format = format
927
850
 
928
851
 
929
 
class NoSuchRevision(InternalBzrError):
930
 
 
931
 
    _fmt = "%(branch)s has no revision %(revision)s"
 
852
class StrictCommitFailed(Exception):
 
853
 
 
854
    _fmt = "Commit refused because there are unknowns in the tree."
 
855
 
 
856
 
 
857
class NoSuchRevision(BzrError):
 
858
 
 
859
    _fmt = "Branch %(branch)s has no revision %(revision)s"
 
860
 
 
861
    internal_error = True
932
862
 
933
863
    def __init__(self, branch, revision):
934
 
        # 'branch' may sometimes be an internal object like a KnitRevisionStore
935
864
        BzrError.__init__(self, branch=branch, revision=revision)
936
865
 
937
866
 
938
 
class RangeInChangeOption(BzrError):
939
 
 
940
 
    _fmt = "Option --change does not accept revision ranges"
 
867
class NotLeftParentDescendant(BzrError):
 
868
 
 
869
    _fmt = ("Revision %(old_revision)s is not the left parent of"
 
870
            " %(new_revision)s, but branch %(branch_location)s expects this")
 
871
 
 
872
    internal_error = True
 
873
 
 
874
    def __init__(self, branch, old_revision, new_revision):
 
875
        BzrError.__init__(self, branch_location=branch.base,
 
876
                          old_revision=old_revision,
 
877
                          new_revision=new_revision)
941
878
 
942
879
 
943
880
class NoSuchRevisionSpec(BzrError):
950
887
 
951
888
class NoSuchRevisionInTree(NoSuchRevision):
952
889
    """When using Tree.revision_tree, and the revision is not accessible."""
953
 
 
954
 
    _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
 
890
    
 
891
    _fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
955
892
 
956
893
    def __init__(self, tree, revision_id):
957
894
        BzrError.__init__(self)
961
898
 
962
899
class InvalidRevisionSpec(BzrError):
963
900
 
964
 
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
965
 
            " %(branch_url)s%(extra)s")
 
901
    _fmt = ("Requested revision: %(spec)r does not exist in branch:"
 
902
            " %(branch)s%(extra)s")
966
903
 
967
904
    def __init__(self, spec, branch, extra=None):
968
905
        BzrError.__init__(self, branch=branch, spec=spec)
969
 
        self.branch_url = getattr(branch, 'user_url', str(branch))
970
906
        if extra:
971
907
            self.extra = '\n' + str(extra)
972
908
        else:
973
909
            self.extra = ''
974
910
 
975
911
 
 
912
class HistoryMissing(BzrError):
 
913
 
 
914
    _fmt = "%(branch)s is missing %(object_type)s {%(object_id)s}"
 
915
 
 
916
 
976
917
class AppendRevisionsOnlyViolation(BzrError):
977
918
 
978
919
    _fmt = ('Operation denied because it would change the main history,'
980
921
           ' branch "%(location)s".')
981
922
 
982
923
    def __init__(self, location):
983
 
       import breezy.urlutils as urlutils
 
924
       import bzrlib.urlutils as urlutils
984
925
       location = urlutils.unescape_for_display(location, 'ascii')
985
926
       BzrError.__init__(self, location=location)
986
927
 
988
929
class DivergedBranches(BzrError):
989
930
 
990
931
    _fmt = ("These branches have diverged."
991
 
            " Use the missing command to see how.\n"
992
 
            "Use the merge command to reconcile them.")
 
932
            " Use the merge command to reconcile them.")
 
933
 
 
934
    internal_error = False
993
935
 
994
936
    def __init__(self, branch1, branch2):
995
937
        self.branch1 = branch1
996
938
        self.branch2 = branch2
997
939
 
998
940
 
999
 
class NotLefthandHistory(InternalBzrError):
 
941
class NotLefthandHistory(BzrError):
1000
942
 
1001
943
    _fmt = "Supplied history does not follow left-hand parents"
1002
944
 
 
945
    internal_error = True
 
946
 
1003
947
    def __init__(self, history):
1004
948
        BzrError.__init__(self, history=history)
1005
949
 
1009
953
    _fmt = ("Branches have no common ancestor, and"
1010
954
            " no merge base revision was specified.")
1011
955
 
1012
 
 
1013
 
class CannotReverseCherrypick(BzrError):
1014
 
 
1015
 
    _fmt = ('Selected merge cannot perform reverse cherrypicks.  Try merge3'
1016
 
            ' or diff3.')
 
956
    internal_error = False
1017
957
 
1018
958
 
1019
959
class NoCommonAncestor(BzrError):
1020
 
 
 
960
    
1021
961
    _fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1022
962
 
1023
963
    def __init__(self, revision_a, revision_b):
1043
983
            not_ancestor_id=not_ancestor_id)
1044
984
 
1045
985
 
1046
 
class NoCommits(BranchError):
 
986
class InstallFailed(BzrError):
 
987
 
 
988
    def __init__(self, revisions):
 
989
        revision_str = ", ".join(str(r) for r in revisions)
 
990
        msg = "Could not install revisions:\n%s" % revision_str
 
991
        BzrError.__init__(self, msg)
 
992
        self.revisions = revisions
 
993
 
 
994
 
 
995
class AmbiguousBase(BzrError):
 
996
 
 
997
    def __init__(self, bases):
 
998
        warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
 
999
                DeprecationWarning)
 
1000
        msg = ("The correct base is unclear, because %s are all equally close"
 
1001
                % ", ".join(bases))
 
1002
        BzrError.__init__(self, msg)
 
1003
        self.bases = bases
 
1004
 
 
1005
 
 
1006
class NoCommits(BzrError):
1047
1007
 
1048
1008
    _fmt = "Branch %(branch)s has no commits."
1049
1009
 
 
1010
    def __init__(self, branch):
 
1011
        BzrError.__init__(self, branch=branch)
 
1012
 
1050
1013
 
1051
1014
class UnlistableStore(BzrError):
1052
1015
 
1063
1026
 
1064
1027
class BoundBranchOutOfDate(BzrError):
1065
1028
 
1066
 
    _fmt = ("Bound branch %(branch)s is out of date with master branch"
1067
 
            " %(master)s.%(extra_help)s")
 
1029
    _fmt = ("Bound branch %(branch)s is out of date"
 
1030
            " with master branch %(master)s.")
1068
1031
 
1069
1032
    def __init__(self, branch, master):
1070
1033
        BzrError.__init__(self)
1071
1034
        self.branch = branch
1072
1035
        self.master = master
1073
 
        self.extra_help = ''
1074
 
 
1075
 
 
 
1036
 
 
1037
        
1076
1038
class CommitToDoubleBoundBranch(BzrError):
1077
1039
 
1078
1040
    _fmt = ("Cannot commit to branch %(branch)s."
1106
1068
        self.error = error
1107
1069
 
1108
1070
 
 
1071
class WeaveError(BzrError):
 
1072
 
 
1073
    _fmt = "Error in processing weave: %(message)s"
 
1074
 
 
1075
    def __init__(self, message=None):
 
1076
        BzrError.__init__(self)
 
1077
        self.message = message
 
1078
 
 
1079
 
 
1080
class WeaveRevisionAlreadyPresent(WeaveError):
 
1081
 
 
1082
    _fmt = "Revision {%(revision_id)s} already present in %(weave)s"
 
1083
 
 
1084
    def __init__(self, revision_id, weave):
 
1085
 
 
1086
        WeaveError.__init__(self)
 
1087
        self.revision_id = revision_id
 
1088
        self.weave = weave
 
1089
 
 
1090
 
 
1091
class WeaveRevisionNotPresent(WeaveError):
 
1092
 
 
1093
    _fmt = "Revision {%(revision_id)s} not present in %(weave)s"
 
1094
 
 
1095
    def __init__(self, revision_id, weave):
 
1096
        WeaveError.__init__(self)
 
1097
        self.revision_id = revision_id
 
1098
        self.weave = weave
 
1099
 
 
1100
 
 
1101
class WeaveFormatError(WeaveError):
 
1102
 
 
1103
    _fmt = "Weave invariant violated: %(what)s"
 
1104
 
 
1105
    def __init__(self, what):
 
1106
        WeaveError.__init__(self)
 
1107
        self.what = what
 
1108
 
 
1109
 
 
1110
class WeaveParentMismatch(WeaveError):
 
1111
 
 
1112
    _fmt = "Parents are mismatched between two revisions."
 
1113
    
 
1114
 
 
1115
class WeaveInvalidChecksum(WeaveError):
 
1116
 
 
1117
    _fmt = "Text did not match it's checksum: %(message)s"
 
1118
 
 
1119
 
 
1120
class WeaveTextDiffers(WeaveError):
 
1121
 
 
1122
    _fmt = ("Weaves differ on text content. Revision:"
 
1123
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
 
1124
 
 
1125
    def __init__(self, revision_id, weave_a, weave_b):
 
1126
        WeaveError.__init__(self)
 
1127
        self.revision_id = revision_id
 
1128
        self.weave_a = weave_a
 
1129
        self.weave_b = weave_b
 
1130
 
 
1131
 
 
1132
class WeaveTextDiffers(WeaveError):
 
1133
 
 
1134
    _fmt = ("Weaves differ on text content. Revision:"
 
1135
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
 
1136
 
 
1137
    def __init__(self, revision_id, weave_a, weave_b):
 
1138
        WeaveError.__init__(self)
 
1139
        self.revision_id = revision_id
 
1140
        self.weave_a = weave_a
 
1141
        self.weave_b = weave_b
 
1142
 
 
1143
 
1109
1144
class VersionedFileError(BzrError):
1110
 
 
 
1145
    
1111
1146
    _fmt = "Versioned file error"
1112
1147
 
1113
1148
 
1114
1149
class RevisionNotPresent(VersionedFileError):
1115
 
 
1116
 
    _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
 
1150
    
 
1151
    _fmt = "Revision {%(revision_id)s} not present in %(file_id)s."
1117
1152
 
1118
1153
    def __init__(self, revision_id, file_id):
1119
1154
        VersionedFileError.__init__(self)
1122
1157
 
1123
1158
 
1124
1159
class RevisionAlreadyPresent(VersionedFileError):
1125
 
 
1126
 
    _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
 
1160
    
 
1161
    _fmt = "Revision {%(revision_id)s} already present in %(file_id)s."
1127
1162
 
1128
1163
    def __init__(self, revision_id, file_id):
1129
1164
        VersionedFileError.__init__(self)
1131
1166
        self.file_id = file_id
1132
1167
 
1133
1168
 
1134
 
class VersionedFileInvalidChecksum(VersionedFileError):
1135
 
 
1136
 
    _fmt = "Text did not match its checksum: %(msg)s"
1137
 
 
1138
 
 
1139
 
class RetryWithNewPacks(BzrError):
1140
 
    """Raised when we realize that the packs on disk have changed.
1141
 
 
1142
 
    This is meant as more of a signaling exception, to trap between where a
1143
 
    local error occurred and the code that can actually handle the error and
1144
 
    code that can retry appropriately.
1145
 
    """
1146
 
 
1147
 
    internal_error = True
1148
 
 
1149
 
    _fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1150
 
            " %(orig_error)s")
1151
 
 
1152
 
    def __init__(self, context, reload_occurred, exc_info):
1153
 
        """create a new RetryWithNewPacks error.
1154
 
 
1155
 
        :param reload_occurred: Set to True if we know that the packs have
1156
 
            already been reloaded, and we are failing because of an in-memory
1157
 
            cache miss. If set to True then we will ignore if a reload says
1158
 
            nothing has changed, because we assume it has already reloaded. If
1159
 
            False, then a reload with nothing changed will force an error.
1160
 
        :param exc_info: The original exception traceback, so if there is a
1161
 
            problem we can raise the original error (value from sys.exc_info())
1162
 
        """
1163
 
        BzrError.__init__(self)
1164
 
        self.context = context
1165
 
        self.reload_occurred = reload_occurred
1166
 
        self.exc_info = exc_info
1167
 
        self.orig_error = exc_info[1]
1168
 
        # TODO: The global error handler should probably treat this by
1169
 
        #       raising/printing the original exception with a bit about
1170
 
        #       RetryWithNewPacks also not being caught
1171
 
 
1172
 
 
1173
 
class RetryAutopack(RetryWithNewPacks):
1174
 
    """Raised when we are autopacking and we find a missing file.
1175
 
 
1176
 
    Meant as a signaling exception, to tell the autopack code it should try
1177
 
    again.
1178
 
    """
1179
 
 
1180
 
    internal_error = True
1181
 
 
1182
 
    _fmt = ("Pack files have changed, reload and try autopack again."
1183
 
            " context: %(context)s %(orig_error)s")
 
1169
class KnitError(BzrError):
 
1170
    
 
1171
    _fmt = "Knit error"
 
1172
 
 
1173
    internal_error = True
 
1174
 
 
1175
 
 
1176
class KnitHeaderError(KnitError):
 
1177
 
 
1178
    _fmt = "Knit header error: %(badline)r unexpected for file %(filename)s"
 
1179
 
 
1180
    def __init__(self, badline, filename):
 
1181
        KnitError.__init__(self)
 
1182
        self.badline = badline
 
1183
        self.filename = filename
 
1184
 
 
1185
 
 
1186
class KnitCorrupt(KnitError):
 
1187
 
 
1188
    _fmt = "Knit %(filename)s corrupt: %(how)s"
 
1189
 
 
1190
    def __init__(self, filename, how):
 
1191
        KnitError.__init__(self)
 
1192
        self.filename = filename
 
1193
        self.how = how
 
1194
 
 
1195
 
 
1196
class KnitIndexUnknownMethod(KnitError):
 
1197
    """Raised when we don't understand the storage method.
 
1198
 
 
1199
    Currently only 'fulltext' and 'line-delta' are supported.
 
1200
    """
 
1201
    
 
1202
    _fmt = ("Knit index %(filename)s does not have a known method"
 
1203
            " in options: %(options)r")
 
1204
 
 
1205
    def __init__(self, filename, options):
 
1206
        KnitError.__init__(self)
 
1207
        self.filename = filename
 
1208
        self.options = options
1184
1209
 
1185
1210
 
1186
1211
class NoSuchExportFormat(BzrError):
1187
 
 
 
1212
    
1188
1213
    _fmt = "Export format %(format)r not supported"
1189
1214
 
1190
1215
    def __init__(self, format):
1193
1218
 
1194
1219
 
1195
1220
class TransportError(BzrError):
1196
 
 
 
1221
    
1197
1222
    _fmt = "Transport error: %(msg)s %(orig_error)s"
1198
1223
 
1199
1224
    def __init__(self, msg=None, orig_error=None):
1208
1233
        BzrError.__init__(self)
1209
1234
 
1210
1235
 
1211
 
class TooManyConcurrentRequests(InternalBzrError):
 
1236
class TooManyConcurrentRequests(BzrError):
1212
1237
 
1213
1238
    _fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1214
1239
            " Be sure to finish_writing and finish_reading on the"
1215
1240
            " currently open request.")
1216
1241
 
 
1242
    internal_error = True
 
1243
 
1217
1244
    def __init__(self, medium):
1218
1245
        self.medium = medium
1219
1246
 
1226
1253
        self.details = details
1227
1254
 
1228
1255
 
1229
 
class UnexpectedProtocolVersionMarker(TransportError):
1230
 
 
1231
 
    _fmt = "Received bad protocol version marker: %(marker)r"
1232
 
 
1233
 
    def __init__(self, marker):
1234
 
        self.marker = marker
1235
 
 
1236
 
 
1237
 
class UnknownSmartMethod(InternalBzrError):
1238
 
 
1239
 
    _fmt = "The server does not recognise the '%(verb)s' request."
1240
 
 
1241
 
    def __init__(self, verb):
1242
 
        self.verb = verb
1243
 
 
1244
 
 
1245
 
class SmartMessageHandlerError(InternalBzrError):
1246
 
 
1247
 
    _fmt = ("The message handler raised an exception:\n"
1248
 
            "%(traceback_text)s")
1249
 
 
1250
 
    def __init__(self, exc_info):
1251
 
        import traceback
1252
 
        # GZ 2010-08-10: Cycle with exc_tb/exc_info affects at least one test
1253
 
        self.exc_type, self.exc_value, self.exc_tb = exc_info
1254
 
        self.exc_info = exc_info
1255
 
        traceback_strings = traceback.format_exception(
1256
 
                self.exc_type, self.exc_value, self.exc_tb)
1257
 
        self.traceback_text = ''.join(traceback_strings)
1258
 
 
1259
 
 
1260
1256
# A set of semi-meaningful errors which can be thrown
1261
1257
class TransportNotPossible(TransportError):
1262
1258
 
1287
1283
            self.port = ':%s' % port
1288
1284
 
1289
1285
 
1290
 
# XXX: This is also used for unexpected end of file, which is different at the
1291
 
# TCP level from "connection reset".
1292
1286
class ConnectionReset(TransportError):
1293
1287
 
1294
1288
    _fmt = "Connection closed: %(msg)s %(orig_error)s"
1295
1289
 
1296
1290
 
1297
 
class ConnectionTimeout(ConnectionError):
1298
 
 
1299
 
    _fmt = "Connection Timeout: %(msg)s%(orig_error)s"
1300
 
 
1301
 
 
1302
1291
class InvalidRange(TransportError):
1303
1292
 
1304
 
    _fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1305
 
 
1306
 
    def __init__(self, path, offset, msg=None):
1307
 
        TransportError.__init__(self, msg)
 
1293
    _fmt = "Invalid range access in %(path)s at %(offset)s."
 
1294
    
 
1295
    def __init__(self, path, offset):
 
1296
        TransportError.__init__(self, ("Invalid range access in %s at %d"
 
1297
                                       % (path, offset)))
1308
1298
        self.path = path
1309
1299
        self.offset = offset
1310
1300
 
1311
1301
 
1312
1302
class InvalidHttpResponse(TransportError):
1313
1303
 
1314
 
    _fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
 
1304
    _fmt = "Invalid http response for %(path)s: %(msg)s"
1315
1305
 
1316
1306
    def __init__(self, path, msg, orig_error=None):
1317
1307
        self.path = path
1318
 
        if orig_error is None:
1319
 
            orig_error = ''
1320
 
        else:
1321
 
            # This is reached for obscure and unusual errors so we want to
1322
 
            # preserve as much info as possible to ease debug.
1323
 
            orig_error = ': %r' % (orig_error,)
1324
1308
        TransportError.__init__(self, msg, orig_error=orig_error)
1325
1309
 
1326
1310
 
1327
1311
class InvalidHttpRange(InvalidHttpResponse):
1328
1312
 
1329
1313
    _fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1330
 
 
 
1314
    
1331
1315
    def __init__(self, path, range, msg):
1332
1316
        self.range = range
1333
1317
        InvalidHttpResponse.__init__(self, path, msg)
1334
1318
 
1335
1319
 
1336
 
class HttpBoundaryMissing(InvalidHttpResponse):
1337
 
    """A multipart response ends with no boundary marker.
1338
 
 
1339
 
    This is a special case caused by buggy proxies, described in
1340
 
    <https://bugs.launchpad.net/bzr/+bug/198646>.
1341
 
    """
1342
 
 
1343
 
    _fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1344
 
 
1345
 
    def __init__(self, path, msg):
1346
 
        InvalidHttpResponse.__init__(self, path, msg)
1347
 
 
1348
 
 
1349
1320
class InvalidHttpContentType(InvalidHttpResponse):
1350
1321
 
1351
1322
    _fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1352
 
 
 
1323
    
1353
1324
    def __init__(self, path, ctype, msg):
1354
1325
        self.ctype = ctype
1355
1326
        InvalidHttpResponse.__init__(self, path, msg)
1359
1330
 
1360
1331
    _fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1361
1332
 
1362
 
    def __init__(self, source, target, is_permanent=False):
 
1333
    def __init__(self, source, target, is_permament=False, qual_proto=None):
1363
1334
        self.source = source
1364
1335
        self.target = target
1365
 
        if is_permanent:
 
1336
        if is_permament:
1366
1337
            self.permanently = ' permanently'
1367
1338
        else:
1368
1339
            self.permanently = ''
 
1340
        self.is_permament = is_permament
 
1341
        self._qualified_proto = qual_proto
1369
1342
        TransportError.__init__(self)
1370
1343
 
 
1344
    def _requalify_url(self, url):
 
1345
        """Restore the qualified proto in front of the url"""
 
1346
        # When this exception is raised, source and target are in
 
1347
        # user readable format. But some transports may use a
 
1348
        # different proto (http+urllib:// will present http:// to
 
1349
        # the user. If a qualified proto is specified, the code
 
1350
        # trapping the exception can get the qualified urls to
 
1351
        # properly handle the redirection themself (creating a
 
1352
        # new transport object from the target url for example).
 
1353
        # But checking that the scheme of the original and
 
1354
        # redirected urls are the same can be tricky. (see the
 
1355
        # FIXME in BzrDir.open_from_transport for the unique use
 
1356
        # case so far).
 
1357
        if self._qualified_proto is None:
 
1358
            return url
 
1359
 
 
1360
        # The TODO related to NotBranchError mention that doing
 
1361
        # that kind of manipulation on the urls may not be the
 
1362
        # exception object job. On the other hand, this object is
 
1363
        # the interface between the code and the user so
 
1364
        # presenting the urls in different ways is indeed its
 
1365
        # job...
 
1366
        import urlparse
 
1367
        proto, netloc, path, query, fragment = urlparse.urlsplit(url)
 
1368
        return urlparse.urlunsplit((self._qualified_proto, netloc, path,
 
1369
                                   query, fragment))
 
1370
 
 
1371
    def get_source_url(self):
 
1372
        return self._requalify_url(self.source)
 
1373
 
 
1374
    def get_target_url(self):
 
1375
        return self._requalify_url(self.target)
 
1376
 
1371
1377
 
1372
1378
class TooManyRedirections(TransportError):
1373
1379
 
1374
1380
    _fmt = "Too many redirections"
1375
1381
 
1376
 
 
1377
1382
class ConflictsInTree(BzrError):
1378
1383
 
1379
1384
    _fmt = "Working tree has conflicts."
1380
1385
 
1381
1386
 
1382
 
class DependencyNotPresent(BzrError):
1383
 
 
1384
 
    _fmt = 'Unable to import library "%(library)s": %(error)s'
1385
 
 
1386
 
    def __init__(self, library, error):
1387
 
        BzrError.__init__(self, library=library, error=error)
 
1387
class ParseConfigError(BzrError):
 
1388
 
 
1389
    def __init__(self, errors, filename):
 
1390
        if filename is None:
 
1391
            filename = ""
 
1392
        message = "Error(s) parsing config file %s:\n%s" % \
 
1393
            (filename, ('\n'.join(e.message for e in errors)))
 
1394
        BzrError.__init__(self, message)
 
1395
 
 
1396
 
 
1397
class NoEmailInUsername(BzrError):
 
1398
 
 
1399
    _fmt = "%(username)r does not seem to contain a reasonable email address"
 
1400
 
 
1401
    def __init__(self, username):
 
1402
        BzrError.__init__(self)
 
1403
        self.username = username
 
1404
 
 
1405
 
 
1406
class SigningFailed(BzrError):
 
1407
 
 
1408
    _fmt = "Failed to gpg sign data with command %(command_line)r"
 
1409
 
 
1410
    def __init__(self, command_line):
 
1411
        BzrError.__init__(self, command_line=command_line)
1388
1412
 
1389
1413
 
1390
1414
class WorkingTreeNotRevision(BzrError):
1391
1415
 
1392
 
    _fmt = ("The working tree for %(basedir)s has changed since"
 
1416
    _fmt = ("The working tree for %(basedir)s has changed since" 
1393
1417
            " the last commit, but weave merge requires that it be"
1394
1418
            " unchanged")
1395
1419
 
1397
1421
        BzrError.__init__(self, basedir=tree.basedir)
1398
1422
 
1399
1423
 
 
1424
class CantReprocessAndShowBase(BzrError):
 
1425
 
 
1426
    _fmt = ("Can't reprocess and show base, because reprocessing obscures "
 
1427
           "the relationship of conflicting lines to the base")
 
1428
 
 
1429
 
1400
1430
class GraphCycleError(BzrError):
1401
1431
 
1402
1432
    _fmt = "Cycle in graph %(graph)r"
1406
1436
        self.graph = graph
1407
1437
 
1408
1438
 
1409
 
class WritingCompleted(InternalBzrError):
 
1439
class WritingCompleted(BzrError):
1410
1440
 
1411
1441
    _fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1412
1442
            "called upon it - accept bytes may not be called anymore.")
1413
1443
 
 
1444
    internal_error = True
 
1445
 
1414
1446
    def __init__(self, request):
1415
1447
        self.request = request
1416
1448
 
1417
1449
 
1418
 
class WritingNotComplete(InternalBzrError):
 
1450
class WritingNotComplete(BzrError):
1419
1451
 
1420
1452
    _fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1421
1453
            "called upon it - until the write phase is complete no "
1422
1454
            "data may be read.")
1423
1455
 
 
1456
    internal_error = True
 
1457
 
1424
1458
    def __init__(self, request):
1425
1459
        self.request = request
1426
1460
 
1434
1468
        self.filename = filename
1435
1469
 
1436
1470
 
1437
 
class MediumNotConnected(InternalBzrError):
 
1471
class MediumNotConnected(BzrError):
1438
1472
 
1439
1473
    _fmt = """The medium '%(medium)s' is not connected."""
1440
1474
 
 
1475
    internal_error = True
 
1476
 
1441
1477
    def __init__(self, medium):
1442
1478
        self.medium = medium
1443
1479
 
1449
1485
 
1450
1486
class NoBundleFound(BzrError):
1451
1487
 
1452
 
    _fmt = 'No bundle was found in "%(filename)s".'
 
1488
    _fmt = "No bundle was found in %(filename)s"
1453
1489
 
1454
1490
    def __init__(self, filename):
1455
1491
        BzrError.__init__(self)
1494
1530
    _fmt = "Key %(key)s is already present in map"
1495
1531
 
1496
1532
 
1497
 
class DuplicateHelpPrefix(BzrError):
1498
 
 
1499
 
    _fmt = "The prefix %(prefix)s is in the help search path twice."
1500
 
 
1501
 
    def __init__(self, prefix):
1502
 
        self.prefix = prefix
1503
 
 
1504
 
 
1505
 
class MalformedTransform(InternalBzrError):
 
1533
class MalformedTransform(BzrError):
1506
1534
 
1507
1535
    _fmt = "Tree transform is malformed %(conflicts)r"
1508
1536
 
1519
1547
        self.root_trans_id = transform.root
1520
1548
 
1521
1549
 
1522
 
class BzrBadParameter(InternalBzrError):
 
1550
class BzrBadParameter(BzrError):
1523
1551
 
1524
1552
    _fmt = "Bad parameter: %(param)r"
1525
1553
 
1546
1574
    _fmt = "Moving the root directory is not supported at this time"
1547
1575
 
1548
1576
 
1549
 
class TransformRenameFailed(BzrError):
1550
 
 
1551
 
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
1552
 
 
1553
 
    def __init__(self, from_path, to_path, why, errno):
1554
 
        self.from_path = from_path
1555
 
        self.to_path = to_path
1556
 
        self.why = why
1557
 
        self.errno = errno
1558
 
 
1559
 
 
1560
1577
class BzrMoveFailedError(BzrError):
1561
1578
 
1562
 
    _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1563
 
        "%(_has_extra)s%(extra)s")
 
1579
    _fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1564
1580
 
1565
1581
    def __init__(self, from_path='', to_path='', extra=None):
1566
 
        from breezy.osutils import splitpath
1567
1582
        BzrError.__init__(self)
1568
1583
        if extra:
1569
 
            self.extra, self._has_extra = extra, ': '
 
1584
            self.extra = ': ' + str(extra)
1570
1585
        else:
1571
 
            self.extra = self._has_extra = ''
 
1586
            self.extra = ''
1572
1587
 
1573
1588
        has_from = len(from_path) > 0
1574
1589
        has_to = len(to_path) > 0
1575
1590
        if has_from:
1576
 
            self.from_path = splitpath(from_path)[-1]
 
1591
            self.from_path = osutils.splitpath(from_path)[-1]
1577
1592
        else:
1578
1593
            self.from_path = ''
1579
1594
 
1580
1595
        if has_to:
1581
 
            self.to_path = splitpath(to_path)[-1]
 
1596
            self.to_path = osutils.splitpath(to_path)[-1]
1582
1597
        else:
1583
1598
            self.to_path = ''
1584
1599
 
1595
1610
 
1596
1611
class BzrRenameFailedError(BzrMoveFailedError):
1597
1612
 
1598
 
    _fmt = ("Could not rename %(from_path)s%(operator)s %(to_path)s"
1599
 
        "%(_has_extra)s%(extra)s")
 
1613
    _fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1600
1614
 
1601
1615
    def __init__(self, from_path, to_path, extra=None):
1602
1616
        BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1609
1623
 
1610
1624
class BzrBadParameterMissing(BzrBadParameter):
1611
1625
 
1612
 
    _fmt = "Parameter %(param)s is required but not present."
 
1626
    _fmt = "Parameter $(param)s is required but not present."
1613
1627
 
1614
1628
 
1615
1629
class BzrBadParameterUnicode(BzrBadParameter):
1623
1637
    _fmt = "Parameter %(param)s contains a newline."
1624
1638
 
1625
1639
 
 
1640
class DependencyNotPresent(BzrError):
 
1641
 
 
1642
    _fmt = 'Unable to import library "%(library)s": %(error)s'
 
1643
 
 
1644
    def __init__(self, library, error):
 
1645
        BzrError.__init__(self, library=library, error=error)
 
1646
 
 
1647
 
1626
1648
class ParamikoNotPresent(DependencyNotPresent):
1627
1649
 
1628
1650
    _fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1638
1660
 
1639
1661
class UninitializableFormat(BzrError):
1640
1662
 
1641
 
    _fmt = "Format %(format)s cannot be initialised by this version of brz."
 
1663
    _fmt = "Format %(format)s cannot be initialised by this version of bzr."
1642
1664
 
1643
1665
    def __init__(self, format):
1644
1666
        BzrError.__init__(self)
1647
1669
 
1648
1670
class BadConversionTarget(BzrError):
1649
1671
 
1650
 
    _fmt = "Cannot convert from format %(from_format)s to format %(format)s." \
1651
 
            "    %(problem)s"
 
1672
    _fmt = "Cannot convert to format %(format)s.  %(problem)s"
1652
1673
 
1653
 
    def __init__(self, problem, format, from_format=None):
 
1674
    def __init__(self, problem, format):
1654
1675
        BzrError.__init__(self)
1655
1676
        self.problem = problem
1656
1677
        self.format = format
1657
 
        self.from_format = from_format or '(unspecified)'
1658
 
 
1659
 
 
1660
 
class NoDiffFound(BzrError):
1661
 
 
1662
 
    _fmt = 'Could not find an appropriate Differ for file "%(path)s"'
1663
 
 
1664
 
    def __init__(self, path):
1665
 
        BzrError.__init__(self, path)
1666
 
 
1667
 
 
1668
 
class ExecutableMissing(BzrError):
1669
 
 
1670
 
    _fmt = "%(exe_name)s could not be found on this machine"
1671
 
 
1672
 
    def __init__(self, exe_name):
1673
 
        BzrError.__init__(self, exe_name=exe_name)
1674
1678
 
1675
1679
 
1676
1680
class NoDiff(BzrError):
1686
1690
    _fmt = "Diff3 is not installed on this machine."
1687
1691
 
1688
1692
 
1689
 
class ExistingContent(BzrError):
1690
 
    # Added in breezy 0.92, used by VersionedFile.add_lines.
1691
 
 
1692
 
    _fmt = "The content being inserted is already present."
1693
 
 
1694
 
 
1695
1693
class ExistingLimbo(BzrError):
1696
1694
 
1697
1695
    _fmt = """This tree contains left-over files from a failed operation.
1698
1696
    Please examine %(limbo_dir)s to see if it contains any files you wish to
1699
1697
    keep, and delete it when you are done."""
1700
 
 
 
1698
    
1701
1699
    def __init__(self, limbo_dir):
1702
1700
       BzrError.__init__(self)
1703
1701
       self.limbo_dir = limbo_dir
1704
1702
 
1705
1703
 
1706
 
class ExistingPendingDeletion(BzrError):
1707
 
 
1708
 
    _fmt = """This tree contains left-over files from a failed operation.
1709
 
    Please examine %(pending_deletion)s to see if it contains any files you
1710
 
    wish to keep, and delete it when you are done."""
1711
 
 
1712
 
    def __init__(self, pending_deletion):
1713
 
       BzrError.__init__(self, pending_deletion=pending_deletion)
1714
 
 
1715
 
 
1716
1704
class ImmortalLimbo(BzrError):
1717
1705
 
1718
 
    _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
 
1706
    _fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
1719
1707
    Please examine %(limbo_dir)s to see if it contains any files you wish to
1720
1708
    keep, and delete it when you are done."""
1721
1709
 
1724
1712
       self.limbo_dir = limbo_dir
1725
1713
 
1726
1714
 
1727
 
class ImmortalPendingDeletion(BzrError):
1728
 
 
1729
 
    _fmt = ("Unable to delete transform temporary directory "
1730
 
    "%(pending_deletion)s.  Please examine %(pending_deletion)s to see if it "
1731
 
    "contains any files you wish to keep, and delete it when you are done.")
1732
 
 
1733
 
    def __init__(self, pending_deletion):
1734
 
       BzrError.__init__(self, pending_deletion=pending_deletion)
1735
 
 
1736
 
 
1737
1715
class OutOfDateTree(BzrError):
1738
1716
 
1739
 
    _fmt = "Working tree is out of date, please run 'brz update'.%(more)s"
 
1717
    _fmt = "Working tree is out of date, please run 'bzr update'."
1740
1718
 
1741
 
    def __init__(self, tree, more=None):
1742
 
        if more is None:
1743
 
            more = ''
1744
 
        else:
1745
 
            more = ' ' + more
 
1719
    def __init__(self, tree):
1746
1720
        BzrError.__init__(self)
1747
1721
        self.tree = tree
1748
 
        self.more = more
1749
1722
 
1750
1723
 
1751
1724
class PublicBranchOutOfDate(BzrError):
1754
1727
        '"%(revstring)s".'
1755
1728
 
1756
1729
    def __init__(self, public_location, revstring):
1757
 
        import breezy.urlutils as urlutils
 
1730
        import bzrlib.urlutils as urlutils
1758
1731
        public_location = urlutils.unescape_for_display(public_location,
1759
1732
                                                        'ascii')
1760
1733
        BzrError.__init__(self, public_location=public_location,
1774
1747
class CorruptRepository(BzrError):
1775
1748
 
1776
1749
    _fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1777
 
            "Please run brz reconcile on this repository.")
 
1750
            "Please run bzr reconcile on this repository.")
1778
1751
 
1779
1752
    def __init__(self, repo):
1780
1753
        BzrError.__init__(self)
1781
 
        self.repo_path = repo.user_url
1782
 
 
1783
 
 
1784
 
class InconsistentDelta(BzrError):
1785
 
    """Used when we get a delta that is not valid."""
1786
 
 
1787
 
    _fmt = ("An inconsistent delta was supplied involving %(path)r,"
1788
 
            " %(file_id)r\nreason: %(reason)s")
1789
 
 
1790
 
    def __init__(self, path, file_id, reason):
1791
 
        BzrError.__init__(self)
1792
 
        self.path = path
1793
 
        self.file_id = file_id
1794
 
        self.reason = reason
1795
 
 
1796
 
 
1797
 
class InconsistentDeltaDelta(InconsistentDelta):
1798
 
    """Used when we get a delta that is not valid."""
1799
 
 
1800
 
    _fmt = ("An inconsistent delta was supplied: %(delta)r"
1801
 
            "\nreason: %(reason)s")
1802
 
 
1803
 
    def __init__(self, delta, reason):
1804
 
        BzrError.__init__(self)
1805
 
        self.delta = delta
1806
 
        self.reason = reason
 
1754
        self.repo_path = repo.bzrdir.root_transport.base
1807
1755
 
1808
1756
 
1809
1757
class UpgradeRequired(BzrError):
1815
1763
        self.path = path
1816
1764
 
1817
1765
 
1818
 
class RepositoryUpgradeRequired(UpgradeRequired):
1819
 
 
1820
 
    _fmt = "To use this feature you must upgrade your repository at %(path)s."
1821
 
 
1822
 
 
1823
 
class RichRootUpgradeRequired(UpgradeRequired):
1824
 
 
1825
 
    _fmt = ("To use this feature you must upgrade your branch at %(path)s to"
1826
 
           " a format which supports rich roots.")
1827
 
 
1828
 
 
1829
1766
class LocalRequiresBoundBranch(BzrError):
1830
1767
 
1831
1768
    _fmt = "Cannot perform local-only commits on unbound branches."
1832
1769
 
1833
1770
 
 
1771
class MissingProgressBarFinish(BzrError):
 
1772
 
 
1773
    _fmt = "A nested progress bar was not 'finished' correctly."
 
1774
 
 
1775
 
 
1776
class InvalidProgressBarType(BzrError):
 
1777
 
 
1778
    _fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
 
1779
            " is not a supported type Select one of: %(valid_types)s")
 
1780
 
 
1781
    def __init__(self, bar_type, valid_types):
 
1782
        BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
 
1783
 
 
1784
 
1834
1785
class UnsupportedOperation(BzrError):
1835
1786
 
1836
1787
    _fmt = ("The method %(mname)s is not supported on"
1842
1793
        self.tname = type(method_self).__name__
1843
1794
 
1844
1795
 
1845
 
class FetchLimitUnsupported(UnsupportedOperation):
1846
 
 
1847
 
    fmt = ("InterBranch %(interbranch)r does not support fetching limits.")
1848
 
 
1849
 
    def __init__(self, interbranch):
1850
 
        BzrError.__init__(self, interbranch=interbranch)
 
1796
class CannotSetRevisionId(UnsupportedOperation):
 
1797
    """Raised when a commit is attempting to set a revision id but cant."""
1851
1798
 
1852
1799
 
1853
1800
class NonAsciiRevisionId(UnsupportedOperation):
1856
1803
    """
1857
1804
 
1858
1805
 
1859
 
class GhostTagsNotSupported(BzrError):
1860
 
 
1861
 
    _fmt = "Ghost tags not supported by format %(format)r."
1862
 
 
1863
 
    def __init__(self, format):
1864
 
        self.format = format
1865
 
 
1866
 
 
1867
1806
class BinaryFile(BzrError):
1868
 
 
 
1807
    
1869
1808
    _fmt = "File is binary but should be text."
1870
1809
 
1871
1810
 
1891
1830
 
1892
1831
 
1893
1832
class NotABundle(BzrError):
1894
 
 
 
1833
    
1895
1834
    _fmt = "Not a bzr revision-bundle: %(text)r"
1896
1835
 
1897
1836
    def __init__(self, text):
1899
1838
        self.text = text
1900
1839
 
1901
1840
 
1902
 
class BadBundle(BzrError):
1903
 
 
 
1841
class BadBundle(BzrError): 
 
1842
    
1904
1843
    _fmt = "Bad bzr revision-bundle: %(text)r"
1905
1844
 
1906
1845
    def __init__(self, text):
1908
1847
        self.text = text
1909
1848
 
1910
1849
 
1911
 
class MalformedHeader(BadBundle):
1912
 
 
 
1850
class MalformedHeader(BadBundle): 
 
1851
    
1913
1852
    _fmt = "Malformed bzr revision-bundle header: %(text)r"
1914
1853
 
1915
1854
 
1916
 
class MalformedPatches(BadBundle):
1917
 
 
 
1855
class MalformedPatches(BadBundle): 
 
1856
    
1918
1857
    _fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1919
1858
 
1920
1859
 
1921
 
class MalformedFooter(BadBundle):
1922
 
 
 
1860
class MalformedFooter(BadBundle): 
 
1861
    
1923
1862
    _fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1924
1863
 
1925
1864
 
1926
1865
class UnsupportedEOLMarker(BadBundle):
1927
 
 
1928
 
    _fmt = "End of line marker was not \\n in bzr revision-bundle"
 
1866
    
 
1867
    _fmt = "End of line marker was not \\n in bzr revision-bundle"    
1929
1868
 
1930
1869
    def __init__(self):
1931
 
        # XXX: BadBundle's constructor assumes there's explanatory text,
 
1870
        # XXX: BadBundle's constructor assumes there's explanatory text, 
1932
1871
        # but for this there is not
1933
1872
        BzrError.__init__(self)
1934
1873
 
1935
1874
 
1936
1875
class IncompatibleBundleFormat(BzrError):
1937
 
 
 
1876
    
1938
1877
    _fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1939
1878
 
1940
1879
    def __init__(self, bundle_format, other):
1944
1883
 
1945
1884
 
1946
1885
class BadInventoryFormat(BzrError):
1947
 
 
 
1886
    
1948
1887
    _fmt = "Root class for inventory serialization errors"
1949
1888
 
1950
1889
 
1961
1900
    _fmt = """This operation requires rich root data storage"""
1962
1901
 
1963
1902
 
1964
 
class NoSmartMedium(InternalBzrError):
 
1903
class NoSmartMedium(BzrError):
1965
1904
 
1966
1905
    _fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1967
1906
 
 
1907
    internal_error = True
 
1908
 
1968
1909
    def __init__(self, transport):
1969
1910
        self.transport = transport
1970
1911
 
1971
1912
 
 
1913
class NoSmartServer(NotBranchError):
 
1914
 
 
1915
    _fmt = "No smart server available at %(url)s"
 
1916
 
 
1917
    def __init__(self, url):
 
1918
        self.url = url
 
1919
 
 
1920
 
1972
1921
class UnknownSSH(BzrError):
1973
1922
 
1974
 
    _fmt = "Unrecognised value for BRZ_SSH environment variable: %(vendor)s"
 
1923
    _fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
1975
1924
 
1976
1925
    def __init__(self, vendor):
1977
1926
        BzrError.__init__(self)
1981
1930
class SSHVendorNotFound(BzrError):
1982
1931
 
1983
1932
    _fmt = ("Don't know how to handle SSH connections."
1984
 
            " Please set BRZ_SSH environment variable.")
1985
 
 
1986
 
 
1987
 
class GhostRevisionsHaveNoRevno(BzrError):
1988
 
    """When searching for revnos, if we encounter a ghost, we are stuck"""
1989
 
 
1990
 
    _fmt = ("Could not determine revno for {%(revision_id)s} because"
1991
 
            " its ancestry shows a ghost at {%(ghost_revision_id)s}")
1992
 
 
1993
 
    def __init__(self, revision_id, ghost_revision_id):
1994
 
        self.revision_id = revision_id
1995
 
        self.ghost_revision_id = ghost_revision_id
 
1933
            " Please set BZR_SSH environment variable.")
1996
1934
 
1997
1935
 
1998
1936
class GhostRevisionUnusableHere(BzrError):
2004
1942
        self.revision_id = revision_id
2005
1943
 
2006
1944
 
2007
 
class IllegalUseOfScopeReplacer(InternalBzrError):
 
1945
class IllegalUseOfScopeReplacer(BzrError):
2008
1946
 
2009
1947
    _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2010
1948
            " %(msg)s%(extra)s")
2011
1949
 
 
1950
    internal_error = True
 
1951
 
2012
1952
    def __init__(self, name, msg, extra=None):
2013
1953
        BzrError.__init__(self)
2014
1954
        self.name = name
2019
1959
            self.extra = ''
2020
1960
 
2021
1961
 
2022
 
class InvalidImportLine(InternalBzrError):
 
1962
class InvalidImportLine(BzrError):
2023
1963
 
2024
1964
    _fmt = "Not a valid import statement: %(msg)\n%(text)s"
2025
1965
 
 
1966
    internal_error = True
 
1967
 
2026
1968
    def __init__(self, text, msg):
2027
1969
        BzrError.__init__(self)
2028
1970
        self.text = text
2029
1971
        self.msg = msg
2030
1972
 
2031
1973
 
2032
 
class ImportNameCollision(InternalBzrError):
 
1974
class ImportNameCollision(BzrError):
2033
1975
 
2034
1976
    _fmt = ("Tried to import an object to the same name as"
2035
1977
            " an existing object. %(name)s")
2036
1978
 
 
1979
    internal_error = True
 
1980
 
2037
1981
    def __init__(self, name):
2038
1982
        BzrError.__init__(self)
2039
1983
        self.name = name
2052
1996
        " branch location."
2053
1997
 
2054
1998
 
2055
 
class IllegalMergeDirectivePayload(BzrError):
2056
 
    """A merge directive contained something other than a patch or bundle"""
2057
 
 
2058
 
    _fmt = "Bad merge directive payload %(start)r"
2059
 
 
2060
 
    def __init__(self, start):
2061
 
        BzrError(self)
2062
 
        self.start = start
2063
 
 
2064
 
 
2065
 
class PatchVerificationFailed(BzrError):
2066
 
    """A patch from a merge directive could not be verified"""
2067
 
 
2068
 
    _fmt = "Preview patch does not match requested changes."
2069
 
 
2070
 
 
2071
1999
class PatchMissing(BzrError):
2072
2000
    """Raise a patch type was specified but no patch supplied"""
2073
2001
 
2074
 
    _fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
 
2002
    _fmt = "patch_type was %(patch_type)s, but no patch was supplied."
2075
2003
 
2076
2004
    def __init__(self, patch_type):
2077
2005
        BzrError.__init__(self)
2078
2006
        self.patch_type = patch_type
2079
2007
 
2080
2008
 
2081
 
class TargetNotBranch(BzrError):
2082
 
    """A merge directive's target branch is required, but isn't a branch"""
2083
 
 
2084
 
    _fmt = ("Your branch does not have all of the revisions required in "
2085
 
            "order to merge this merge directive and the target "
2086
 
            "location specified in the merge directive is not a branch: "
2087
 
            "%(location)s.")
2088
 
 
2089
 
    def __init__(self, location):
2090
 
        BzrError.__init__(self)
2091
 
        self.location = location
2092
 
 
2093
 
 
2094
2009
class UnsupportedInventoryKind(BzrError):
2095
 
 
 
2010
    
2096
2011
    _fmt = """Unsupported entry kind %(kind)s"""
2097
2012
 
2098
2013
    def __init__(self, kind):
2101
2016
 
2102
2017
class BadSubsumeSource(BzrError):
2103
2018
 
2104
 
    _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
 
2019
    _fmt = """Can't subsume %(other_tree)s into %(tree)s.  %(reason)s"""
2105
2020
 
2106
2021
    def __init__(self, tree, other_tree, reason):
2107
2022
        self.tree = tree
2110
2025
 
2111
2026
 
2112
2027
class SubsumeTargetNeedsUpgrade(BzrError):
2113
 
 
 
2028
    
2114
2029
    _fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2115
2030
 
2116
2031
    def __init__(self, other_tree):
2117
2032
        self.other_tree = other_tree
2118
2033
 
2119
2034
 
 
2035
class BadReferenceTarget(BzrError):
 
2036
 
 
2037
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s.  %(reason)s"
 
2038
 
 
2039
    internal_error = True
 
2040
 
 
2041
    def __init__(self, tree, other_tree, reason):
 
2042
        self.tree = tree
 
2043
        self.other_tree = other_tree
 
2044
        self.reason = reason
 
2045
 
 
2046
 
2120
2047
class NoSuchTag(BzrError):
2121
2048
 
2122
2049
    _fmt = "No such tag: %(tag_name)s"
2128
2055
class TagsNotSupported(BzrError):
2129
2056
 
2130
2057
    _fmt = ("Tags not supported by %(branch)s;"
2131
 
            " you may be able to use brz upgrade.")
 
2058
            " you may be able to use bzr upgrade.")
2132
2059
 
2133
2060
    def __init__(self, branch):
2134
2061
        self.branch = branch
2135
2062
 
2136
 
 
 
2063
        
2137
2064
class TagAlreadyExists(BzrError):
2138
2065
 
2139
2066
    _fmt = "Tag %(tag_name)s already exists."
2140
2067
 
2141
2068
    def __init__(self, tag_name):
2142
2069
        self.tag_name = tag_name
2143
 
 
2144
 
 
2145
 
class UnexpectedSmartServerResponse(BzrError):
2146
 
 
2147
 
    _fmt = "Could not understand response from smart server: %(response_tuple)r"
2148
 
 
2149
 
    def __init__(self, response_tuple):
2150
 
        self.response_tuple = response_tuple
2151
 
 
2152
 
 
2153
 
class ErrorFromSmartServer(BzrError):
2154
 
    """An error was received from a smart server.
2155
 
 
2156
 
    :seealso: UnknownErrorFromSmartServer
2157
 
    """
2158
 
 
2159
 
    _fmt = "Error received from smart server: %(error_tuple)r"
2160
 
 
2161
 
    internal_error = True
2162
 
 
2163
 
    def __init__(self, error_tuple):
2164
 
        self.error_tuple = error_tuple
2165
 
        try:
2166
 
            self.error_verb = error_tuple[0]
2167
 
        except IndexError:
2168
 
            self.error_verb = None
2169
 
        self.error_args = error_tuple[1:]
2170
 
 
2171
 
 
2172
 
class UnknownErrorFromSmartServer(BzrError):
2173
 
    """An ErrorFromSmartServer could not be translated into a typical breezy
2174
 
    error.
2175
 
 
2176
 
    This is distinct from ErrorFromSmartServer so that it is possible to
2177
 
    distinguish between the following two cases:
2178
 
 
2179
 
    - ErrorFromSmartServer was uncaught.  This is logic error in the client
2180
 
      and so should provoke a traceback to the user.
2181
 
    - ErrorFromSmartServer was caught but its error_tuple could not be
2182
 
      translated.  This is probably because the server sent us garbage, and
2183
 
      should not provoke a traceback.
2184
 
    """
2185
 
 
2186
 
    _fmt = "Server sent an unexpected error: %(error_tuple)r"
2187
 
 
2188
 
    internal_error = False
2189
 
 
2190
 
    def __init__(self, error_from_smart_server):
2191
 
        """Constructor.
2192
 
 
2193
 
        :param error_from_smart_server: An ErrorFromSmartServer instance.
2194
 
        """
2195
 
        self.error_from_smart_server = error_from_smart_server
2196
 
        self.error_tuple = error_from_smart_server.error_tuple
2197
 
 
2198
 
 
2199
 
class ContainerError(BzrError):
2200
 
    """Base class of container errors."""
2201
 
 
2202
 
 
2203
 
class UnknownContainerFormatError(ContainerError):
2204
 
 
2205
 
    _fmt = "Unrecognised container format: %(container_format)r"
2206
 
 
2207
 
    def __init__(self, container_format):
2208
 
        self.container_format = container_format
2209
 
 
2210
 
 
2211
 
class UnexpectedEndOfContainerError(ContainerError):
2212
 
 
2213
 
    _fmt = "Unexpected end of container stream"
2214
 
 
2215
 
 
2216
 
class UnknownRecordTypeError(ContainerError):
2217
 
 
2218
 
    _fmt = "Unknown record type: %(record_type)r"
2219
 
 
2220
 
    def __init__(self, record_type):
2221
 
        self.record_type = record_type
2222
 
 
2223
 
 
2224
 
class InvalidRecordError(ContainerError):
2225
 
 
2226
 
    _fmt = "Invalid record: %(reason)s"
2227
 
 
2228
 
    def __init__(self, reason):
2229
 
        self.reason = reason
2230
 
 
2231
 
 
2232
 
class ContainerHasExcessDataError(ContainerError):
2233
 
 
2234
 
    _fmt = "Container has data after end marker: %(excess)r"
2235
 
 
2236
 
    def __init__(self, excess):
2237
 
        self.excess = excess
2238
 
 
2239
 
 
2240
 
class DuplicateRecordNameError(ContainerError):
2241
 
 
2242
 
    _fmt = "Container has multiple records with the same name: %(name)s"
2243
 
 
2244
 
    def __init__(self, name):
2245
 
        self.name = name.decode("utf-8")
2246
 
 
2247
 
 
2248
 
class RepositoryDataStreamError(BzrError):
2249
 
 
2250
 
    _fmt = "Corrupt or incompatible data stream: %(reason)s"
2251
 
 
2252
 
    def __init__(self, reason):
2253
 
        self.reason = reason
2254
 
 
2255
 
 
2256
 
class UncommittedChanges(BzrError):
2257
 
 
2258
 
    _fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2259
 
            ' (See brz status).%(more)s')
2260
 
 
2261
 
    def __init__(self, tree, more=None):
2262
 
        if more is None:
2263
 
            more = ''
2264
 
        else:
2265
 
            more = ' ' + more
2266
 
        import breezy.urlutils as urlutils
2267
 
        user_url = getattr(tree, "user_url", None)
2268
 
        if user_url is None:
2269
 
            display_url = str(tree)
2270
 
        else:
2271
 
            display_url = urlutils.unescape_for_display(user_url, 'ascii')
2272
 
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2273
 
 
2274
 
 
2275
 
class StoringUncommittedNotSupported(BzrError):
2276
 
 
2277
 
    _fmt = ('Branch "%(display_url)s" does not support storing uncommitted'
2278
 
            ' changes.')
2279
 
 
2280
 
    def __init__(self, branch):
2281
 
        import breezy.urlutils as urlutils
2282
 
        user_url = getattr(branch, "user_url", None)
2283
 
        if user_url is None:
2284
 
            display_url = str(branch)
2285
 
        else:
2286
 
            display_url = urlutils.unescape_for_display(user_url, 'ascii')
2287
 
        BzrError.__init__(self, branch=branch, display_url=display_url)
2288
 
 
2289
 
 
2290
 
class ShelvedChanges(UncommittedChanges):
2291
 
 
2292
 
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
2293
 
            ' (See brz shelve --list).%(more)s')
2294
 
 
2295
 
 
2296
 
class UnableCreateSymlink(BzrError):
2297
 
 
2298
 
    _fmt = 'Unable to create symlink %(path_str)son this platform'
2299
 
 
2300
 
    def __init__(self, path=None):
2301
 
        path_str = ''
2302
 
        if path:
2303
 
            try:
2304
 
                path_str = repr(str(path))
2305
 
            except UnicodeEncodeError:
2306
 
                path_str = repr(path)
2307
 
            path_str += ' '
2308
 
        self.path_str = path_str
2309
 
 
2310
 
 
2311
 
class UnableEncodePath(BzrError):
2312
 
 
2313
 
    _fmt = ('Unable to encode %(kind)s path %(path)r in '
2314
 
            'user encoding %(user_encoding)s')
2315
 
 
2316
 
    def __init__(self, path, kind):
2317
 
        from breezy.osutils import get_user_encoding
2318
 
        self.path = path
2319
 
        self.kind = kind
2320
 
        self.user_encoding = get_user_encoding()
2321
 
 
2322
 
 
2323
 
class NoSuchAlias(BzrError):
2324
 
 
2325
 
    _fmt = ('The alias "%(alias_name)s" does not exist.')
2326
 
 
2327
 
    def __init__(self, alias_name):
2328
 
        BzrError.__init__(self, alias_name=alias_name)
2329
 
 
2330
 
 
2331
 
class CannotBindAddress(BzrError):
2332
 
 
2333
 
    _fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2334
 
 
2335
 
    def __init__(self, host, port, orig_error):
2336
 
        # nb: in python2.4 socket.error doesn't have a useful repr
2337
 
        BzrError.__init__(self, host=host, port=port,
2338
 
            orig_error=repr(orig_error.args))
2339
 
 
2340
 
 
2341
 
class TipChangeRejected(BzrError):
2342
 
    """A pre_change_branch_tip hook function may raise this to cleanly and
2343
 
    explicitly abort a change to a branch tip.
2344
 
    """
2345
 
 
2346
 
    _fmt = u"Tip change rejected: %(msg)s"
2347
 
 
2348
 
    def __init__(self, msg):
2349
 
        self.msg = msg
2350
 
 
2351
 
 
2352
 
class JailBreak(BzrError):
2353
 
 
2354
 
    _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2355
 
 
2356
 
    def __init__(self, url):
2357
 
        BzrError.__init__(self, url=url)
2358
 
 
2359
 
 
2360
 
class UserAbort(BzrError):
2361
 
 
2362
 
    _fmt = 'The user aborted the operation.'
2363
 
 
2364
 
 
2365
 
class UnresumableWriteGroup(BzrError):
2366
 
 
2367
 
    _fmt = ("Repository %(repository)s cannot resume write group "
2368
 
            "%(write_groups)r: %(reason)s")
2369
 
 
2370
 
    internal_error = True
2371
 
 
2372
 
    def __init__(self, repository, write_groups, reason):
2373
 
        self.repository = repository
2374
 
        self.write_groups = write_groups
2375
 
        self.reason = reason
2376
 
 
2377
 
 
2378
 
class UnsuspendableWriteGroup(BzrError):
2379
 
 
2380
 
    _fmt = ("Repository %(repository)s cannot suspend a write group.")
2381
 
 
2382
 
    internal_error = True
2383
 
 
2384
 
    def __init__(self, repository):
2385
 
        self.repository = repository
2386
 
 
2387
 
 
2388
 
class LossyPushToSameVCS(BzrError):
2389
 
 
2390
 
    _fmt = ("Lossy push not possible between %(source_branch)r and "
2391
 
            "%(target_branch)r that are in the same VCS.")
2392
 
 
2393
 
    internal_error = True
2394
 
 
2395
 
    def __init__(self, source_branch, target_branch):
2396
 
        self.source_branch = source_branch
2397
 
        self.target_branch = target_branch
2398
 
 
2399
 
 
2400
 
class NoRoundtrippingSupport(BzrError):
2401
 
 
2402
 
    _fmt = ("Roundtripping is not supported between %(source_branch)r and "
2403
 
            "%(target_branch)r.")
2404
 
 
2405
 
    internal_error = True
2406
 
 
2407
 
    def __init__(self, source_branch, target_branch):
2408
 
        self.source_branch = source_branch
2409
 
        self.target_branch = target_branch
2410
 
 
2411
 
 
2412
 
class NoColocatedBranchSupport(BzrError):
2413
 
 
2414
 
    _fmt = ("%(controldir)r does not support co-located branches.")
2415
 
 
2416
 
    def __init__(self, controldir):
2417
 
        self.controldir = controldir
2418
 
 
2419
 
 
2420
 
class RecursiveBind(BzrError):
2421
 
 
2422
 
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2423
 
        'Please use `brz unbind` to fix.')
2424
 
 
2425
 
    def __init__(self, branch_url):
2426
 
        self.branch_url = branch_url
2427
 
 
2428
 
 
2429
 
class UnsupportedKindChange(BzrError):
2430
 
 
2431
 
    _fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2432
 
            "%(path)s not supported by format %(format)r")
2433
 
 
2434
 
    def __init__(self, path, from_kind, to_kind, format):
2435
 
        self.path = path
2436
 
        self.from_kind = from_kind
2437
 
        self.to_kind = to_kind
2438
 
        self.format = format
2439
 
 
2440
 
 
2441
 
class ChangesAlreadyStored(BzrCommandError):
2442
 
 
2443
 
    _fmt = ('Cannot store uncommitted changes because this branch already'
2444
 
            ' stores uncommitted changes.')