104
101
class BzrCheckError(BzrNewError):
105
102
"""Internal check failed: %(message)s"""
106
103
def __init__(self, message):
107
BzrNewError.__init__(self)
108
104
self.message = message
111
107
class InvalidEntryName(BzrNewError):
112
108
"""Invalid entry name: %(name)s"""
113
109
def __init__(self, name):
114
BzrNewError.__init__(self)
118
113
class InvalidRevisionNumber(BzrNewError):
119
114
"""Invalid revision number %(revno)d"""
120
115
def __init__(self, revno):
121
BzrNewError.__init__(self)
122
116
self.revno = revno
125
119
class InvalidRevisionId(BzrNewError):
126
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
127
def __init__(self, revision_id, branch):
128
BzrNewError.__init__(self)
129
self.revision_id = revision_id
133
class NoWorkingTree(BzrNewError):
134
"""No WorkingTree exists for %s(base)."""
136
def __init__(self, base):
137
BzrNewError.__init__(self)
120
"""Invalid revision-id"""
141
123
class BzrCommandError(BzrError):
142
124
# Error from malformed user command
143
# This is being misused as a generic exception
144
# pleae subclass. RBC 20051030
145
125
def __str__(self):
146
126
return self.args[0]
149
class BzrOptionError(BzrCommandError):
150
"""Some missing or otherwise incorrect option was supplied."""
153
128
class StrictCommitFailed(Exception):
154
129
"""Commit refused because there are unknowns in the tree."""
157
class PathError(BzrNewError):
158
"""Generic path error: %(path)r%(extra)s)"""
159
def __init__(self, path, extra=None):
160
BzrNewError.__init__(self)
163
self.extra = ': ' + str(extra)
168
class NoSuchFile(PathError):
169
"""No such file: %(path)r%(extra)s"""
172
class FileExists(PathError):
173
"""File exists: %(path)r%(extra)s"""
176
class PermissionDenied(PathError):
177
"""Permission denied: %(path)r%(extra)s"""
180
class PathNotChild(BzrNewError):
181
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
182
def __init__(self, path, base, extra=None):
183
BzrNewError.__init__(self)
187
self.extra = ': ' + str(extra)
192
131
class NotBranchError(BzrNewError):
193
132
"""Not a branch: %(path)s"""
194
133
def __init__(self, path):
199
class FileInWrongBranch(BzrNewError):
200
"""File %(path)s in not in branch %(branch_base)s."""
201
def __init__(self, branch, path):
202
BzrNewError.__init__(self)
204
self.branch_base = branch.base
208
138
class UnsupportedFormatError(BzrError):
209
139
"""Specified path is a bzr branch that we cannot read."""
210
140
def __str__(self):
303
231
self.not_ancestor_id = not_ancestor_id
234
class NotAncestor(BzrError):
235
def __init__(self, rev_id, not_ancestor_id):
237
self.not_ancestor_id = not_ancestor_id
238
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
240
BzrError.__init__(self, msg)
306
243
class InstallFailed(BzrError):
307
244
def __init__(self, revisions):
308
245
msg = "Could not install revisions:\n%s" % " ,".join(revisions)
331
268
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
334
class WeaveError(BzrNewError):
335
"""Error in processing weave: %(message)s"""
336
def __init__(self, message=None):
337
BzrNewError.__init__(self)
338
self.message = message
341
class WeaveRevisionAlreadyPresent(WeaveError):
342
"""Revision {%(revision_id)s} already present in %(weave)s"""
343
def __init__(self, revision_id, weave):
344
WeaveError.__init__(self)
345
self.revision_id = revision_id
349
class WeaveRevisionNotPresent(WeaveError):
350
"""Revision {%(revision_id)s} not present in %(weave)s"""
351
def __init__(self, revision_id, weave):
352
WeaveError.__init__(self)
353
self.revision_id = revision_id
357
class WeaveFormatError(WeaveError):
358
"""Weave invariant violated: %(what)s"""
359
def __init__(self, what):
360
WeaveError.__init__(self)
364
class WeaveParentMismatch(WeaveError):
365
"""Parents are mismatched between two revisions."""
368
class NoSuchExportFormat(BzrNewError):
369
"""Export format %(format)r not supported"""
370
def __init__(self, format):
371
BzrNewError.__init__(self)
271
from bzrlib.weave import WeaveError, WeaveParentMismatch
375
273
class TransportError(BzrError):
376
274
"""All errors thrown by Transport implementations should derive
394
class ConnectionError(TransportError):
395
"""A connection problem prevents file retrieval.
396
This does not indicate whether the file exists or not; it indicates that a
397
precondition for requesting the file was not met.
399
def __init__(self, msg=None, orig_error=None):
400
TransportError.__init__(self, msg=msg, orig_error=orig_error)
291
class NonRelativePath(TransportError):
292
"""An absolute path was supplied, that could not be decoded into
297
class NoSuchFile(TransportError, IOError):
298
"""A get() was issued for a file that doesn't exist."""
300
# XXX: Is multiple inheritance for exceptions really needed?
303
return 'no such file: ' + self.msg
305
def __init__(self, msg=None, orig_error=None):
307
TransportError.__init__(self, msg=msg, orig_error=orig_error)
308
IOError.__init__(self, errno.ENOENT, self.msg)
310
class FileExists(TransportError, OSError):
311
"""An operation was attempted, which would overwrite an entry,
312
but overwritting is not supported.
314
mkdir() can throw this, but put() just overwites existing files.
316
# XXX: Is multiple inheritance for exceptions really needed?
317
def __init__(self, msg=None, orig_error=None):
319
TransportError.__init__(self, msg=msg, orig_error=orig_error)
320
OSError.__init__(self, errno.EEXIST, self.msg)
322
class PermissionDenied(TransportError):
323
"""An operation cannot succeed because of a lack of permissions."""
403
326
class ConnectionReset(TransportError):
404
327
"""The connection has been closed."""
408
331
def __init__(self):
409
332
BzrError.__init__(self, "Working tree has conflicts.")
411
class ParseConfigError(BzrError):
412
def __init__(self, errors, filename):
415
message = "Error(s) parsing config file %s:\n%s" % \
416
(filename, ('\n'.join(e.message for e in errors)))
417
BzrError.__init__(self, message)
419
334
class SigningFailed(BzrError):
420
335
def __init__(self, command_line):
421
336
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
424
class WorkingTreeNotRevision(BzrError):
425
def __init__(self, tree):
426
BzrError.__init__(self, "The working tree for %s has changed since"
427
" last commit, but weave merge requires that it be"
428
" unchanged." % tree.basedir)
430
class CantReprocessAndShowBase(BzrNewError):
431
"""Can't reprocess and show base.
432
Reprocessing obscures relationship of conflicting lines to base."""
434
class GraphCycleError(BzrNewError):
435
"""Cycle in graph %(graph)r"""
436
def __init__(self, graph):
437
BzrNewError.__init__(self)
440
class NotConflicted(BzrNewError):
441
"""File %(filename)s is not conflicted."""
442
def __init__(self, filename):
443
BzrNewError.__init__(self)
444
self.filename = filename
446
class MustUseDecorated(Exception):
447
"""A decorating function has requested its original command be used.
449
This should never escape bzr, so does not need to be printable.
452
class MissingText(BzrNewError):
453
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
454
def __init__(self, branch, text_revision, file_id):
456
self.base = branch.base
457
self.text_revision = text_revision
458
self.file_id = file_id