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.
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"
146
171
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):
173
def __init__(self, message):
161
174
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):
175
self.message = message
178
class InvalidEntryName(BzrError):
187
180
_fmt = "Invalid entry name: %(name)s"
182
internal_error = True
189
184
def __init__(self, name):
190
185
BzrError.__init__(self)
194
189
class InvalidRevisionNumber(BzrError):
196
191
_fmt = "Invalid revision number %(revno)s"
198
193
def __init__(self, revno):
218
212
def __init__(self, revision_id):
219
213
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
215
class NoSuchId(BzrError):
240
_fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
217
_fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
242
219
def __init__(self, tree, file_id):
243
220
BzrError.__init__(self)
244
221
self.file_id = file_id
248
class NotStacked(BranchError):
250
_fmt = "The branch '%(branch)s' is not stacked."
253
class InventoryModified(InternalBzrError):
225
class InventoryModified(BzrError):
255
227
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
256
228
" so a clean inventory cannot be read without data loss.")
230
internal_error = True
258
232
def __init__(self, tree):
262
236
class NoWorkingTree(BzrError):
264
_fmt = 'No WorkingTree exists for "%(base)s".'
238
_fmt = "No WorkingTree exists for %(base)s."
266
240
def __init__(self, base):
267
241
BzrError.__init__(self)
245
class NotBuilding(BzrError):
247
_fmt = "Not currently building a tree."
271
250
class NotLocalUrl(BzrError):
273
252
_fmt = "%(url)s is not a local path."
365
358
class NotADirectory(PathError):
367
_fmt = '"%(path)s" is not a directory %(extra)s'
360
_fmt = "%(path)r is not a directory %(extra)s"
370
363
class NotInWorkingDirectory(PathError):
372
_fmt = '"%(path)s" is not in the working directory %(extra)s'
365
_fmt = "%(path)r is not in the working directory %(extra)s"
375
368
class DirectoryNotEmpty(PathError):
377
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
380
class HardLinkNotSupported(PathError):
382
_fmt = 'Hard-linking "%(path)s" is not supported'
385
class ReadingCompleted(InternalBzrError):
370
_fmt = "Directory not empty: %(path)r%(extra)s"
373
class ReadingCompleted(BzrError):
387
375
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
388
376
"called upon it - the request has been completed and no more "
389
377
"data may be read.")
379
internal_error = True
391
381
def __init__(self, request):
392
382
self.request = request
395
385
class ResourceBusy(PathError):
397
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
387
_fmt = "Device or resource busy: %(path)r%(extra)s"
400
390
class PermissionDenied(PathError):
402
_fmt = 'Permission denied: "%(path)s"%(extra)s'
405
class UnavailableRepresentation(InternalBzrError):
407
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
408
"is encoded as '%(native)s'.")
410
def __init__(self, key, wanted, native):
411
InternalBzrError.__init__(self)
392
_fmt = "Permission denied: %(path)r%(extra)s"
395
class InvalidURL(PathError):
397
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
400
class InvalidURLJoin(PathError):
402
_fmt = "Invalid URL join request: %(args)s%(extra)s"
404
def __init__(self, msg, base, args):
405
PathError.__init__(self, base, msg)
406
self.args = [base] + list(args)
409
class UnknownHook(BzrError):
411
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
413
def __init__(self, hook_type, hook_name):
414
BzrError.__init__(self)
415
self.type = hook_type
416
self.hook = hook_name
417
419
class UnsupportedProtocol(PathError):
419
421
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
421
def __init__(self, url, extra=""):
423
def __init__(self, url, extra):
422
424
PathError.__init__(self, url, extra=extra)
425
class UnstackableLocationError(BzrError):
427
_fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
429
def __init__(self, branch_url, target_url):
430
BzrError.__init__(self)
431
self.branch_url = branch_url
432
self.target_url = target_url
435
class UnstackableRepositoryFormat(BzrError):
437
_fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
438
"You will need to upgrade the repository to permit branch stacking.")
440
def __init__(self, format, url):
441
BzrError.__init__(self)
446
class ReadError(PathError):
448
_fmt = """Error reading from %(path)r."""
451
427
class ShortReadvError(PathError):
453
_fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
454
' at %(offset)s for "%(path)s"%(extra)s')
429
_fmt = ("readv() read %(actual)s bytes rather than %(length)s bytes"
430
" at %(offset)s for %(path)s%(extra)s")
456
432
internal_error = True
481
457
class InvalidNormalization(PathError):
483
_fmt = 'Path "%(path)s" is not unicode normalized'
459
_fmt = "Path %(path)r is not unicode normalized"
486
462
# TODO: This is given a URL; we try to unescape it but doing that from inside
487
463
# the exception object is a bit undesirable.
488
# TODO: Probably this behavior of should be a common superclass
464
# TODO: Probably this behavior of should be a common superclass
489
465
class NotBranchError(PathError):
491
_fmt = 'Not a branch: "%(path)s"%(detail)s.'
493
def __init__(self, path, detail=None, controldir=None):
494
from . import urlutils
495
path = urlutils.unescape_for_display(path, 'ascii')
496
if detail is not None:
497
detail = ': ' + detail
499
self.controldir = controldir
500
PathError.__init__(self, path=path)
503
return '<%s %r>' % (self.__class__.__name__, self.__dict__)
505
def _get_format_string(self):
506
# GZ 2017-06-08: Not the best place to lazy fill detail in.
507
if self.detail is None:
508
self.detail = self._get_detail()
509
return super(NotBranchError, self)._get_format_string()
511
def _get_detail(self):
512
if self.controldir is not None:
514
self.controldir.open_repository()
515
except NoRepositoryPresent:
517
except Exception as e:
518
# Just ignore unexpected errors. Raising arbitrary errors
519
# during str(err) can provoke strange bugs. Concretely
520
# Launchpad's codehosting managed to raise NotBranchError
521
# here, and then get stuck in an infinite loop/recursion
522
# trying to str() that error. All this error really cares
523
# about that there's no working repository there, and if
524
# open_repository() fails, there probably isn't.
525
return ': ' + e.__class__.__name__
527
return ': location is a repository'
467
_fmt = "Not a branch: %(path)s"
469
def __init__(self, path):
470
import bzrlib.urlutils as urlutils
471
self.path = urlutils.unescape_for_display(path, 'ascii')
531
474
class NoSubmitBranch(PathError):
533
476
_fmt = 'No submit branch available for branch "%(path)s"'
535
478
def __init__(self, branch):
536
from . import urlutils
537
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
540
class AlreadyControlDirError(PathError):
542
_fmt = 'A control directory already exists: "%(path)s".'
479
import bzrlib.urlutils as urlutils
480
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
545
483
class AlreadyBranchError(PathError):
547
_fmt = 'Already a branch: "%(path)s".'
550
class InvalidBranchName(PathError):
552
_fmt = "Invalid branch name: %(name)s"
554
def __init__(self, name):
555
BzrError.__init__(self)
559
class ParentBranchExists(AlreadyBranchError):
561
_fmt = 'Parent branch already exists: "%(path)s".'
485
_fmt = "Already a branch: %(path)s."
564
488
class BranchExistsWithoutWorkingTree(PathError):
566
_fmt = 'Directory contains a branch, but no working tree \
567
(use brz checkout if you wish to build a working tree): "%(path)s"'
490
_fmt = "Directory contains a branch, but no working tree \
491
(use bzr checkout if you wish to build a working tree): %(path)s"
494
class AtomicFileAlreadyClosed(PathError):
496
_fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
499
def __init__(self, path, function):
500
PathError.__init__(self, path=path, extra=None)
501
self.function = function
570
504
class InaccessibleParent(PathError):
572
_fmt = ('Parent not accessible given base "%(base)s" and'
573
' relative path "%(path)s"')
506
_fmt = ("Parent not accessible given base %(base)s and"
507
" relative path %(path)s")
575
509
def __init__(self, path, base):
576
510
PathError.__init__(self, path)
580
514
class NoRepositoryPresent(BzrError):
582
_fmt = 'No repository present: "%(path)s"'
584
def __init__(self, controldir):
585
BzrError.__init__(self)
586
self.path = controldir.transport.clone('..').base
516
_fmt = "No repository present: %(path)r"
517
def __init__(self, bzrdir):
518
BzrError.__init__(self)
519
self.path = bzrdir.transport.clone('..').base
522
class FileInWrongBranch(BzrError):
524
_fmt = "File %(path)s in not in branch %(branch_base)s."
526
def __init__(self, branch, path):
527
BzrError.__init__(self)
529
self.branch_base = branch.base
589
533
class UnsupportedFormatError(BzrError):
591
_fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
535
_fmt = "Unsupported branch format: %(format)s"
594
538
class UnknownFormatError(BzrError):
596
_fmt = "Unknown %(kind)s format: %(format)r"
598
def __init__(self, format, kind='branch'):
603
class LineEndingError(BzrError):
605
_fmt = ("Line ending corrupted for file: %(file)s; "
606
"Maybe your files got corrupted in transport?")
608
def __init__(self, file):
540
_fmt = "Unknown branch format: %(format)r"
612
543
class IncompatibleFormat(BzrError):
614
_fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
616
def __init__(self, format, controldir_format):
617
BzrError.__init__(self)
619
self.controldir = controldir_format
622
class ParseFormatError(BzrError):
624
_fmt = "Parse error on line %(lineno)d of %(format)s format: %(line)s"
626
def __init__(self, format, lineno, line, text):
627
BzrError.__init__(self)
634
class IncompatibleRepositories(BzrError):
635
"""Report an error that two repositories are not compatible.
637
Note that the source and target repositories are permitted to be strings:
638
this exception is thrown from the smart server and may refer to a
639
repository the client hasn't opened.
642
_fmt = "%(target)s\n" \
643
"is not compatible with\n" \
647
def __init__(self, source, target, details=None):
649
details = "(no details)"
650
BzrError.__init__(self, target=target, source=source, details=details)
545
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
547
def __init__(self, format, bzrdir_format):
548
BzrError.__init__(self)
550
self.bzrdir = bzrdir_format
653
553
class IncompatibleRevision(BzrError):
655
555
_fmt = "Revision is not compatible with %(repo_format)s"
657
557
def __init__(self, repo_format):
979
854
class InvalidRevisionSpec(BzrError):
981
_fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
982
" %(branch_url)s%(extra)s")
856
_fmt = ("Requested revision: %(spec)r does not exist in branch:"
857
" %(branch)s%(extra)s")
984
859
def __init__(self, spec, branch, extra=None):
985
860
BzrError.__init__(self, branch=branch, spec=spec)
986
self.branch_url = getattr(branch, 'user_url', str(branch))
988
862
self.extra = '\n' + str(extra)
867
class HistoryMissing(BzrError):
869
_fmt = "%(branch)s is missing %(object_type)s {%(object_id)s}"
993
872
class AppendRevisionsOnlyViolation(BzrError):
995
874
_fmt = ('Operation denied because it would change the main history,'
996
' which is not permitted by the append_revisions_only setting on'
997
' branch "%(location)s".')
875
' which is not permitted by the append_revisions_only setting on'
876
' branch "%(location)s".')
999
878
def __init__(self, location):
1000
import breezy.urlutils as urlutils
1001
location = urlutils.unescape_for_display(location, 'ascii')
1002
BzrError.__init__(self, location=location)
879
import bzrlib.urlutils as urlutils
880
location = urlutils.unescape_for_display(location, 'ascii')
881
BzrError.__init__(self, location=location)
1005
884
class DivergedBranches(BzrError):
1007
886
_fmt = ("These branches have diverged."
1008
" Use the missing command to see how.\n"
1009
"Use the merge command to reconcile them.")
887
" Use the merge command to reconcile them.")
889
internal_error = False
1011
891
def __init__(self, branch1, branch2):
1012
892
self.branch1 = branch1
1013
893
self.branch2 = branch2
1016
class NotLefthandHistory(InternalBzrError):
896
class NotLefthandHistory(BzrError):
1018
898
_fmt = "Supplied history does not follow left-hand parents"
900
internal_error = True
1020
902
def __init__(self, history):
1021
903
BzrError.__init__(self, history=history)
1122
1023
self.error = error
1026
class WeaveError(BzrError):
1028
_fmt = "Error in processing weave: %(message)s"
1030
def __init__(self, message=None):
1031
BzrError.__init__(self)
1032
self.message = message
1035
class WeaveRevisionAlreadyPresent(WeaveError):
1037
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1039
def __init__(self, revision_id, weave):
1041
WeaveError.__init__(self)
1042
self.revision_id = revision_id
1046
class WeaveRevisionNotPresent(WeaveError):
1048
_fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1050
def __init__(self, revision_id, weave):
1051
WeaveError.__init__(self)
1052
self.revision_id = revision_id
1056
class WeaveFormatError(WeaveError):
1058
_fmt = "Weave invariant violated: %(what)s"
1060
def __init__(self, what):
1061
WeaveError.__init__(self)
1065
class WeaveParentMismatch(WeaveError):
1067
_fmt = "Parents are mismatched between two revisions."
1070
class WeaveInvalidChecksum(WeaveError):
1072
_fmt = "Text did not match it's checksum: %(message)s"
1075
class WeaveTextDiffers(WeaveError):
1077
_fmt = ("Weaves differ on text content. Revision:"
1078
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1080
def __init__(self, revision_id, weave_a, weave_b):
1081
WeaveError.__init__(self)
1082
self.revision_id = revision_id
1083
self.weave_a = weave_a
1084
self.weave_b = weave_b
1087
class WeaveTextDiffers(WeaveError):
1089
_fmt = ("Weaves differ on text content. Revision:"
1090
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1092
def __init__(self, revision_id, weave_a, weave_b):
1093
WeaveError.__init__(self)
1094
self.revision_id = revision_id
1095
self.weave_a = weave_a
1096
self.weave_b = weave_b
1125
1099
class VersionedFileError(BzrError):
1127
1101
_fmt = "Versioned file error"
1130
1104
class RevisionNotPresent(VersionedFileError):
1132
_fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1106
_fmt = "Revision {%(revision_id)s} not present in %(file_id)s."
1134
1108
def __init__(self, revision_id, file_id):
1135
1109
VersionedFileError.__init__(self)
1147
1121
self.file_id = file_id
1150
class VersionedFileInvalidChecksum(VersionedFileError):
1152
_fmt = "Text did not match its checksum: %(msg)s"
1155
class RetryWithNewPacks(BzrError):
1156
"""Raised when we realize that the packs on disk have changed.
1158
This is meant as more of a signaling exception, to trap between where a
1159
local error occurred and the code that can actually handle the error and
1160
code that can retry appropriately.
1163
internal_error = True
1165
_fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1168
def __init__(self, context, reload_occurred, exc_info):
1169
"""create a new RetryWithNewPacks error.
1171
:param reload_occurred: Set to True if we know that the packs have
1172
already been reloaded, and we are failing because of an in-memory
1173
cache miss. If set to True then we will ignore if a reload says
1174
nothing has changed, because we assume it has already reloaded. If
1175
False, then a reload with nothing changed will force an error.
1176
:param exc_info: The original exception traceback, so if there is a
1177
problem we can raise the original error (value from sys.exc_info())
1179
BzrError.__init__(self)
1180
self.context = context
1181
self.reload_occurred = reload_occurred
1182
self.exc_info = exc_info
1183
self.orig_error = exc_info[1]
1184
# TODO: The global error handler should probably treat this by
1185
# raising/printing the original exception with a bit about
1186
# RetryWithNewPacks also not being caught
1189
class RetryAutopack(RetryWithNewPacks):
1190
"""Raised when we are autopacking and we find a missing file.
1192
Meant as a signaling exception, to tell the autopack code it should try
1196
internal_error = True
1198
_fmt = ("Pack files have changed, reload and try autopack again."
1199
" context: %(context)s %(orig_error)s")
1124
class KnitError(BzrError):
1128
internal_error = True
1131
class KnitHeaderError(KnitError):
1133
_fmt = "Knit header error: %(badline)r unexpected for file %(filename)s"
1135
def __init__(self, badline, filename):
1136
KnitError.__init__(self)
1137
self.badline = badline
1138
self.filename = filename
1141
class KnitCorrupt(KnitError):
1143
_fmt = "Knit %(filename)s corrupt: %(how)s"
1145
def __init__(self, filename, how):
1146
KnitError.__init__(self)
1147
self.filename = filename
1151
class KnitIndexUnknownMethod(KnitError):
1152
"""Raised when we don't understand the storage method.
1154
Currently only 'fulltext' and 'line-delta' are supported.
1157
_fmt = ("Knit index %(filename)s does not have a known method"
1158
" in options: %(options)r")
1160
def __init__(self, filename, options):
1161
KnitError.__init__(self)
1162
self.filename = filename
1163
self.options = options
1202
1166
class NoSuchExportFormat(BzrError):
1204
1168
_fmt = "Export format %(format)r not supported"
1206
1170
def __init__(self, format):
1303
1238
self.port = ':%s' % port
1306
# XXX: This is also used for unexpected end of file, which is different at the
1307
# TCP level from "connection reset".
1308
1241
class ConnectionReset(TransportError):
1310
1243
_fmt = "Connection closed: %(msg)s %(orig_error)s"
1313
class ConnectionTimeout(ConnectionError):
1315
_fmt = "Connection Timeout: %(msg)s%(orig_error)s"
1318
1246
class InvalidRange(TransportError):
1320
_fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1322
def __init__(self, path, offset, msg=None):
1323
TransportError.__init__(self, msg)
1248
_fmt = "Invalid range access in %(path)s at %(offset)s."
1250
def __init__(self, path, offset):
1251
TransportError.__init__(self, ("Invalid range access in %s at %d"
1324
1253
self.path = path
1325
1254
self.offset = offset
1328
1257
class InvalidHttpResponse(TransportError):
1330
_fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1259
_fmt = "Invalid http response for %(path)s: %(msg)s"
1332
1261
def __init__(self, path, msg, orig_error=None):
1333
1262
self.path = path
1334
if orig_error is None:
1337
# This is reached for obscure and unusual errors so we want to
1338
# preserve as much info as possible to ease debug.
1339
orig_error = ': %r' % (orig_error,)
1340
1263
TransportError.__init__(self, msg, orig_error=orig_error)
1343
1266
class InvalidHttpRange(InvalidHttpResponse):
1345
1268
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1347
1270
def __init__(self, path, range, msg):
1348
1271
self.range = range
1349
1272
InvalidHttpResponse.__init__(self, path, msg)
1352
class HttpBoundaryMissing(InvalidHttpResponse):
1353
"""A multipart response ends with no boundary marker.
1355
This is a special case caused by buggy proxies, described in
1356
<https://bugs.launchpad.net/bzr/+bug/198646>.
1359
_fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1361
def __init__(self, path, msg):
1362
InvalidHttpResponse.__init__(self, path, msg)
1365
1275
class InvalidHttpContentType(InvalidHttpResponse):
1367
1277
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1369
1279
def __init__(self, path, ctype, msg):
1370
1280
self.ctype = ctype
1371
1281
InvalidHttpResponse.__init__(self, path, msg)
1374
class RedirectRequested(TransportError):
1376
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1378
def __init__(self, source, target, is_permanent=False):
1379
self.source = source
1380
self.target = target
1382
self.permanently = ' permanently'
1384
self.permanently = ''
1385
TransportError.__init__(self)
1388
class TooManyRedirections(TransportError):
1390
_fmt = "Too many redirections"
1393
1284
class ConflictsInTree(BzrError):
1395
1286
_fmt = "Working tree has conflicts."
1398
class DependencyNotPresent(BzrError):
1400
_fmt = 'Unable to import library "%(library)s": %(error)s'
1402
def __init__(self, library, error):
1403
BzrError.__init__(self, library=library, error=error)
1289
class ParseConfigError(BzrError):
1291
def __init__(self, errors, filename):
1292
if filename is None:
1294
message = "Error(s) parsing config file %s:\n%s" % \
1295
(filename, ('\n'.join(e.message for e in errors)))
1296
BzrError.__init__(self, message)
1299
class NoEmailInUsername(BzrError):
1301
_fmt = "%(username)r does not seem to contain a reasonable email address"
1303
def __init__(self, username):
1304
BzrError.__init__(self)
1305
self.username = username
1308
class SigningFailed(BzrError):
1310
_fmt = "Failed to gpg sign data with command %(command_line)r"
1312
def __init__(self, command_line):
1313
BzrError.__init__(self, command_line=command_line)
1406
1316
class WorkingTreeNotRevision(BzrError):
1408
_fmt = ("The working tree for %(basedir)s has changed since"
1318
_fmt = ("The working tree for %(basedir)s has changed since"
1409
1319
" the last commit, but weave merge requires that it be"
1702
1592
_fmt = "Diff3 is not installed on this machine."
1705
class ExistingContent(BzrError):
1706
# Added in breezy 0.92, used by VersionedFile.add_lines.
1708
_fmt = "The content being inserted is already present."
1711
1595
class ExistingLimbo(BzrError):
1713
1597
_fmt = """This tree contains left-over files from a failed operation.
1714
1598
Please examine %(limbo_dir)s to see if it contains any files you wish to
1715
1599
keep, and delete it when you are done."""
1717
1601
def __init__(self, limbo_dir):
1718
BzrError.__init__(self)
1719
self.limbo_dir = limbo_dir
1722
class ExistingPendingDeletion(BzrError):
1724
_fmt = """This tree contains left-over files from a failed operation.
1725
Please examine %(pending_deletion)s to see if it contains any files you
1726
wish to keep, and delete it when you are done."""
1728
def __init__(self, pending_deletion):
1729
BzrError.__init__(self, pending_deletion=pending_deletion)
1602
BzrError.__init__(self)
1603
self.limbo_dir = limbo_dir
1732
1606
class ImmortalLimbo(BzrError):
1734
_fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1608
_fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
1735
1609
Please examine %(limbo_dir)s to see if it contains any files you wish to
1736
1610
keep, and delete it when you are done."""
1738
1612
def __init__(self, limbo_dir):
1739
BzrError.__init__(self)
1740
self.limbo_dir = limbo_dir
1743
class ImmortalPendingDeletion(BzrError):
1745
_fmt = ("Unable to delete transform temporary directory "
1746
"%(pending_deletion)s. Please examine %(pending_deletion)s to see if it "
1747
"contains any files you wish to keep, and delete it when you are done.")
1749
def __init__(self, pending_deletion):
1750
BzrError.__init__(self, pending_deletion=pending_deletion)
1613
BzrError.__init__(self)
1614
self.limbo_dir = limbo_dir
1753
1617
class OutOfDateTree(BzrError):
1755
_fmt = "Working tree is out of date, please run 'brz update'.%(more)s"
1619
_fmt = "Working tree is out of date, please run 'bzr update'."
1757
def __init__(self, tree, more=None):
1621
def __init__(self, tree):
1762
1622
BzrError.__init__(self)
1763
1623
self.tree = tree
1767
1626
class PublicBranchOutOfDate(BzrError):
2117
1957
class TagsNotSupported(BzrError):
2119
1959
_fmt = ("Tags not supported by %(branch)s;"
2120
" you may be able to use 'brz upgrade %(branch_url)s'.")
1960
" you may be able to use bzr upgrade.")
2122
1962
def __init__(self, branch):
2123
1963
self.branch = branch
2124
self.branch_url = branch.user_url
2127
1966
class TagAlreadyExists(BzrError):
2129
1968
_fmt = "Tag %(tag_name)s already exists."
2131
1970
def __init__(self, tag_name):
2132
1971
self.tag_name = tag_name
2135
class UnexpectedSmartServerResponse(BzrError):
2137
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2139
def __init__(self, response_tuple):
2140
self.response_tuple = response_tuple
2143
class ErrorFromSmartServer(BzrError):
2144
"""An error was received from a smart server.
2146
:seealso: UnknownErrorFromSmartServer
2149
_fmt = "Error received from smart server: %(error_tuple)r"
2151
internal_error = True
2153
def __init__(self, error_tuple):
2154
self.error_tuple = error_tuple
2156
self.error_verb = error_tuple[0]
2158
self.error_verb = None
2159
self.error_args = error_tuple[1:]
2162
class UnknownErrorFromSmartServer(BzrError):
2163
"""An ErrorFromSmartServer could not be translated into a typical breezy
2166
This is distinct from ErrorFromSmartServer so that it is possible to
2167
distinguish between the following two cases:
2169
- ErrorFromSmartServer was uncaught. This is logic error in the client
2170
and so should provoke a traceback to the user.
2171
- ErrorFromSmartServer was caught but its error_tuple could not be
2172
translated. This is probably because the server sent us garbage, and
2173
should not provoke a traceback.
2176
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2178
internal_error = False
2180
def __init__(self, error_from_smart_server):
2183
:param error_from_smart_server: An ErrorFromSmartServer instance.
2185
self.error_from_smart_server = error_from_smart_server
2186
self.error_tuple = error_from_smart_server.error_tuple
2189
class ContainerError(BzrError):
2190
"""Base class of container errors."""
2193
class UnknownContainerFormatError(ContainerError):
2195
_fmt = "Unrecognised container format: %(container_format)r"
2197
def __init__(self, container_format):
2198
self.container_format = container_format
2201
class UnexpectedEndOfContainerError(ContainerError):
2203
_fmt = "Unexpected end of container stream"
2206
class UnknownRecordTypeError(ContainerError):
2208
_fmt = "Unknown record type: %(record_type)r"
2210
def __init__(self, record_type):
2211
self.record_type = record_type
2214
class InvalidRecordError(ContainerError):
2216
_fmt = "Invalid record: %(reason)s"
2218
def __init__(self, reason):
2219
self.reason = reason
2222
class ContainerHasExcessDataError(ContainerError):
2224
_fmt = "Container has data after end marker: %(excess)r"
2226
def __init__(self, excess):
2227
self.excess = excess
2230
class DuplicateRecordNameError(ContainerError):
2232
_fmt = "Container has multiple records with the same name: %(name)s"
2234
def __init__(self, name):
2235
self.name = name.decode("utf-8")
2238
class RepositoryDataStreamError(BzrError):
2240
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2242
def __init__(self, reason):
2243
self.reason = reason
2246
class UncommittedChanges(BzrError):
2248
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2249
' (See brz status).%(more)s')
2251
def __init__(self, tree, more=None):
2256
import breezy.urlutils as urlutils
2257
user_url = getattr(tree, "user_url", None)
2258
if user_url is None:
2259
display_url = str(tree)
2261
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2262
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2265
class StoringUncommittedNotSupported(BzrError):
2267
_fmt = ('Branch "%(display_url)s" does not support storing uncommitted'
2270
def __init__(self, branch):
2271
import breezy.urlutils as urlutils
2272
user_url = getattr(branch, "user_url", None)
2273
if user_url is None:
2274
display_url = str(branch)
2276
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2277
BzrError.__init__(self, branch=branch, display_url=display_url)
2280
class ShelvedChanges(UncommittedChanges):
2282
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2283
' (See brz shelve --list).%(more)s')
2286
class UnableEncodePath(BzrError):
2288
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2289
'user encoding %(user_encoding)s')
2291
def __init__(self, path, kind):
2292
from breezy.osutils import get_user_encoding
2295
self.user_encoding = get_user_encoding()
2298
class NoSuchAlias(BzrError):
2300
_fmt = ('The alias "%(alias_name)s" does not exist.')
2302
def __init__(self, alias_name):
2303
BzrError.__init__(self, alias_name=alias_name)
2306
class CannotBindAddress(BzrError):
2308
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2310
def __init__(self, host, port, orig_error):
2311
# nb: in python2.4 socket.error doesn't have a useful repr
2312
BzrError.__init__(self, host=host, port=port,
2313
orig_error=repr(orig_error.args))
2316
class TipChangeRejected(BzrError):
2317
"""A pre_change_branch_tip hook function may raise this to cleanly and
2318
explicitly abort a change to a branch tip.
2321
_fmt = u"Tip change rejected: %(msg)s"
2323
def __init__(self, msg):
2327
class JailBreak(BzrError):
2329
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2331
def __init__(self, url):
2332
BzrError.__init__(self, url=url)
2335
class UserAbort(BzrError):
2337
_fmt = 'The user aborted the operation.'
2340
class UnresumableWriteGroup(BzrError):
2342
_fmt = ("Repository %(repository)s cannot resume write group "
2343
"%(write_groups)r: %(reason)s")
2345
internal_error = True
2347
def __init__(self, repository, write_groups, reason):
2348
self.repository = repository
2349
self.write_groups = write_groups
2350
self.reason = reason
2353
class UnsuspendableWriteGroup(BzrError):
2355
_fmt = ("Repository %(repository)s cannot suspend a write group.")
2357
internal_error = True
2359
def __init__(self, repository):
2360
self.repository = repository
2363
class LossyPushToSameVCS(BzrError):
2365
_fmt = ("Lossy push not possible between %(source_branch)r and "
2366
"%(target_branch)r that are in the same VCS.")
2368
internal_error = True
2370
def __init__(self, source_branch, target_branch):
2371
self.source_branch = source_branch
2372
self.target_branch = target_branch
2375
class NoRoundtrippingSupport(BzrError):
2377
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
2378
"%(target_branch)r.")
2380
internal_error = True
2382
def __init__(self, source_branch, target_branch):
2383
self.source_branch = source_branch
2384
self.target_branch = target_branch
2387
class NoColocatedBranchSupport(BzrError):
2389
_fmt = ("%(controldir)r does not support co-located branches.")
2391
def __init__(self, controldir):
2392
self.controldir = controldir
2395
class RecursiveBind(BzrError):
2397
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2398
'Please use `brz unbind` to fix.')
2400
def __init__(self, branch_url):
2401
self.branch_url = branch_url
2404
class UnsupportedKindChange(BzrError):
2406
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2407
"%(path)s not supported by format %(format)r")
2409
def __init__(self, path, from_kind, to_kind, format):
2411
self.from_kind = from_kind
2412
self.to_kind = to_kind
2413
self.format = format
2416
class ChangesAlreadyStored(BzrCommandError):
2418
_fmt = ('Cannot store uncommitted changes because this branch already'
2419
' stores uncommitted changes.')
2422
class RevnoOutOfBounds(InternalBzrError):
2424
_fmt = ("The requested revision number %(revno)d is outside of the "
2425
"expected boundaries (%(minimum)d <= %(maximum)d).")
2427
def __init__(self, revno, bounds):
2428
InternalBzrError.__init__(
2429
self, revno=revno, minimum=bounds[0], maximum=bounds[1])