127
127
def __str__(self):
129
return self.__doc__ % self.__dict__
129
# __str__() should always return a 'str' object
130
# never a 'unicode' object.
131
s = self.__doc__ % self.__dict__
132
if isinstance(s, unicode):
133
return s.encode('utf8')
130
135
except (NameError, ValueError, KeyError), e:
131
136
return 'Unprintable exception %s: %s' \
132
137
% (self.__class__.__name__, str(e))
162
167
class InvalidRevisionId(BzrNewError):
163
168
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
164
170
def __init__(self, revision_id, branch):
165
171
# branch can be any string or object with __str__ defined
166
172
BzrNewError.__init__(self)
197
203
# BzrCommandError, and non-UI code should not throw a subclass of
198
204
# BzrCommandError. ADHB 20051211
199
205
def __init__(self, msg):
206
# Object.__str__() must return a real string
207
# returning a Unicode string is a python error.
208
if isinstance(msg, unicode):
209
self.msg = msg.encode('utf8')
202
213
def __str__(self):
304
315
(use bzr checkout if you wish to build a working tree): %(path)s"""
318
class AtomicFileAlreadyClosed(PathError):
319
"""'%(function)s' called on an AtomicFile after it was closed: %(path)s"""
321
def __init__(self, path, function):
322
PathError.__init__(self, path=path, extra=None)
323
self.function = function
326
class InaccessibleParent(PathError):
327
"""Parent not accessible given base %(base)s and relative path %(path)s"""
329
def __init__(self, path, base):
330
PathError.__init__(self, path)
307
334
class NoRepositoryPresent(BzrNewError):
308
335
"""No repository present: %(path)r"""
309
336
def __init__(self, bzrdir):
1045
1072
"""Not a bzr revision-bundle: %(text)r"""
1047
1074
def __init__(self, text):
1051
class BadBundle(Exception): pass
1054
class MalformedHeader(BadBundle): pass
1057
class MalformedPatches(BadBundle): pass
1060
class MalformedFooter(BadBundle): pass
1075
BzrNewError.__init__(self)
1079
class BadBundle(BzrNewError):
1080
"""Bad bzr revision-bundle: %(text)r"""
1082
def __init__(self, text):
1083
BzrNewError.__init__(self)
1087
class MalformedHeader(BadBundle):
1088
"""Malformed bzr revision-bundle header: %(text)r"""
1090
def __init__(self, text):
1091
BzrNewError.__init__(self)
1095
class MalformedPatches(BadBundle):
1096
"""Malformed patches in bzr revision-bundle: %(text)r"""
1098
def __init__(self, text):
1099
BzrNewError.__init__(self)
1103
class MalformedFooter(BadBundle):
1104
"""Malformed footer in bzr revision-bundle: %(text)r"""
1106
def __init__(self, text):
1107
BzrNewError.__init__(self)
1111
class UnsupportedEOLMarker(BadBundle):
1112
"""End of line marker was not \\n in bzr revision-bundle"""
1115
BzrNewError.__init__(self)
1118
class GhostRevisionUnusableHere(BzrNewError):
1119
"""Ghost revision {%(revision_id)s} cannot be used here."""
1121
def __init__(self, revision_id):
1122
BzrNewError.__init__(self)
1123
self.revision_id = revision_id