132
132
if isinstance(s, unicode):
133
133
return s.encode('utf8')
135
except (NameError, ValueError, KeyError), e:
136
return 'Unprintable exception %s: %s' \
137
% (self.__class__.__name__, str(e))
135
except (TypeError, NameError, ValueError, KeyError), e:
136
return 'Unprintable exception %s(%r): %s' \
137
% (self.__class__.__name__,
138
self.__dict__, str(e))
140
141
class BzrCheckError(BzrNewError):
167
168
class InvalidRevisionId(BzrNewError):
168
169
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
169
171
def __init__(self, revision_id, branch):
170
172
# branch can be any string or object with __str__ defined
171
173
BzrNewError.__init__(self)
173
175
self.branch = branch
178
class NoSuchId(BzrNewError):
179
"""The file id %(file_id)s is not present in the tree %(tree)s."""
181
def __init__(self, tree, file_id):
182
BzrNewError.__init__(self)
183
self.file_id = file_id
176
187
class NoWorkingTree(BzrNewError):
177
188
"""No WorkingTree exists for %(base)s."""
515
525
is_user_error = False
517
527
def __init__(self, branch, revision):
519
self.revision = revision
528
BzrNewError.__init__(self, branch=branch, revision=revision)
531
class NoSuchRevisionSpec(BzrNewError):
532
"""No namespace registered for string: %(spec)r"""
534
def __init__(self, spec):
535
BzrNewError.__init__(self, spec=spec)
538
class InvalidRevisionSpec(BzrNewError):
539
"""Requested revision: '%(spec)s' does not exist in branch:
540
%(branch)s%(extra)s"""
542
def __init__(self, spec, branch, extra=None):
543
BzrNewError.__init__(self, branch=branch, spec=spec)
545
self.extra = '\n' + str(extra)
522
550
class HistoryMissing(BzrError):
585
613
self.bases = bases
588
class NoCommits(BzrError):
616
class NoCommits(BzrNewError):
617
"""Branch %(branch)s has no commits."""
589
619
def __init__(self, branch):
590
msg = "Branch %s has no commits." % branch
591
BzrError.__init__(self, msg)
620
BzrNewError.__init__(self, branch=branch)
594
623
class UnlistableStore(BzrError):
778
807
class InvalidRange(TransportError):
779
"""Invalid range access."""
808
"""Invalid range access in %(path)s at %(offset)s."""
781
810
def __init__(self, path, offset):
782
811
TransportError.__init__(self, ("Invalid range access in %s at %d"
783
812
% (path, offset)))
786
817
class InvalidHttpResponse(TransportError):
948
979
DependencyNotPresent.__init__(self, 'paramiko', error)
982
class PointlessMerge(BzrNewError):
983
"""Nothing to merge."""
951
986
class UninitializableFormat(BzrNewError):
952
987
"""Format %(format)s cannot be initialised by this version of bzr."""
956
991
self.format = format
994
class BadConversionTarget(BzrNewError):
995
"""Cannot convert to format %(format)s. %(problem)s"""
997
def __init__(self, problem, format):
998
BzrNewError.__init__(self)
999
self.problem = problem
1000
self.format = format
959
1003
class NoDiff(BzrNewError):
960
1004
"""Diff is not installed on this machine: %(msg)s"""
1106
1150
BzrNewError.__init__(self)
1107
1151
self.text = text
1109
1154
class UnsupportedEOLMarker(BadBundle):
1110
1155
"""End of line marker was not \\n in bzr revision-bundle"""
1112
1157
def __init__(self):
1113
BzrNewError.__init__(self)
1158
BzrNewError.__init__(self)
1161
class BadInventoryFormat(BzrNewError):
1162
"""Root class for inventory serialization errors"""
1165
class UnexpectedInventoryFormat(BadInventoryFormat):
1166
"""The inventory was not in the expected format:\n %(msg)s"""
1168
def __init__(self, msg):
1169
BadInventoryFormat.__init__(self, msg=msg)
1172
class UnknownSSH(BzrNewError):
1173
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1175
def __init__(self, vendor):
1176
BzrNewError.__init__(self)
1177
self.vendor = vendor
1180
class GhostRevisionUnusableHere(BzrNewError):
1181
"""Ghost revision {%(revision_id)s} cannot be used here."""
1183
def __init__(self, revision_id):
1184
BzrNewError.__init__(self)
1185
self.revision_id = revision_id
1188
class IllegalUseOfScopeReplacer(BzrNewError):
1189
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1191
is_user_error = False
1193
def __init__(self, name, msg, extra=None):
1194
BzrNewError.__init__(self)
1198
self.extra = ': ' + str(extra)
1203
class InvalidImportLine(BzrNewError):
1204
"""Not a valid import statement: %(msg)\n%(text)s"""
1206
is_user_error = False
1208
def __init__(self, text, msg):
1209
BzrNewError.__init__(self)
1214
class ImportNameCollision(BzrNewError):
1215
"""Tried to import an object to the same name as an existing object. %(name)s"""
1217
is_user_error = False
1219
def __init__(self, name):
1220
BzrNewError.__init__(self)