101
106
class BzrCheckError(BzrNewError):
102
107
"""Internal check failed: %(message)s"""
103
109
def __init__(self, message):
110
BzrNewError.__init__(self)
104
111
self.message = message
107
114
class InvalidEntryName(BzrNewError):
108
115
"""Invalid entry name: %(name)s"""
109
116
def __init__(self, name):
117
BzrNewError.__init__(self)
113
121
class InvalidRevisionNumber(BzrNewError):
114
122
"""Invalid revision number %(revno)d"""
115
123
def __init__(self, revno):
124
BzrNewError.__init__(self)
116
125
self.revno = revno
119
128
class InvalidRevisionId(BzrNewError):
120
"""Invalid revision-id"""
129
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
130
def __init__(self, revision_id, branch):
131
BzrNewError.__init__(self)
132
self.revision_id = revision_id
136
class NoWorkingTree(BzrNewError):
137
"""No WorkingTree exists for %s(base)."""
139
def __init__(self, base):
140
BzrNewError.__init__(self)
144
class NotLocalUrl(BzrNewError):
145
"""%s(url) is not a local path."""
147
def __init__(self, url):
148
BzrNewError.__init__(self)
123
152
class BzrCommandError(BzrError):
124
153
# Error from malformed user command
154
# This is being misused as a generic exception
155
# pleae subclass. RBC 20051030
157
# I think it's a waste of effort to differentiate between errors that
158
# are not intended to be caught anyway. UI code need not subclass
159
# BzrCommandError, and non-UI code should not throw a subclass of
160
# BzrCommandError. ADHB 20051211
125
161
def __str__(self):
126
162
return self.args[0]
165
class BzrOptionError(BzrCommandError):
166
"""Some missing or otherwise incorrect option was supplied."""
128
169
class StrictCommitFailed(Exception):
129
170
"""Commit refused because there are unknowns in the tree."""
173
class PathError(BzrNewError):
174
"""Generic path error: %(path)r%(extra)s)"""
175
def __init__(self, path, extra=None):
176
BzrNewError.__init__(self)
179
self.extra = ': ' + str(extra)
184
class NoSuchFile(PathError):
185
"""No such file: %(path)r%(extra)s"""
188
class FileExists(PathError):
189
"""File exists: %(path)r%(extra)s"""
192
class DirectoryNotEmpty(PathError):
193
"""Directory not empty: %(path)r%(extra)s"""
196
class PermissionDenied(PathError):
197
"""Permission denied: %(path)r%(extra)s"""
200
class PathNotChild(BzrNewError):
201
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
202
def __init__(self, path, base, extra=None):
203
BzrNewError.__init__(self)
207
self.extra = ': ' + str(extra)
131
212
class NotBranchError(BzrNewError):
132
213
"""Not a branch: %(path)s"""
133
214
def __init__(self, path):
219
class NoRepositoryPresent(BzrNewError):
220
"""Not repository present: %(path)r"""
221
def __init__(self, bzrdir):
222
BzrNewError.__init__(self)
223
self.path = bzrdir.transport.clone('..').base
226
class FileInWrongBranch(BzrNewError):
227
"""File %(path)s in not in branch %(branch_base)s."""
229
def __init__(self, branch, path):
230
BzrNewError.__init__(self)
232
self.branch_base = branch.base
138
236
class UnsupportedFormatError(BzrError):
139
"""Specified path is a bzr branch that we cannot read."""
237
"""Specified path is a bzr branch that we recognize but cannot read."""
140
238
def __str__(self):
141
239
return 'unsupported branch format: %s' % self.args[0]
242
class UnknownFormatError(BzrError):
243
"""Specified path is a bzr branch whose format we do not recognize."""
245
return 'unknown branch format: %s' % self.args[0]
248
class IncompatibleFormat(BzrNewError):
249
"""Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
251
def __init__(self, format, bzrdir_format):
252
BzrNewError.__init__(self)
254
self.bzrdir = bzrdir_format
144
257
class NotVersionedError(BzrNewError):
145
258
"""%(path)s is not versioned"""
146
259
def __init__(self, path):
158
271
"""Cannot operate on a file because it is a control file."""
161
class LockError(Exception):
274
class LockError(BzrNewError):
275
"""Lock error: %(message)s"""
163
276
# All exceptions from the lock/unlock functions should be from
164
277
# this exception class. They will be translated as necessary. The
165
278
# original exception is available as e.original_error
280
# New code should prefer to raise specific subclasses
281
def __init__(self, message):
282
self.message = message
168
285
class CommitNotPossible(LockError):
169
286
"""A commit was attempted but we do not have a write lock open."""
172
291
class AlreadyCommitted(LockError):
173
292
"""A rollback was requested, but is not able to be accomplished."""
176
297
class ReadOnlyError(LockError):
177
"""A write attempt was made in a read only transaction."""
298
"""A write attempt was made in a read only transaction on %(obj)s"""
299
def __init__(self, obj):
303
class OutSideTransaction(BzrNewError):
304
"""A transaction related operation was attempted after the transaction finished."""
307
class ObjectNotLocked(LockError):
308
"""%(obj)r is not locked"""
309
# this can indicate that any particular object is not locked; see also
310
# LockNotHeld which means that a particular *lock* object is not held by
311
# the caller -- perhaps they should be unified.
312
def __init__(self, obj):
316
class ReadOnlyObjectDirtiedError(ReadOnlyError):
317
"""Cannot change object %(obj)r in read only transaction"""
318
def __init__(self, obj):
322
class UnlockableTransport(LockError):
323
"""Cannot lock: transport is read only: %(transport)s"""
324
def __init__(self, transport):
325
self.transport = transport
328
class LockContention(LockError):
329
"""Could not acquire lock %(lock)s"""
330
# TODO: show full url for lock, combining the transport and relative bits?
331
def __init__(self, lock):
335
class LockBroken(LockError):
336
"""Lock was broken while still open: %(lock)s - check storage consistency!"""
337
def __init__(self, lock):
341
class LockBreakMismatch(LockError):
342
"""Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"""
343
def __init__(self, lock, holder, target):
349
class LockNotHeld(LockError):
350
"""Lock not held: %(lock)s"""
351
def __init__(self, lock):
180
355
class PointlessCommit(BzrNewError):
181
356
"""No changes to commit"""
359
class UpgradeReadonly(BzrNewError):
360
"""Upgrade URL cannot work with readonly URL's."""
363
class UpToDateFormat(BzrNewError):
364
"""The branch format %(format)s is already at the most recent format."""
366
def __init__(self, format):
367
BzrNewError.__init__(self)
372
class StrictCommitFailed(Exception):
373
"""Commit refused because there are unknowns in the tree."""
184
376
class NoSuchRevision(BzrError):
185
377
def __init__(self, branch, revision):
186
378
self.branch = branch
211
403
BzrCommandError.__init__(self, msg)
213
406
class NoCommonAncestor(BzrError):
214
407
def __init__(self, revision_a, revision_b):
215
408
msg = "Revisions have no common ancestor: %s %s." \
216
409
% (revision_a, revision_b)
217
410
BzrError.__init__(self, msg)
219
413
class NoCommonRoot(BzrError):
220
414
def __init__(self, revision_a, revision_b):
221
415
msg = "Revisions are not derived from the same root: %s %s." \
222
416
% (revision_a, revision_b)
223
417
BzrError.__init__(self, msg)
225
class NotAncestor(BzrError):
226
def __init__(self, rev_id, not_ancestor_id):
227
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
229
BzrError.__init__(self, msg)
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)
421
class NotAncestor(BzrError):
422
def __init__(self, rev_id, not_ancestor_id):
423
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
425
BzrError.__init__(self, msg)
427
self.not_ancestor_id = not_ancestor_id
243
430
class InstallFailed(BzrError):
247
434
self.revisions = revisions
250
class AmbiguousBase(BzrError):
251
def __init__(self, bases):
252
msg = "The correct base is unclear, becase %s are all equally close" %\
254
BzrError.__init__(self, msg)
257
437
class NoCommits(BzrError):
258
438
def __init__(self, branch):
259
439
msg = "Branch %s has no commits." % branch
260
440
BzrError.__init__(self, msg)
262
443
class UnlistableStore(BzrError):
263
444
def __init__(self, store):
264
445
BzrError.__init__(self, "Store %s is not listable" % store)
266
449
class UnlistableBranch(BzrError):
267
450
def __init__(self, br):
268
451
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
271
from bzrlib.weave import WeaveError, WeaveParentMismatch
454
class BoundBranchOutOfDate(BzrNewError):
455
"""Bound branch %(branch)s is out of date with master branch %(master)s."""
456
def __init__(self, branch, master):
457
BzrNewError.__init__(self)
462
class CommitToDoubleBoundBranch(BzrNewError):
463
"""Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."""
464
def __init__(self, branch, master, remote):
465
BzrNewError.__init__(self)
471
class OverwriteBoundBranch(BzrNewError):
472
"""Cannot pull --overwrite to a branch which is bound %(branch)s"""
473
def __init__(self, branch):
474
BzrNewError.__init__(self)
478
class BoundBranchConnectionFailure(BzrNewError):
479
"""Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"""
480
def __init__(self, branch, target, error):
481
BzrNewError.__init__(self)
487
class WeaveError(BzrNewError):
488
"""Error in processing weave: %(message)s"""
490
def __init__(self, message=None):
491
BzrNewError.__init__(self)
492
self.message = message
495
class WeaveRevisionAlreadyPresent(WeaveError):
496
"""Revision {%(revision_id)s} already present in %(weave)s"""
497
def __init__(self, revision_id, weave):
499
WeaveError.__init__(self)
500
self.revision_id = revision_id
504
class WeaveRevisionNotPresent(WeaveError):
505
"""Revision {%(revision_id)s} not present in %(weave)s"""
507
def __init__(self, revision_id, weave):
508
WeaveError.__init__(self)
509
self.revision_id = revision_id
513
class WeaveFormatError(WeaveError):
514
"""Weave invariant violated: %(what)s"""
516
def __init__(self, what):
517
WeaveError.__init__(self)
521
class WeaveParentMismatch(WeaveError):
522
"""Parents are mismatched between two revisions."""
525
class WeaveInvalidChecksum(WeaveError):
526
"""Text did not match it's checksum: %(message)s"""
529
class WeaveTextDiffers(WeaveError):
530
"""Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
532
def __init__(self, revision_id, weave_a, weave_b):
533
WeaveError.__init__(self)
534
self.revision_id = revision_id
535
self.weave_a = weave_a
536
self.weave_b = weave_b
539
class WeaveTextDiffers(WeaveError):
540
"""Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
542
def __init__(self, revision_id, weave_a, weave_b):
543
WeaveError.__init__(self)
544
self.revision_id = revision_id
545
self.weave_a = weave_a
546
self.weave_b = weave_b
549
class VersionedFileError(BzrNewError):
550
"""Versioned file error."""
553
class RevisionNotPresent(VersionedFileError):
554
"""Revision {%(revision_id)s} not present in %(file_id)s."""
556
def __init__(self, revision_id, file_id):
557
VersionedFileError.__init__(self)
558
self.revision_id = revision_id
559
self.file_id = file_id
562
class RevisionAlreadyPresent(VersionedFileError):
563
"""Revision {%(revision_id)s} already present in %(file_id)s."""
565
def __init__(self, revision_id, file_id):
566
VersionedFileError.__init__(self)
567
self.revision_id = revision_id
568
self.file_id = file_id
571
class KnitError(BzrNewError):
575
class KnitHeaderError(KnitError):
576
"""Knit header error: %(badline)r unexpected"""
578
def __init__(self, badline):
579
KnitError.__init__(self)
580
self.badline = badline
583
class KnitCorrupt(KnitError):
584
"""Knit %(filename)s corrupt: %(how)s"""
586
def __init__(self, filename, how):
587
KnitError.__init__(self)
588
self.filename = filename
592
class NoSuchExportFormat(BzrNewError):
593
"""Export format %(format)r not supported"""
594
def __init__(self, format):
595
BzrNewError.__init__(self)
273
599
class TransportError(BzrError):
274
600
"""All errors thrown by Transport implementations should derive
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."""
619
class ConnectionError(TransportError):
620
"""A connection problem prevents file retrieval.
621
This does not indicate whether the file exists or not; it indicates that a
622
precondition for requesting the file was not met.
624
def __init__(self, msg=None, orig_error=None):
625
TransportError.__init__(self, msg=msg, orig_error=orig_error)
326
628
class ConnectionReset(TransportError):
327
629
"""The connection has been closed."""
330
633
class ConflictsInTree(BzrError):
331
634
def __init__(self):
332
635
BzrError.__init__(self, "Working tree has conflicts.")
638
class ParseConfigError(BzrError):
639
def __init__(self, errors, filename):
642
message = "Error(s) parsing config file %s:\n%s" % \
643
(filename, ('\n'.join(e.message for e in errors)))
644
BzrError.__init__(self, message)
334
647
class SigningFailed(BzrError):
335
648
def __init__(self, command_line):
336
649
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
653
class WorkingTreeNotRevision(BzrError):
654
def __init__(self, tree):
655
BzrError.__init__(self, "The working tree for %s has changed since"
656
" last commit, but weave merge requires that it be"
657
" unchanged." % tree.basedir)
660
class CantReprocessAndShowBase(BzrNewError):
661
"""Can't reprocess and show base.
662
Reprocessing obscures relationship of conflicting lines to base."""
665
class GraphCycleError(BzrNewError):
666
"""Cycle in graph %(graph)r"""
667
def __init__(self, graph):
668
BzrNewError.__init__(self)
672
class NotConflicted(BzrNewError):
673
"""File %(filename)s is not conflicted."""
675
def __init__(self, filename):
676
BzrNewError.__init__(self)
677
self.filename = filename
680
class MustUseDecorated(Exception):
681
"""A decorating function has requested its original command be used.
683
This should never escape bzr, so does not need to be printable.
687
class MissingText(BzrNewError):
688
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
690
def __init__(self, branch, text_revision, file_id):
691
BzrNewError.__init__(self)
693
self.base = branch.base
694
self.text_revision = text_revision
695
self.file_id = file_id
698
class DuplicateKey(BzrNewError):
699
"""Key %(key)s is already present in map"""
702
class MalformedTransform(BzrNewError):
703
"""Tree transform is malformed %(conflicts)r"""
706
class BzrBadParameter(BzrNewError):
707
"""A bad parameter : %(param)s is not usable.
709
This exception should never be thrown, but it is a base class for all
710
parameter-to-function errors.
712
def __init__(self, param):
713
BzrNewError.__init__(self)
717
class BzrBadParameterNotUnicode(BzrBadParameter):
718
"""Parameter %(param)s is neither unicode nor utf8."""
721
class ReusingTransform(BzrNewError):
722
"""Attempt to reuse a transform that has already been applied."""
725
class CantMoveRoot(BzrNewError):
726
"""Moving the root directory is not supported at this time"""
729
class BzrBadParameterNotString(BzrBadParameter):
730
"""Parameter %(param)s is not a string or unicode string."""
733
class BzrBadParameterMissing(BzrBadParameter):
734
"""Parameter $(param)s is required but not present."""
737
class DependencyNotPresent(BzrNewError):
738
"""Unable to import library "%(library)s": %(error)s"""
740
def __init__(self, library, error):
741
BzrNewError.__init__(self, library=library, error=error)
744
class ParamikoNotPresent(DependencyNotPresent):
745
"""Unable to import paramiko (required for sftp support): %(error)s"""
747
def __init__(self, error):
748
DependencyNotPresent.__init__(self, 'paramiko', error)
751
class UninitializableFormat(BzrNewError):
752
"""Format %(format)s cannot be initialised by this version of bzr."""
754
def __init__(self, format):
755
BzrNewError.__init__(self)
759
class NoDiff3(BzrNewError):
760
"""Diff3 is not installed on this machine."""
763
class ExistingLimbo(BzrNewError):
764
"""This tree contains left-over files from a failed operation.
765
Please examine %(limbo_dir)s to see if it contains any files you wish to
766
keep, and delete it when you are done.
768
def __init__(self, limbo_dir):
769
BzrNewError.__init__(self)
770
self.limbo_dir = limbo_dir
773
class ImmortalLimbo(BzrNewError):
774
"""Unable to delete transform temporary directory $(limbo_dir)s.
775
Please examine %(limbo_dir)s to see if it contains any files you wish to
776
keep, and delete it when you are done.
778
def __init__(self, limbo_dir):
779
BzrNewError.__init__(self)
780
self.limbo_dir = limbo_dir
783
class OutOfDateTree(BzrNewError):
784
"""Working tree is out of date, please run 'bzr update'."""
786
def __init__(self, tree):
787
BzrNewError.__init__(self)
791
class MergeModifiedFormatError(BzrNewError):
792
"""Error in merge modified format"""
795
class CorruptRepository(BzrNewError):
796
"""An error has been detected in the repository %(repo_path)s.
797
Please run bzr reconcile on this repository."""
799
def __init__(self, repo):
800
BzrNewError.__init__(self)
801
self.repo_path = repo.bzrdir.root_transport.base
804
class UpgradeRequired(BzrNewError):
805
"""To use this feature you must upgrade your branch at %(path)s."""
807
def __init__(self, path):
808
BzrNewError.__init__(self)
812
class LocalRequiresBoundBranch(BzrNewError):
813
"""Cannot perform local-only commits on unbound branches."""
816
class MissingProgressBarFinish(BzrNewError):
817
"""A nested progress bar was not 'finished' correctly."""