96
102
fmt = self._get_format_string()
98
s = fmt % self.__dict__
104
d = dict(self.__dict__)
105
# special case: python2.5 puts the 'message' attribute in a
106
# slot, so it isn't seen in __dict__
107
d['message'] = getattr(self, 'message', 'no message')
99
109
# __str__() should always return a 'str' object
100
110
# never a 'unicode' object.
101
111
if isinstance(s, unicode):
139
class InternalBzrError(BzrError):
140
"""Base class for errors that are internal in nature.
142
This is a convenience class for errors that are internal. The
143
internal_error attribute can still be altered in subclasses, if needed.
144
Using this class is simply an easy way to get internal errors.
147
internal_error = True
129
150
class BzrNewError(BzrError):
130
151
"""Deprecated error base class."""
131
152
# base classes should override the docstring with their human-
164
185
_fmt = "The tree builder is already building a tree."
167
class BzrCheckError(BzrError):
188
class BzrCheckError(InternalBzrError):
169
190
_fmt = "Internal check failed: %(message)s"
171
internal_error = True
173
192
def __init__(self, message):
174
193
BzrError.__init__(self)
175
194
self.message = message
178
class DisabledMethod(BzrError):
197
class DisabledMethod(InternalBzrError):
180
199
_fmt = "The smart server method '%(class_name)s' is disabled."
182
internal_error = True
184
201
def __init__(self, class_name):
185
202
BzrError.__init__(self)
186
203
self.class_name = class_name
207
224
self.transport = transport
210
class InvalidEntryName(BzrError):
227
class InvalidEntryName(InternalBzrError):
212
229
_fmt = "Invalid entry name: %(name)s"
214
internal_error = True
216
231
def __init__(self, name):
217
232
BzrError.__init__(self)
245
260
self.revision_id = revision_id
263
class RootMissing(InternalBzrError):
265
_fmt = ("The root entry of a tree must be the first entry supplied to "
266
"record_entry_contents.")
248
269
class NoHelpTopic(BzrError):
250
271
_fmt = ("No help could be found for '%(topic)s'. "
273
294
BzrError.__init__(self, repository=repository, file_id=file_id)
276
class InventoryModified(BzrError):
297
class InventoryModified(InternalBzrError):
278
299
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
279
300
" so a clean inventory cannot be read without data loss.")
281
internal_error = True
283
302
def __init__(self, tree):
309
class WorkingTreeAlreadyPopulated(BzrError):
328
class WorkingTreeAlreadyPopulated(InternalBzrError):
311
330
_fmt = 'Working tree already populated in "%(base)s"'
313
internal_error = True
315
332
def __init__(self, base):
318
336
class BzrCommandError(BzrError):
319
337
"""Error from user command"""
321
internal_error = False
323
339
# Error from malformed user command; please avoid raising this as a
324
340
# generic exception not caused by user input.
481
497
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
484
class ReadingCompleted(BzrError):
500
class ReadingCompleted(InternalBzrError):
486
502
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
487
503
"called upon it - the request has been completed and no more "
488
504
"data may be read.")
490
internal_error = True
492
506
def __init__(self, request):
493
507
self.request = request
770
784
_fmt = 'Cannot operate on "%(filename)s" because it is a control file'
773
class LockError(BzrError):
787
class LockError(InternalBzrError):
775
789
_fmt = "Lock error: %(msg)s"
777
internal_error = True
779
791
# All exceptions from the lock/unlock functions should be from
780
792
# this exception class. They will be translated as necessary. The
781
793
# original exception is available as e.original_error
783
795
# New code should prefer to raise specific subclasses
784
796
def __init__(self, message):
785
797
# Python 2.5 uses a slot for StandardError.message,
786
# so use a different variable name
787
# so it is exposed in self.__dict__
798
# so use a different variable name. We now work around this in
799
# BzrError.__str__, but this member name is kept for compatability.
788
800
self.msg = message
830
842
_fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
844
@symbol_versioning.deprecated_method(symbol_versioning.zero_ninetytwo)
832
845
def __init__(self, fname, msg):
833
846
LockError.__init__(self, '')
834
847
self.fname = fname
851
class LockFailed(LockError):
853
internal_error = False
855
_fmt = "Cannot lock %(lock)s: %(why)s"
857
def __init__(self, lock, why):
858
LockError.__init__(self, '')
838
863
class OutSideTransaction(BzrError):
840
865
_fmt = ("A transaction related operation was attempted after"
975
1000
_fmt = "Commit refused because there are unknowns in the tree."
978
class NoSuchRevision(BzrError):
1003
class NoSuchRevision(InternalBzrError):
980
1005
_fmt = "%(branch)s has no revision %(revision)s"
982
internal_error = True
984
1007
def __init__(self, branch, revision):
985
1008
# 'branch' may sometimes be an internal object like a KnitRevisionStore
986
1009
BzrError.__init__(self, branch=branch, revision=revision)
989
1012
# zero_ninetyone: this exception is no longer raised and should be removed
990
class NotLeftParentDescendant(BzrError):
1013
class NotLeftParentDescendant(InternalBzrError):
992
1015
_fmt = ("Revision %(old_revision)s is not the left parent of"
993
1016
" %(new_revision)s, but branch %(branch_location)s expects this")
995
internal_error = True
997
1018
def __init__(self, branch, old_revision, new_revision):
998
1019
BzrError.__init__(self, branch_location=branch.base,
999
1020
old_revision=old_revision,
1059
1080
_fmt = ("These branches have diverged."
1060
1081
" Use the merge command to reconcile them.")
1062
internal_error = False
1064
1083
def __init__(self, branch1, branch2):
1065
1084
self.branch1 = branch1
1066
1085
self.branch2 = branch2
1069
class NotLefthandHistory(BzrError):
1088
class NotLefthandHistory(InternalBzrError):
1071
1090
_fmt = "Supplied history does not follow left-hand parents"
1073
internal_error = True
1075
1092
def __init__(self, history):
1076
1093
BzrError.__init__(self, history=history)
1374
1387
BzrError.__init__(self)
1377
class TooManyConcurrentRequests(BzrError):
1390
class TooManyConcurrentRequests(InternalBzrError):
1379
1392
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1380
1393
" Be sure to finish_writing and finish_reading on the"
1381
1394
" currently open request.")
1383
internal_error = True
1385
1396
def __init__(self, medium):
1386
1397
self.medium = medium
1577
1588
self.graph = graph
1580
class WritingCompleted(BzrError):
1591
class WritingCompleted(InternalBzrError):
1582
1593
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1583
1594
"called upon it - accept bytes may not be called anymore.")
1585
internal_error = True
1587
1596
def __init__(self, request):
1588
1597
self.request = request
1591
class WritingNotComplete(BzrError):
1600
class WritingNotComplete(InternalBzrError):
1593
1602
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1594
1603
"called upon it - until the write phase is complete no "
1595
1604
"data may be read.")
1597
internal_error = True
1599
1606
def __init__(self, request):
1600
1607
self.request = request
1609
1616
self.filename = filename
1612
class MediumNotConnected(BzrError):
1619
class MediumNotConnected(InternalBzrError):
1614
1621
_fmt = """The medium '%(medium)s' is not connected."""
1616
internal_error = True
1618
1623
def __init__(self, medium):
1619
1624
self.medium = medium
1696
1701
self.root_trans_id = transform.root
1699
class BzrBadParameter(BzrError):
1704
class BzrBadParameter(InternalBzrError):
1701
1706
_fmt = "Bad parameter: %(param)r"
1703
internal_error = True
1705
1708
# This exception should never be thrown, but it is a base class for all
1706
1709
# parameter-to-function errors.
1854
1857
_fmt = "Diff3 is not installed on this machine."
1860
class ExistingContent(BzrError):
1861
# Added in bzrlib 0.92, used by VersionedFile.add_lines.
1863
_fmt = "The content being inserted is already present."
1857
1866
class ExistingLimbo(BzrError):
1859
1868
_fmt = """This tree contains left-over files from a failed operation.
2084
2093
_fmt = """This operation requires rich root data storage"""
2087
class NoSmartMedium(BzrError):
2096
class NoSmartMedium(InternalBzrError):
2089
2098
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
2091
internal_error = True
2093
2100
def __init__(self, transport):
2094
2101
self.transport = transport
2126
2133
self.revision_id = revision_id
2129
class IllegalUseOfScopeReplacer(BzrError):
2136
class IllegalUseOfScopeReplacer(InternalBzrError):
2131
2138
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2132
2139
" %(msg)s%(extra)s")
2134
internal_error = True
2136
2141
def __init__(self, name, msg, extra=None):
2137
2142
BzrError.__init__(self)
2138
2143
self.name = name
2143
2148
self.extra = ''
2146
class InvalidImportLine(BzrError):
2151
class InvalidImportLine(InternalBzrError):
2148
2153
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
2150
internal_error = True
2152
2155
def __init__(self, text, msg):
2153
2156
BzrError.__init__(self)
2154
2157
self.text = text
2158
class ImportNameCollision(BzrError):
2161
class ImportNameCollision(InternalBzrError):
2160
2163
_fmt = ("Tried to import an object to the same name as"
2161
2164
" an existing object. %(name)s")
2163
internal_error = True
2165
2166
def __init__(self, name):
2166
2167
BzrError.__init__(self)
2167
2168
self.name = name
2199
2200
class PatchMissing(BzrError):
2200
2201
"""Raise a patch type was specified but no patch supplied"""
2202
_fmt = "patch_type was %(patch_type)s, but no patch was supplied."
2203
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2204
2205
def __init__(self, patch_type):
2205
2206
BzrError.__init__(self)
2232
2233
self.other_tree = other_tree
2235
class BadReferenceTarget(BzrError):
2236
class BadReferenceTarget(InternalBzrError):
2237
2238
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2240
internal_error = True
2242
2241
def __init__(self, tree, other_tree, reason):
2243
2242
self.tree = tree
2244
2243
self.other_tree = other_tree
2348
2345
self.name = name
2351
class NoDestinationAddress(BzrError):
2348
class NoDestinationAddress(InternalBzrError):
2353
2350
_fmt = "Message does not have a destination address."
2355
internal_error = True
2353
class RepositoryDataStreamError(BzrError):
2355
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2357
def __init__(self, reason):
2358
self.reason = reason
2358
2361
class SMTPError(BzrError):
2398
2401
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2400
2403
_fmt = "Please specify smtp_server. No server at default %(host)s."
2406
class BzrDirError(BzrError):
2408
def __init__(self, bzrdir):
2409
import bzrlib.urlutils as urlutils
2410
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2412
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2415
class AlreadyBranch(BzrDirError):
2417
_fmt = "'%(display_url)s' is already a branch."
2420
class AlreadyTree(BzrDirError):
2422
_fmt = "'%(display_url)s' is already a tree."
2425
class AlreadyCheckout(BzrDirError):
2427
_fmt = "'%(display_url)s' is already a checkout."
2430
class ReconfigurationNotSupported(BzrDirError):
2432
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2435
class NoBindLocation(BzrDirError):
2437
_fmt = "No location could be found to bind to at %(display_url)s."
2440
class UncommittedChanges(BzrError):
2442
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2444
def __init__(self, tree):
2445
import bzrlib.urlutils as urlutils
2446
display_url = urlutils.unescape_for_display(
2447
tree.bzrdir.root_transport.base, 'ascii')
2448
BzrError.__init__(self, tree=tree, display_url=display_url)