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
975
985
_fmt = "Commit refused because there are unknowns in the tree."
978
class NoSuchRevision(BzrError):
988
class NoSuchRevision(InternalBzrError):
980
990
_fmt = "%(branch)s has no revision %(revision)s"
982
internal_error = True
984
992
def __init__(self, branch, revision):
985
993
# 'branch' may sometimes be an internal object like a KnitRevisionStore
986
994
BzrError.__init__(self, branch=branch, revision=revision)
989
997
# zero_ninetyone: this exception is no longer raised and should be removed
990
class NotLeftParentDescendant(BzrError):
998
class NotLeftParentDescendant(InternalBzrError):
992
1000
_fmt = ("Revision %(old_revision)s is not the left parent of"
993
1001
" %(new_revision)s, but branch %(branch_location)s expects this")
995
internal_error = True
997
1003
def __init__(self, branch, old_revision, new_revision):
998
1004
BzrError.__init__(self, branch_location=branch.base,
999
1005
old_revision=old_revision,
1059
1065
_fmt = ("These branches have diverged."
1060
1066
" Use the merge command to reconcile them.")
1062
internal_error = False
1064
1068
def __init__(self, branch1, branch2):
1065
1069
self.branch1 = branch1
1066
1070
self.branch2 = branch2
1069
class NotLefthandHistory(BzrError):
1073
class NotLefthandHistory(InternalBzrError):
1071
1075
_fmt = "Supplied history does not follow left-hand parents"
1073
internal_error = True
1075
1077
def __init__(self, history):
1076
1078
BzrError.__init__(self, history=history)
1374
1372
BzrError.__init__(self)
1377
class TooManyConcurrentRequests(BzrError):
1375
class TooManyConcurrentRequests(InternalBzrError):
1379
1377
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1380
1378
" Be sure to finish_writing and finish_reading on the"
1381
1379
" currently open request.")
1383
internal_error = True
1385
1381
def __init__(self, medium):
1386
1382
self.medium = medium
1577
1573
self.graph = graph
1580
class WritingCompleted(BzrError):
1576
class WritingCompleted(InternalBzrError):
1582
1578
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1583
1579
"called upon it - accept bytes may not be called anymore.")
1585
internal_error = True
1587
1581
def __init__(self, request):
1588
1582
self.request = request
1591
class WritingNotComplete(BzrError):
1585
class WritingNotComplete(InternalBzrError):
1593
1587
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1594
1588
"called upon it - until the write phase is complete no "
1595
1589
"data may be read.")
1597
internal_error = True
1599
1591
def __init__(self, request):
1600
1592
self.request = request
1609
1601
self.filename = filename
1612
class MediumNotConnected(BzrError):
1604
class MediumNotConnected(InternalBzrError):
1614
1606
_fmt = """The medium '%(medium)s' is not connected."""
1616
internal_error = True
1618
1608
def __init__(self, medium):
1619
1609
self.medium = medium
1696
1686
self.root_trans_id = transform.root
1699
class BzrBadParameter(BzrError):
1689
class BzrBadParameter(InternalBzrError):
1701
1691
_fmt = "Bad parameter: %(param)r"
1703
internal_error = True
1705
1693
# This exception should never be thrown, but it is a base class for all
1706
1694
# parameter-to-function errors.
1854
1842
_fmt = "Diff3 is not installed on this machine."
1845
class ExistingContent(BzrError):
1846
# Added in bzrlib 0.92, used by VersionedFile.add_lines.
1848
_fmt = "The content being inserted is already present."
1857
1851
class ExistingLimbo(BzrError):
1859
1853
_fmt = """This tree contains left-over files from a failed operation.
2084
2078
_fmt = """This operation requires rich root data storage"""
2087
class NoSmartMedium(BzrError):
2081
class NoSmartMedium(InternalBzrError):
2089
2083
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
2091
internal_error = True
2093
2085
def __init__(self, transport):
2094
2086
self.transport = transport
2126
2118
self.revision_id = revision_id
2129
class IllegalUseOfScopeReplacer(BzrError):
2121
class IllegalUseOfScopeReplacer(InternalBzrError):
2131
2123
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2132
2124
" %(msg)s%(extra)s")
2134
internal_error = True
2136
2126
def __init__(self, name, msg, extra=None):
2137
2127
BzrError.__init__(self)
2138
2128
self.name = name
2143
2133
self.extra = ''
2146
class InvalidImportLine(BzrError):
2136
class InvalidImportLine(InternalBzrError):
2148
2138
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
2150
internal_error = True
2152
2140
def __init__(self, text, msg):
2153
2141
BzrError.__init__(self)
2154
2142
self.text = text
2158
class ImportNameCollision(BzrError):
2146
class ImportNameCollision(InternalBzrError):
2160
2148
_fmt = ("Tried to import an object to the same name as"
2161
2149
" an existing object. %(name)s")
2163
internal_error = True
2165
2151
def __init__(self, name):
2166
2152
BzrError.__init__(self)
2167
2153
self.name = name
2232
2218
self.other_tree = other_tree
2235
class BadReferenceTarget(BzrError):
2221
class BadReferenceTarget(InternalBzrError):
2237
2223
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2240
internal_error = True
2242
2226
def __init__(self, tree, other_tree, reason):
2243
2227
self.tree = tree
2244
2228
self.other_tree = other_tree
2406
2386
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2408
2388
_fmt = "Please specify smtp_server. No server at default %(host)s."
2391
class BzrDirError(BzrError):
2393
def __init__(self, bzrdir):
2394
import bzrlib.urlutils as urlutils
2395
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2397
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2400
class AlreadyBranch(BzrDirError):
2402
_fmt = "'%(display_url)s' is already a branch."
2405
class AlreadyTree(BzrDirError):
2407
_fmt = "'%(display_url)s' is already a tree."
2410
class AlreadyCheckout(BzrDirError):
2412
_fmt = "'%(display_url)s' is already a checkout."
2415
class ReconfigurationNotSupported(BzrDirError):
2417
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2420
class NoBindLocation(BzrDirError):
2422
_fmt = "No location could be found to bind to at %(display_url)s."
2425
class UncommittedChanges(BzrError):
2427
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2429
def __init__(self, tree):
2430
import bzrlib.urlutils as urlutils
2431
display_url = urlutils.unescape_for_display(
2432
tree.bzrdir.root_transport.base, 'ascii')
2433
BzrError.__init__(self, tree=tree, display_url=display_url)