86
87
for key, value in kwds.items():
87
88
setattr(self, key, value)
90
91
s = getattr(self, '_preformatted_string', None)
92
# contains a preformatted message
93
# contains a preformatted message; must be cast to plain str
96
96
fmt = self._get_format_string()
98
d = dict(self.__dict__)
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')
103
except Exception as 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__,
108
getattr(self, '_fmt', None),
111
def _get_format_string(self):
112
"""Return format string for this exception or None"""
113
fmt = getattr(self, '_fmt', None)
116
fmt = getattr(self, '__doc__', None)
118
symbol_versioning.warn("%s uses its docstring as a format, "
119
"it should use _fmt instead" % self.__class__.__name__,
122
return 'Unprintable exception %s: dict=%r, fmt=%r' \
106
123
% (self.__class__.__name__,
108
125
getattr(self, '_fmt', None),
115
return self._format().encode('utf-8')
117
__unicode__ = _format
120
return '%s(%s)' % (self.__class__.__name__, str(self))
122
def _get_format_string(self):
123
"""Return format string for this exception or None"""
124
fmt = getattr(self, '_fmt', None)
126
from breezy.i18n import gettext
127
return gettext(fmt) # _fmt strings should be ascii
129
def __eq__(self, other):
130
if self.__class__ is not other.__class__:
131
return NotImplemented
132
return self.__dict__ == other.__dict__
138
class InternalBzrError(BzrError):
139
"""Base class for errors that are internal in nature.
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.
146
internal_error = True
149
class BranchError(BzrError):
150
"""Base class for concrete 'errors about a branch'."""
152
def __init__(self, branch):
153
BzrError.__init__(self, branch=branch)
156
class BzrCheckError(InternalBzrError):
158
_fmt = "Internal check failed: %(msg)s"
160
def __init__(self, msg):
161
BzrError.__init__(self)
165
class IncompatibleVersion(BzrError):
167
_fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\
168
'is required, but current version is %(current)r.'
170
def __init__(self, api, wanted, current):
173
self.current = current
176
class InProcessTransport(BzrError):
178
_fmt = "The transport '%(transport)s' is only accessible within this " \
181
def __init__(self, transport):
182
self.transport = transport
185
class InvalidEntryName(InternalBzrError):
129
class BzrNewError(BzrError):
130
"""Deprecated error base class."""
131
# base classes should override the docstring with their human-
132
# readable explanation
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).
139
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
140
'please convert %s to use BzrError instead'
141
% self.__class__.__name__,
144
BzrError.__init__(self, *args)
145
for key, value in kwds.items():
146
setattr(self, key, value)
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')
156
except (TypeError, NameError, ValueError, KeyError), e:
157
return 'Unprintable exception %s(%r): %s' \
158
% (self.__class__.__name__,
159
self.__dict__, str(e))
162
class AlreadyBuilding(BzrError):
164
_fmt = "The tree builder is already building a tree."
167
class BzrCheckError(BzrError):
169
_fmt = "Internal check failed: %(message)s"
171
internal_error = True
173
def __init__(self, message):
174
BzrError.__init__(self)
175
self.message = message
178
class DisabledMethod(BzrError):
180
_fmt = "The smart server method '%(class_name)s' is disabled."
182
internal_error = True
184
def __init__(self, class_name):
185
BzrError.__init__(self)
186
self.class_name = class_name
189
class InvalidEntryName(BzrError):
187
191
_fmt = "Invalid entry name: %(name)s"
193
internal_error = True
189
195
def __init__(self, name):
190
196
BzrError.__init__(self)
194
200
class InvalidRevisionNumber(BzrError):
196
202
_fmt = "Invalid revision number %(revno)s"
198
204
def __init__(self, revno):
218
223
def __init__(self, revision_id):
219
224
self.revision_id = revision_id
222
class RootMissing(InternalBzrError):
224
_fmt = ("The root entry of a tree must be the first entry supplied to "
225
"the commit builder.")
228
class NoPublicBranch(BzrError):
230
_fmt = 'There is no public branch set for "%(branch_url)s".'
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)
238
226
class NoSuchId(BzrError):
240
_fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
228
_fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
242
230
def __init__(self, tree, file_id):
243
231
BzrError.__init__(self)
244
232
self.file_id = file_id
248
class NotStacked(BranchError):
250
_fmt = "The branch '%(branch)s' is not stacked."
253
class InventoryModified(InternalBzrError):
236
class InventoryModified(BzrError):
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.")
241
internal_error = True
258
243
def __init__(self, tree):
262
247
class NoWorkingTree(BzrError):
264
_fmt = 'No WorkingTree exists for "%(base)s".'
249
_fmt = "No WorkingTree exists for %(base)s."
266
251
def __init__(self, base):
267
252
BzrError.__init__(self)
256
class NotBuilding(BzrError):
258
_fmt = "Not currently building a tree."
271
261
class NotLocalUrl(BzrError):
273
263
_fmt = "%(url)s is not a local path."
358
369
class NotADirectory(PathError):
360
_fmt = '"%(path)s" is not a directory %(extra)s'
371
_fmt = "%(path)r is not a directory %(extra)s"
363
374
class NotInWorkingDirectory(PathError):
365
_fmt = '"%(path)s" is not in the working directory %(extra)s'
376
_fmt = "%(path)r is not in the working directory %(extra)s"
368
379
class DirectoryNotEmpty(PathError):
370
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
373
class HardLinkNotSupported(PathError):
375
_fmt = 'Hard-linking "%(path)s" is not supported'
378
class ReadingCompleted(InternalBzrError):
381
_fmt = "Directory not empty: %(path)r%(extra)s"
384
class ReadingCompleted(BzrError):
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.")
390
internal_error = True
384
392
def __init__(self, request):
385
393
self.request = request
388
396
class ResourceBusy(PathError):
390
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
398
_fmt = "Device or resource busy: %(path)r%(extra)s"
393
401
class PermissionDenied(PathError):
395
_fmt = 'Permission denied: "%(path)s"%(extra)s'
398
class UnavailableRepresentation(InternalBzrError):
400
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
401
"is encoded as '%(native)s'.")
403
def __init__(self, key, wanted, native):
404
InternalBzrError.__init__(self)
403
_fmt = "Permission denied: %(path)r%(extra)s"
406
class InvalidURL(PathError):
408
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
411
class InvalidURLJoin(PathError):
413
_fmt = "Invalid URL join request: %(args)s%(extra)s"
415
def __init__(self, msg, base, args):
416
PathError.__init__(self, base, msg)
417
self.args = [base] + list(args)
420
class UnknownHook(BzrError):
422
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
424
def __init__(self, hook_type, hook_name):
425
BzrError.__init__(self)
426
self.type = hook_type
427
self.hook = hook_name
410
430
class UnsupportedProtocol(PathError):
412
432
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
414
def __init__(self, url, extra=""):
434
def __init__(self, url, extra):
415
435
PathError.__init__(self, url, extra=extra)
418
class UnstackableLocationError(BzrError):
420
_fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
422
def __init__(self, branch_url, target_url):
423
BzrError.__init__(self)
424
self.branch_url = branch_url
425
self.target_url = target_url
428
class UnstackableRepositoryFormat(BzrError):
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.")
433
def __init__(self, format, url):
434
BzrError.__init__(self)
439
class ReadError(PathError):
441
_fmt = """Error reading from %(path)r."""
444
438
class ShortReadvError(PathError):
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")
449
443
internal_error = True
474
468
class InvalidNormalization(PathError):
476
_fmt = 'Path "%(path)s" is not unicode normalized'
470
_fmt = "Path %(path)r is not unicode normalized"
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):
484
_fmt = 'Not a branch: "%(path)s"%(detail)s.'
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
492
self.controldir = controldir
493
PathError.__init__(self, path=path)
496
return '<%s %r>' % (self.__class__.__name__, self.__dict__)
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()
504
def _get_detail(self):
505
if self.controldir is not None:
507
self.controldir.open_repository()
508
except NoRepositoryPresent:
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__
520
return ': location is a repository'
478
_fmt = "Not a branch: %(path)s"
480
def __init__(self, path):
481
import bzrlib.urlutils as urlutils
482
self.path = urlutils.unescape_for_display(path, 'ascii')
524
485
class NoSubmitBranch(PathError):
583
525
class NoRepositoryPresent(BzrError):
585
_fmt = 'No repository present: "%(path)s"'
586
def __init__(self, controldir):
587
BzrError.__init__(self)
588
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
533
class FileInWrongBranch(BzrError):
535
_fmt = "File %(path)s in not in branch %(branch_base)s."
537
def __init__(self, branch, path):
538
BzrError.__init__(self)
540
self.branch_base = branch.base
591
544
class UnsupportedFormatError(BzrError):
593
_fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
546
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
596
549
class UnknownFormatError(BzrError):
598
_fmt = "Unknown %(kind)s format: %(format)r"
600
def __init__(self, format, kind='branch'):
551
_fmt = "Unknown branch format: %(format)r"
605
554
class IncompatibleFormat(BzrError):
607
_fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
609
def __init__(self, format, controldir_format):
610
BzrError.__init__(self)
612
self.controldir = controldir_format
615
class ParseFormatError(BzrError):
617
_fmt = "Parse error on line %(lineno)d of %(format)s format: %(line)s"
619
def __init__(self, format, lineno, line, text):
620
BzrError.__init__(self)
556
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
558
def __init__(self, format, bzrdir_format):
559
BzrError.__init__(self)
561
self.bzrdir = bzrdir_format
627
564
class IncompatibleRepositories(BzrError):
628
"""Report an error that two repositories are not compatible.
630
Note that the source and target repositories are permitted to be strings:
631
this exception is thrown from the smart server and may refer to a
632
repository the client hasn't opened.
635
_fmt = "%(target)s\n" \
636
"is not compatible with\n" \
640
def __init__(self, source, target, details=None):
642
details = "(no details)"
643
BzrError.__init__(self, target=target, source=source, details=details)
566
_fmt = "Repository %(target)s is not compatible with repository"\
569
def __init__(self, source, target):
570
BzrError.__init__(self, target=target, source=source)
646
573
class IncompatibleRevision(BzrError):
648
575
_fmt = "Revision is not compatible with %(repo_format)s"
650
577
def __init__(self, repo_format):
1116
1068
self.error = error
1071
class WeaveError(BzrError):
1073
_fmt = "Error in processing weave: %(message)s"
1075
def __init__(self, message=None):
1076
BzrError.__init__(self)
1077
self.message = message
1080
class WeaveRevisionAlreadyPresent(WeaveError):
1082
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1084
def __init__(self, revision_id, weave):
1086
WeaveError.__init__(self)
1087
self.revision_id = revision_id
1091
class WeaveRevisionNotPresent(WeaveError):
1093
_fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1095
def __init__(self, revision_id, weave):
1096
WeaveError.__init__(self)
1097
self.revision_id = revision_id
1101
class WeaveFormatError(WeaveError):
1103
_fmt = "Weave invariant violated: %(what)s"
1105
def __init__(self, what):
1106
WeaveError.__init__(self)
1110
class WeaveParentMismatch(WeaveError):
1112
_fmt = "Parents are mismatched between two revisions."
1115
class WeaveInvalidChecksum(WeaveError):
1117
_fmt = "Text did not match it's checksum: %(message)s"
1120
class WeaveTextDiffers(WeaveError):
1122
_fmt = ("Weaves differ on text content. Revision:"
1123
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
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
1132
class WeaveTextDiffers(WeaveError):
1134
_fmt = ("Weaves differ on text content. Revision:"
1135
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
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
1119
1144
class VersionedFileError(BzrError):
1121
1146
_fmt = "Versioned file error"
1124
1149
class RevisionNotPresent(VersionedFileError):
1126
_fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1151
_fmt = "Revision {%(revision_id)s} not present in %(file_id)s."
1128
1153
def __init__(self, revision_id, file_id):
1129
1154
VersionedFileError.__init__(self)
1141
1166
self.file_id = file_id
1144
class VersionedFileInvalidChecksum(VersionedFileError):
1146
_fmt = "Text did not match its checksum: %(msg)s"
1149
class RetryWithNewPacks(BzrError):
1150
"""Raised when we realize that the packs on disk have changed.
1152
This is meant as more of a signaling exception, to trap between where a
1153
local error occurred and the code that can actually handle the error and
1154
code that can retry appropriately.
1157
internal_error = True
1159
_fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1162
def __init__(self, context, reload_occurred, exc_info):
1163
"""create a new RetryWithNewPacks error.
1165
:param reload_occurred: Set to True if we know that the packs have
1166
already been reloaded, and we are failing because of an in-memory
1167
cache miss. If set to True then we will ignore if a reload says
1168
nothing has changed, because we assume it has already reloaded. If
1169
False, then a reload with nothing changed will force an error.
1170
:param exc_info: The original exception traceback, so if there is a
1171
problem we can raise the original error (value from sys.exc_info())
1173
BzrError.__init__(self)
1174
self.context = context
1175
self.reload_occurred = reload_occurred
1176
self.exc_info = exc_info
1177
self.orig_error = exc_info[1]
1178
# TODO: The global error handler should probably treat this by
1179
# raising/printing the original exception with a bit about
1180
# RetryWithNewPacks also not being caught
1183
class RetryAutopack(RetryWithNewPacks):
1184
"""Raised when we are autopacking and we find a missing file.
1186
Meant as a signaling exception, to tell the autopack code it should try
1190
internal_error = True
1192
_fmt = ("Pack files have changed, reload and try autopack again."
1193
" context: %(context)s %(orig_error)s")
1169
class KnitError(BzrError):
1173
internal_error = True
1176
class KnitHeaderError(KnitError):
1178
_fmt = "Knit header error: %(badline)r unexpected for file %(filename)s"
1180
def __init__(self, badline, filename):
1181
KnitError.__init__(self)
1182
self.badline = badline
1183
self.filename = filename
1186
class KnitCorrupt(KnitError):
1188
_fmt = "Knit %(filename)s corrupt: %(how)s"
1190
def __init__(self, filename, how):
1191
KnitError.__init__(self)
1192
self.filename = filename
1196
class KnitIndexUnknownMethod(KnitError):
1197
"""Raised when we don't understand the storage method.
1199
Currently only 'fulltext' and 'line-delta' are supported.
1202
_fmt = ("Knit index %(filename)s does not have a known method"
1203
" in options: %(options)r")
1205
def __init__(self, filename, options):
1206
KnitError.__init__(self)
1207
self.filename = filename
1208
self.options = options
1196
1211
class NoSuchExportFormat(BzrError):
1198
1213
_fmt = "Export format %(format)r not supported"
1200
1215
def __init__(self, format):
1297
1283
self.port = ':%s' % port
1300
# XXX: This is also used for unexpected end of file, which is different at the
1301
# TCP level from "connection reset".
1302
1286
class ConnectionReset(TransportError):
1304
1288
_fmt = "Connection closed: %(msg)s %(orig_error)s"
1307
class ConnectionTimeout(ConnectionError):
1309
_fmt = "Connection Timeout: %(msg)s%(orig_error)s"
1312
1291
class InvalidRange(TransportError):
1314
_fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1316
def __init__(self, path, offset, msg=None):
1317
TransportError.__init__(self, msg)
1293
_fmt = "Invalid range access in %(path)s at %(offset)s."
1295
def __init__(self, path, offset):
1296
TransportError.__init__(self, ("Invalid range access in %s at %d"
1318
1298
self.path = path
1319
1299
self.offset = offset
1322
1302
class InvalidHttpResponse(TransportError):
1324
_fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1304
_fmt = "Invalid http response for %(path)s: %(msg)s"
1326
1306
def __init__(self, path, msg, orig_error=None):
1327
1307
self.path = path
1328
if orig_error is None:
1331
# This is reached for obscure and unusual errors so we want to
1332
# preserve as much info as possible to ease debug.
1333
orig_error = ': %r' % (orig_error,)
1334
1308
TransportError.__init__(self, msg, orig_error=orig_error)
1337
1311
class InvalidHttpRange(InvalidHttpResponse):
1339
1313
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1341
1315
def __init__(self, path, range, msg):
1342
1316
self.range = range
1343
1317
InvalidHttpResponse.__init__(self, path, msg)
1346
class HttpBoundaryMissing(InvalidHttpResponse):
1347
"""A multipart response ends with no boundary marker.
1349
This is a special case caused by buggy proxies, described in
1350
<https://bugs.launchpad.net/bzr/+bug/198646>.
1353
_fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1355
def __init__(self, path, msg):
1356
InvalidHttpResponse.__init__(self, path, msg)
1359
1320
class InvalidHttpContentType(InvalidHttpResponse):
1361
1322
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1363
1324
def __init__(self, path, ctype, msg):
1364
1325
self.ctype = ctype
1365
1326
InvalidHttpResponse.__init__(self, path, msg)
1370
1331
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1372
def __init__(self, source, target, is_permanent=False):
1333
def __init__(self, source, target, is_permament=False, qual_proto=None):
1373
1334
self.source = source
1374
1335
self.target = target
1376
1337
self.permanently = ' permanently'
1378
1339
self.permanently = ''
1340
self.is_permament = is_permament
1341
self._qualified_proto = qual_proto
1379
1342
TransportError.__init__(self)
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
1357
if self._qualified_proto is None:
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
1367
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1368
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1371
def get_source_url(self):
1372
return self._requalify_url(self.source)
1374
def get_target_url(self):
1375
return self._requalify_url(self.target)
1382
1378
class TooManyRedirections(TransportError):
1384
1380
_fmt = "Too many redirections"
1387
1382
class ConflictsInTree(BzrError):
1389
1384
_fmt = "Working tree has conflicts."
1392
class DependencyNotPresent(BzrError):
1394
_fmt = 'Unable to import library "%(library)s": %(error)s'
1396
def __init__(self, library, error):
1397
BzrError.__init__(self, library=library, error=error)
1387
class ParseConfigError(BzrError):
1389
def __init__(self, errors, filename):
1390
if filename is None:
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)
1397
class NoEmailInUsername(BzrError):
1399
_fmt = "%(username)r does not seem to contain a reasonable email address"
1401
def __init__(self, username):
1402
BzrError.__init__(self)
1403
self.username = username
1406
class SigningFailed(BzrError):
1408
_fmt = "Failed to gpg sign data with command %(command_line)r"
1410
def __init__(self, command_line):
1411
BzrError.__init__(self, command_line=command_line)
1400
1414
class WorkingTreeNotRevision(BzrError):
1402
_fmt = ("The working tree for %(basedir)s has changed since"
1416
_fmt = ("The working tree for %(basedir)s has changed since"
1403
1417
" the last commit, but weave merge requires that it be"
2144
2055
class TagsNotSupported(BzrError):
2146
2057
_fmt = ("Tags not supported by %(branch)s;"
2147
" you may be able to use brz upgrade.")
2058
" you may be able to use bzr upgrade.")
2149
2060
def __init__(self, branch):
2150
2061
self.branch = branch
2153
2064
class TagAlreadyExists(BzrError):
2155
2066
_fmt = "Tag %(tag_name)s already exists."
2157
2068
def __init__(self, tag_name):
2158
2069
self.tag_name = tag_name
2161
class UnexpectedSmartServerResponse(BzrError):
2163
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2165
def __init__(self, response_tuple):
2166
self.response_tuple = response_tuple
2169
class ErrorFromSmartServer(BzrError):
2170
"""An error was received from a smart server.
2172
:seealso: UnknownErrorFromSmartServer
2175
_fmt = "Error received from smart server: %(error_tuple)r"
2177
internal_error = True
2179
def __init__(self, error_tuple):
2180
self.error_tuple = error_tuple
2182
self.error_verb = error_tuple[0]
2184
self.error_verb = None
2185
self.error_args = error_tuple[1:]
2188
class UnknownErrorFromSmartServer(BzrError):
2189
"""An ErrorFromSmartServer could not be translated into a typical breezy
2192
This is distinct from ErrorFromSmartServer so that it is possible to
2193
distinguish between the following two cases:
2195
- ErrorFromSmartServer was uncaught. This is logic error in the client
2196
and so should provoke a traceback to the user.
2197
- ErrorFromSmartServer was caught but its error_tuple could not be
2198
translated. This is probably because the server sent us garbage, and
2199
should not provoke a traceback.
2202
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2204
internal_error = False
2206
def __init__(self, error_from_smart_server):
2209
:param error_from_smart_server: An ErrorFromSmartServer instance.
2211
self.error_from_smart_server = error_from_smart_server
2212
self.error_tuple = error_from_smart_server.error_tuple
2215
class ContainerError(BzrError):
2216
"""Base class of container errors."""
2219
class UnknownContainerFormatError(ContainerError):
2221
_fmt = "Unrecognised container format: %(container_format)r"
2223
def __init__(self, container_format):
2224
self.container_format = container_format
2227
class UnexpectedEndOfContainerError(ContainerError):
2229
_fmt = "Unexpected end of container stream"
2232
class UnknownRecordTypeError(ContainerError):
2234
_fmt = "Unknown record type: %(record_type)r"
2236
def __init__(self, record_type):
2237
self.record_type = record_type
2240
class InvalidRecordError(ContainerError):
2242
_fmt = "Invalid record: %(reason)s"
2244
def __init__(self, reason):
2245
self.reason = reason
2248
class ContainerHasExcessDataError(ContainerError):
2250
_fmt = "Container has data after end marker: %(excess)r"
2252
def __init__(self, excess):
2253
self.excess = excess
2256
class DuplicateRecordNameError(ContainerError):
2258
_fmt = "Container has multiple records with the same name: %(name)s"
2260
def __init__(self, name):
2261
self.name = name.decode("utf-8")
2264
class RepositoryDataStreamError(BzrError):
2266
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2268
def __init__(self, reason):
2269
self.reason = reason
2272
class UncommittedChanges(BzrError):
2274
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2275
' (See brz status).%(more)s')
2277
def __init__(self, tree, more=None):
2282
import breezy.urlutils as urlutils
2283
user_url = getattr(tree, "user_url", None)
2284
if user_url is None:
2285
display_url = str(tree)
2287
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2288
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2291
class StoringUncommittedNotSupported(BzrError):
2293
_fmt = ('Branch "%(display_url)s" does not support storing uncommitted'
2296
def __init__(self, branch):
2297
import breezy.urlutils as urlutils
2298
user_url = getattr(branch, "user_url", None)
2299
if user_url is None:
2300
display_url = str(branch)
2302
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2303
BzrError.__init__(self, branch=branch, display_url=display_url)
2306
class ShelvedChanges(UncommittedChanges):
2308
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2309
' (See brz shelve --list).%(more)s')
2312
class UnableCreateSymlink(BzrError):
2314
_fmt = 'Unable to create symlink %(path_str)son this platform'
2316
def __init__(self, path=None):
2320
path_str = repr(str(path))
2321
except UnicodeEncodeError:
2322
path_str = repr(path)
2324
self.path_str = path_str
2327
class UnableEncodePath(BzrError):
2329
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2330
'user encoding %(user_encoding)s')
2332
def __init__(self, path, kind):
2333
from breezy.osutils import get_user_encoding
2336
self.user_encoding = get_user_encoding()
2339
class NoSuchAlias(BzrError):
2341
_fmt = ('The alias "%(alias_name)s" does not exist.')
2343
def __init__(self, alias_name):
2344
BzrError.__init__(self, alias_name=alias_name)
2347
class CannotBindAddress(BzrError):
2349
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2351
def __init__(self, host, port, orig_error):
2352
# nb: in python2.4 socket.error doesn't have a useful repr
2353
BzrError.__init__(self, host=host, port=port,
2354
orig_error=repr(orig_error.args))
2357
class TipChangeRejected(BzrError):
2358
"""A pre_change_branch_tip hook function may raise this to cleanly and
2359
explicitly abort a change to a branch tip.
2362
_fmt = u"Tip change rejected: %(msg)s"
2364
def __init__(self, msg):
2368
class JailBreak(BzrError):
2370
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2372
def __init__(self, url):
2373
BzrError.__init__(self, url=url)
2376
class UserAbort(BzrError):
2378
_fmt = 'The user aborted the operation.'
2381
class UnresumableWriteGroup(BzrError):
2383
_fmt = ("Repository %(repository)s cannot resume write group "
2384
"%(write_groups)r: %(reason)s")
2386
internal_error = True
2388
def __init__(self, repository, write_groups, reason):
2389
self.repository = repository
2390
self.write_groups = write_groups
2391
self.reason = reason
2394
class UnsuspendableWriteGroup(BzrError):
2396
_fmt = ("Repository %(repository)s cannot suspend a write group.")
2398
internal_error = True
2400
def __init__(self, repository):
2401
self.repository = repository
2404
class LossyPushToSameVCS(BzrError):
2406
_fmt = ("Lossy push not possible between %(source_branch)r and "
2407
"%(target_branch)r that are in the same VCS.")
2409
internal_error = True
2411
def __init__(self, source_branch, target_branch):
2412
self.source_branch = source_branch
2413
self.target_branch = target_branch
2416
class NoRoundtrippingSupport(BzrError):
2418
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
2419
"%(target_branch)r.")
2421
internal_error = True
2423
def __init__(self, source_branch, target_branch):
2424
self.source_branch = source_branch
2425
self.target_branch = target_branch
2428
class NoColocatedBranchSupport(BzrError):
2430
_fmt = ("%(controldir)r does not support co-located branches.")
2432
def __init__(self, controldir):
2433
self.controldir = controldir
2436
class RecursiveBind(BzrError):
2438
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2439
'Please use `brz unbind` to fix.')
2441
def __init__(self, branch_url):
2442
self.branch_url = branch_url
2445
class UnsupportedKindChange(BzrError):
2447
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2448
"%(path)s not supported by format %(format)r")
2450
def __init__(self, path, from_kind, to_kind, format):
2452
self.from_kind = from_kind
2453
self.to_kind = to_kind
2454
self.format = format
2457
class ChangesAlreadyStored(BzrCommandError):
2459
_fmt = ('Cannot store uncommitted changes because this branch already'
2460
' stores uncommitted changes.')