120
120
# base classes should override the docstring with their human-
121
121
# readable explanation
123
def __init__(self, **kwds):
123
def __init__(self, *args, **kwds):
124
# XXX: Use the underlying BzrError to always generate the args attribute
125
# if it doesn't exist. We can't use super here, because exceptions are
126
# old-style classes in python2.4 (but new in 2.5). --bmc, 20060426
127
BzrError.__init__(self, *args)
124
128
for key, value in kwds.items():
125
129
setattr(self, key, value)
127
131
def __str__(self):
129
return self.__doc__ % self.__dict__
130
except (NameError, ValueError, KeyError), e:
131
return 'Unprintable exception %s: %s' \
132
% (self.__class__.__name__, str(e))
133
# __str__() should always return a 'str' object
134
# never a 'unicode' object.
135
s = self.__doc__ % self.__dict__
136
if isinstance(s, unicode):
137
return s.encode('utf8')
139
except (TypeError, NameError, ValueError, KeyError), e:
140
return 'Unprintable exception %s(%r): %s' \
141
% (self.__class__.__name__,
142
self.__dict__, str(e))
145
class AlreadyBuilding(BzrNewError):
146
"""The tree builder is already building a tree."""
135
149
class BzrCheckError(BzrNewError):
265
297
PathError.__init__(self, url, extra=extra)
300
class ShortReadvError(PathError):
301
"""readv() read %(actual)s bytes rather than %(length)s bytes at %(offset)s for %(path)s%(extra)s"""
303
is_user_error = False
305
def __init__(self, path, offset, length, actual, extra=None):
306
PathError.__init__(self, path, extra=extra)
268
312
class PathNotChild(BzrNewError):
269
313
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
304
348
(use bzr checkout if you wish to build a working tree): %(path)s"""
351
class AtomicFileAlreadyClosed(PathError):
352
"""'%(function)s' called on an AtomicFile after it was closed: %(path)s"""
354
def __init__(self, path, function):
355
PathError.__init__(self, path=path, extra=None)
356
self.function = function
359
class InaccessibleParent(PathError):
360
"""Parent not accessible given base %(base)s and relative path %(path)s"""
362
def __init__(self, path, base):
363
PathError.__init__(self, path)
307
367
class NoRepositoryPresent(BzrNewError):
308
368
"""No repository present: %(path)r"""
309
369
def __init__(self, bzrdir):
489
548
is_user_error = False
491
550
def __init__(self, branch, revision):
493
self.revision = revision
551
BzrNewError.__init__(self, branch=branch, revision=revision)
554
class NoSuchRevisionSpec(BzrNewError):
555
"""No namespace registered for string: %(spec)r"""
557
def __init__(self, spec):
558
BzrNewError.__init__(self, spec=spec)
561
class InvalidRevisionSpec(BzrNewError):
562
"""Requested revision: '%(spec)s' does not exist in branch:
563
%(branch)s%(extra)s"""
565
def __init__(self, spec, branch, extra=None):
566
BzrNewError.__init__(self, branch=branch, spec=spec)
568
self.extra = '\n' + str(extra)
496
573
class HistoryMissing(BzrError):
559
636
self.bases = bases
562
class NoCommits(BzrError):
639
class NoCommits(BzrNewError):
640
"""Branch %(branch)s has no commits."""
563
642
def __init__(self, branch):
564
msg = "Branch %s has no commits." % branch
565
BzrError.__init__(self, msg)
643
BzrNewError.__init__(self, branch=branch)
568
646
class UnlistableStore(BzrError):
930
1021
self.format = format
1024
class BadConversionTarget(BzrNewError):
1025
"""Cannot convert to format %(format)s. %(problem)s"""
1027
def __init__(self, problem, format):
1028
BzrNewError.__init__(self)
1029
self.problem = problem
1030
self.format = format
933
1033
class NoDiff(BzrNewError):
934
1034
"""Diff is not installed on this machine: %(msg)s"""
936
1036
def __init__(self, msg):
937
super(NoDiff, self).__init__(msg=msg)
1037
BzrNewError.__init__(self, msg=msg)
940
1040
class NoDiff3(BzrNewError):
1045
1145
"""Not a bzr revision-bundle: %(text)r"""
1047
1147
def __init__(self, text):
1051
class BadBundle(Exception): pass
1054
class MalformedHeader(BadBundle): pass
1057
class MalformedPatches(BadBundle): pass
1060
class MalformedFooter(BadBundle): pass
1148
BzrNewError.__init__(self)
1152
class BadBundle(BzrNewError):
1153
"""Bad bzr revision-bundle: %(text)r"""
1155
def __init__(self, text):
1156
BzrNewError.__init__(self)
1160
class MalformedHeader(BadBundle):
1161
"""Malformed bzr revision-bundle header: %(text)r"""
1163
def __init__(self, text):
1164
BzrNewError.__init__(self)
1168
class MalformedPatches(BadBundle):
1169
"""Malformed patches in bzr revision-bundle: %(text)r"""
1171
def __init__(self, text):
1172
BzrNewError.__init__(self)
1176
class MalformedFooter(BadBundle):
1177
"""Malformed footer in bzr revision-bundle: %(text)r"""
1179
def __init__(self, text):
1180
BzrNewError.__init__(self)
1184
class UnsupportedEOLMarker(BadBundle):
1185
"""End of line marker was not \\n in bzr revision-bundle"""
1188
BzrNewError.__init__(self)
1191
class BadInventoryFormat(BzrNewError):
1192
"""Root class for inventory serialization errors"""
1195
class UnexpectedInventoryFormat(BadInventoryFormat):
1196
"""The inventory was not in the expected format:\n %(msg)s"""
1198
def __init__(self, msg):
1199
BadInventoryFormat.__init__(self, msg=msg)
1202
class NoSmartServer(NotBranchError):
1203
"""No smart server available at %(url)s"""
1205
def __init__(self, url):
1209
class UnknownSSH(BzrNewError):
1210
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1212
def __init__(self, vendor):
1213
BzrNewError.__init__(self)
1214
self.vendor = vendor
1217
class GhostRevisionUnusableHere(BzrNewError):
1218
"""Ghost revision {%(revision_id)s} cannot be used here."""
1220
def __init__(self, revision_id):
1221
BzrNewError.__init__(self)
1222
self.revision_id = revision_id
1225
class IllegalUseOfScopeReplacer(BzrNewError):
1226
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1228
is_user_error = False
1230
def __init__(self, name, msg, extra=None):
1231
BzrNewError.__init__(self)
1235
self.extra = ': ' + str(extra)
1240
class InvalidImportLine(BzrNewError):
1241
"""Not a valid import statement: %(msg)\n%(text)s"""
1243
is_user_error = False
1245
def __init__(self, text, msg):
1246
BzrNewError.__init__(self)
1251
class ImportNameCollision(BzrNewError):
1252
"""Tried to import an object to the same name as an existing object. %(name)s"""
1254
is_user_error = False
1256
def __init__(self, name):
1257
BzrNewError.__init__(self)