112
101
class BzrCheckError(BzrNewError):
113
102
"""Internal check failed: %(message)s"""
115
103
def __init__(self, message):
116
BzrNewError.__init__(self)
117
104
self.message = message
120
107
class InvalidEntryName(BzrNewError):
121
108
"""Invalid entry name: %(name)s"""
122
109
def __init__(self, name):
123
BzrNewError.__init__(self)
127
113
class InvalidRevisionNumber(BzrNewError):
128
114
"""Invalid revision number %(revno)d"""
129
115
def __init__(self, revno):
130
BzrNewError.__init__(self)
131
116
self.revno = revno
134
119
class InvalidRevisionId(BzrNewError):
135
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
136
def __init__(self, revision_id, branch):
137
# branch can be any string or object with __str__ defined
138
BzrNewError.__init__(self)
139
self.revision_id = revision_id
143
class NoWorkingTree(BzrNewError):
144
"""No WorkingTree exists for %(base)s."""
146
def __init__(self, base):
147
BzrNewError.__init__(self)
151
class NotLocalUrl(BzrNewError):
152
"""%(url)s is not a local path."""
154
def __init__(self, url):
155
BzrNewError.__init__(self)
120
"""Invalid revision-id"""
159
123
class BzrCommandError(BzrError):
160
124
# Error from malformed user command
161
# This is being misused as a generic exception
162
# pleae subclass. RBC 20051030
164
# I think it's a waste of effort to differentiate between errors that
165
# are not intended to be caught anyway. UI code need not subclass
166
# BzrCommandError, and non-UI code should not throw a subclass of
167
# BzrCommandError. ADHB 20051211
168
125
def __str__(self):
169
126
return self.args[0]
172
class BzrOptionError(BzrCommandError):
173
"""Some missing or otherwise incorrect option was supplied."""
176
128
class StrictCommitFailed(Exception):
177
129
"""Commit refused because there are unknowns in the tree."""
180
# XXX: Should be unified with TransportError; they seem to represent the
182
class PathError(BzrNewError):
183
"""Generic path error: %(path)r%(extra)s)"""
185
def __init__(self, path, extra=None):
186
BzrNewError.__init__(self)
189
self.extra = ': ' + str(extra)
194
class NoSuchFile(PathError):
195
"""No such file: %(path)r%(extra)s"""
198
class FileExists(PathError):
199
"""File exists: %(path)r%(extra)s"""
202
class DirectoryNotEmpty(PathError):
203
"""Directory not empty: %(path)r%(extra)s"""
206
class ResourceBusy(PathError):
207
"""Device or resource busy: %(path)r%(extra)s"""
210
class PermissionDenied(PathError):
211
"""Permission denied: %(path)r%(extra)s"""
214
class PathNotChild(BzrNewError):
215
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
216
def __init__(self, path, base, extra=None):
217
BzrNewError.__init__(self)
221
self.extra = ': ' + str(extra)
226
class NotBranchError(PathError):
131
class NotBranchError(BzrNewError):
227
132
"""Not a branch: %(path)s"""
230
class AlreadyBranchError(PathError):
231
"""Already a branch: %(path)s."""
234
class BranchExistsWithoutWorkingTree(PathError):
235
"""Directory contains a branch, but no working tree \
236
(use bzr checkout if you wish to build a working tree): %(path)s"""
239
class NoRepositoryPresent(BzrNewError):
240
"""No repository present: %(path)r"""
241
def __init__(self, bzrdir):
242
BzrNewError.__init__(self)
243
self.path = bzrdir.transport.clone('..').base
246
class FileInWrongBranch(BzrNewError):
247
"""File %(path)s in not in branch %(branch_base)s."""
249
def __init__(self, branch, path):
250
BzrNewError.__init__(self)
252
self.branch_base = branch.base
133
def __init__(self, path):
134
BzrNewError.__init__(self)
256
138
class UnsupportedFormatError(BzrError):
257
"""Specified path is a bzr branch that we recognize but cannot read."""
139
"""Specified path is a bzr branch that we cannot read."""
258
140
def __str__(self):
259
141
return 'unsupported branch format: %s' % self.args[0]
262
class UnknownFormatError(BzrError):
263
"""Specified path is a bzr branch whose format we do not recognize."""
265
return 'unknown branch format: %s' % self.args[0]
268
class IncompatibleFormat(BzrNewError):
269
"""Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
271
def __init__(self, format, bzrdir_format):
272
BzrNewError.__init__(self)
274
self.bzrdir = bzrdir_format
277
144
class NotVersionedError(BzrNewError):
278
145
"""%(path)s is not versioned"""
279
146
def __init__(self, path):
316
158
"""Cannot operate on a file because it is a control file."""
319
class LockError(BzrNewError):
320
"""Lock error: %(message)s"""
161
class LockError(Exception):
321
163
# All exceptions from the lock/unlock functions should be from
322
164
# this exception class. They will be translated as necessary. The
323
165
# original exception is available as e.original_error
325
# New code should prefer to raise specific subclasses
326
def __init__(self, message):
327
self.message = message
330
168
class CommitNotPossible(LockError):
331
169
"""A commit was attempted but we do not have a write lock open."""
336
172
class AlreadyCommitted(LockError):
337
173
"""A rollback was requested, but is not able to be accomplished."""
342
176
class ReadOnlyError(LockError):
343
"""A write attempt was made in a read only transaction on %(obj)s"""
344
def __init__(self, obj):
348
class OutSideTransaction(BzrNewError):
349
"""A transaction related operation was attempted after the transaction finished."""
352
class ObjectNotLocked(LockError):
353
"""%(obj)r is not locked"""
354
# this can indicate that any particular object is not locked; see also
355
# LockNotHeld which means that a particular *lock* object is not held by
356
# the caller -- perhaps they should be unified.
357
def __init__(self, obj):
361
class ReadOnlyObjectDirtiedError(ReadOnlyError):
362
"""Cannot change object %(obj)r in read only transaction"""
363
def __init__(self, obj):
367
class UnlockableTransport(LockError):
368
"""Cannot lock: transport is read only: %(transport)s"""
369
def __init__(self, transport):
370
self.transport = transport
373
class LockContention(LockError):
374
"""Could not acquire lock %(lock)s"""
375
# TODO: show full url for lock, combining the transport and relative bits?
376
def __init__(self, lock):
380
class LockBroken(LockError):
381
"""Lock was broken while still open: %(lock)s - check storage consistency!"""
382
def __init__(self, lock):
386
class LockBreakMismatch(LockError):
387
"""Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"""
388
def __init__(self, lock, holder, target):
394
class LockNotHeld(LockError):
395
"""Lock not held: %(lock)s"""
396
def __init__(self, lock):
177
"""A write attempt was made in a read only transaction."""
400
180
class PointlessCommit(BzrNewError):
401
181
"""No changes to commit"""
404
class UpgradeReadonly(BzrNewError):
405
"""Upgrade URL cannot work with readonly URL's."""
408
class UpToDateFormat(BzrNewError):
409
"""The branch format %(format)s is already at the most recent format."""
411
def __init__(self, format):
412
BzrNewError.__init__(self)
417
class StrictCommitFailed(Exception):
418
"""Commit refused because there are unknowns in the tree."""
421
184
class NoSuchRevision(BzrError):
422
185
def __init__(self, branch, revision):
423
186
self.branch = branch
449
211
BzrCommandError.__init__(self, msg)
452
213
class NoCommonAncestor(BzrError):
453
214
def __init__(self, revision_a, revision_b):
454
215
msg = "Revisions have no common ancestor: %s %s." \
455
216
% (revision_a, revision_b)
456
217
BzrError.__init__(self, msg)
459
219
class NoCommonRoot(BzrError):
460
220
def __init__(self, revision_a, revision_b):
461
221
msg = "Revisions are not derived from the same root: %s %s." \
462
222
% (revision_a, revision_b)
463
223
BzrError.__init__(self, msg)
467
class NotAncestor(BzrError):
468
def __init__(self, rev_id, not_ancestor_id):
469
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
471
BzrError.__init__(self, msg)
473
self.not_ancestor_id = not_ancestor_id
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)
476
243
class InstallFailed(BzrError):
483
250
class AmbiguousBase(BzrError):
484
251
def __init__(self, bases):
485
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
487
252
msg = "The correct base is unclear, becase %s are all equally close" %\
489
254
BzrError.__init__(self, msg)
490
255
self.bases = bases
493
257
class NoCommits(BzrError):
494
258
def __init__(self, branch):
495
259
msg = "Branch %s has no commits." % branch
496
260
BzrError.__init__(self, msg)
499
262
class UnlistableStore(BzrError):
500
263
def __init__(self, store):
501
264
BzrError.__init__(self, "Store %s is not listable" % store)
505
266
class UnlistableBranch(BzrError):
506
267
def __init__(self, br):
507
268
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
510
class BoundBranchOutOfDate(BzrNewError):
511
"""Bound branch %(branch)s is out of date with master branch %(master)s."""
512
def __init__(self, branch, master):
513
BzrNewError.__init__(self)
518
class CommitToDoubleBoundBranch(BzrNewError):
519
"""Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."""
520
def __init__(self, branch, master, remote):
521
BzrNewError.__init__(self)
527
class OverwriteBoundBranch(BzrNewError):
528
"""Cannot pull --overwrite to a branch which is bound %(branch)s"""
529
def __init__(self, branch):
530
BzrNewError.__init__(self)
534
class BoundBranchConnectionFailure(BzrNewError):
535
"""Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"""
536
def __init__(self, branch, target, error):
537
BzrNewError.__init__(self)
543
class WeaveError(BzrNewError):
544
"""Error in processing weave: %(message)s"""
546
def __init__(self, message=None):
547
BzrNewError.__init__(self)
548
self.message = message
551
class WeaveRevisionAlreadyPresent(WeaveError):
552
"""Revision {%(revision_id)s} already present in %(weave)s"""
553
def __init__(self, revision_id, weave):
555
WeaveError.__init__(self)
556
self.revision_id = revision_id
560
class WeaveRevisionNotPresent(WeaveError):
561
"""Revision {%(revision_id)s} not present in %(weave)s"""
563
def __init__(self, revision_id, weave):
564
WeaveError.__init__(self)
565
self.revision_id = revision_id
569
class WeaveFormatError(WeaveError):
570
"""Weave invariant violated: %(what)s"""
572
def __init__(self, what):
573
WeaveError.__init__(self)
577
class WeaveParentMismatch(WeaveError):
578
"""Parents are mismatched between two revisions."""
581
class WeaveInvalidChecksum(WeaveError):
582
"""Text did not match it's checksum: %(message)s"""
585
class WeaveTextDiffers(WeaveError):
586
"""Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
588
def __init__(self, revision_id, weave_a, weave_b):
589
WeaveError.__init__(self)
590
self.revision_id = revision_id
591
self.weave_a = weave_a
592
self.weave_b = weave_b
595
class WeaveTextDiffers(WeaveError):
596
"""Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
598
def __init__(self, revision_id, weave_a, weave_b):
599
WeaveError.__init__(self)
600
self.revision_id = revision_id
601
self.weave_a = weave_a
602
self.weave_b = weave_b
605
class VersionedFileError(BzrNewError):
606
"""Versioned file error."""
609
class RevisionNotPresent(VersionedFileError):
610
"""Revision {%(revision_id)s} not present in %(file_id)s."""
612
def __init__(self, revision_id, file_id):
613
VersionedFileError.__init__(self)
614
self.revision_id = revision_id
615
self.file_id = file_id
618
class RevisionAlreadyPresent(VersionedFileError):
619
"""Revision {%(revision_id)s} already present in %(file_id)s."""
621
def __init__(self, revision_id, file_id):
622
VersionedFileError.__init__(self)
623
self.revision_id = revision_id
624
self.file_id = file_id
627
class KnitError(BzrNewError):
631
class KnitHeaderError(KnitError):
632
"""Knit header error: %(badline)r unexpected"""
634
def __init__(self, badline):
635
KnitError.__init__(self)
636
self.badline = badline
639
class KnitCorrupt(KnitError):
640
"""Knit %(filename)s corrupt: %(how)s"""
642
def __init__(self, filename, how):
643
KnitError.__init__(self)
644
self.filename = filename
648
class NoSuchExportFormat(BzrNewError):
649
"""Export format %(format)r not supported"""
650
def __init__(self, format):
651
BzrNewError.__init__(self)
271
from bzrlib.weave import WeaveError, WeaveParentMismatch
655
273
class TransportError(BzrError):
656
274
"""All errors thrown by Transport implementations should derive
675
class ConnectionError(TransportError):
676
"""A connection problem prevents file retrieval.
677
This does not indicate whether the file exists or not; it indicates that a
678
precondition for requesting the file was not met.
680
def __init__(self, msg=None, orig_error=None):
681
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."""
684
326
class ConnectionReset(TransportError):
685
327
"""The connection has been closed."""
689
330
class ConflictsInTree(BzrError):
690
331
def __init__(self):
691
332
BzrError.__init__(self, "Working tree has conflicts.")
694
class ParseConfigError(BzrError):
695
def __init__(self, errors, filename):
698
message = "Error(s) parsing config file %s:\n%s" % \
699
(filename, ('\n'.join(e.message for e in errors)))
700
BzrError.__init__(self, message)
703
334
class SigningFailed(BzrError):
704
335
def __init__(self, command_line):
705
336
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
709
class WorkingTreeNotRevision(BzrError):
710
def __init__(self, tree):
711
BzrError.__init__(self, "The working tree for %s has changed since"
712
" last commit, but weave merge requires that it be"
713
" unchanged." % tree.basedir)
716
class CantReprocessAndShowBase(BzrNewError):
717
"""Can't reprocess and show base.
718
Reprocessing obscures relationship of conflicting lines to base."""
721
class GraphCycleError(BzrNewError):
722
"""Cycle in graph %(graph)r"""
723
def __init__(self, graph):
724
BzrNewError.__init__(self)
728
class NotConflicted(BzrNewError):
729
"""File %(filename)s is not conflicted."""
731
def __init__(self, filename):
732
BzrNewError.__init__(self)
733
self.filename = filename
736
class MustUseDecorated(Exception):
737
"""A decorating function has requested its original command be used.
739
This should never escape bzr, so does not need to be printable.
743
class MissingText(BzrNewError):
744
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
746
def __init__(self, branch, text_revision, file_id):
747
BzrNewError.__init__(self)
749
self.base = branch.base
750
self.text_revision = text_revision
751
self.file_id = file_id
754
class DuplicateKey(BzrNewError):
755
"""Key %(key)s is already present in map"""
758
class MalformedTransform(BzrNewError):
759
"""Tree transform is malformed %(conflicts)r"""
762
class BzrBadParameter(BzrNewError):
763
"""A bad parameter : %(param)s is not usable.
765
This exception should never be thrown, but it is a base class for all
766
parameter-to-function errors.
768
def __init__(self, param):
769
BzrNewError.__init__(self)
773
class BzrBadParameterNotUnicode(BzrBadParameter):
774
"""Parameter %(param)s is neither unicode nor utf8."""
777
class ReusingTransform(BzrNewError):
778
"""Attempt to reuse a transform that has already been applied."""
781
class CantMoveRoot(BzrNewError):
782
"""Moving the root directory is not supported at this time"""
785
class BzrBadParameterNotString(BzrBadParameter):
786
"""Parameter %(param)s is not a string or unicode string."""
789
class BzrBadParameterMissing(BzrBadParameter):
790
"""Parameter $(param)s is required but not present."""
793
class BzrBadParameterUnicode(BzrBadParameter):
794
"""Parameter %(param)s is unicode but only byte-strings are permitted."""
797
class BzrBadParameterContainsNewline(BzrBadParameter):
798
"""Parameter %(param)s contains a newline."""
801
class DependencyNotPresent(BzrNewError):
802
"""Unable to import library "%(library)s": %(error)s"""
804
def __init__(self, library, error):
805
BzrNewError.__init__(self, library=library, error=error)
808
class ParamikoNotPresent(DependencyNotPresent):
809
"""Unable to import paramiko (required for sftp support): %(error)s"""
811
def __init__(self, error):
812
DependencyNotPresent.__init__(self, 'paramiko', error)
815
class UninitializableFormat(BzrNewError):
816
"""Format %(format)s cannot be initialised by this version of bzr."""
818
def __init__(self, format):
819
BzrNewError.__init__(self)
823
class NoDiff3(BzrNewError):
824
"""Diff3 is not installed on this machine."""
827
class ExistingLimbo(BzrNewError):
828
"""This tree contains left-over files from a failed operation.
829
Please examine %(limbo_dir)s to see if it contains any files you wish to
830
keep, and delete it when you are done.
832
def __init__(self, limbo_dir):
833
BzrNewError.__init__(self)
834
self.limbo_dir = limbo_dir
837
class ImmortalLimbo(BzrNewError):
838
"""Unable to delete transform temporary directory $(limbo_dir)s.
839
Please examine %(limbo_dir)s to see if it contains any files you wish to
840
keep, and delete it when you are done.
842
def __init__(self, limbo_dir):
843
BzrNewError.__init__(self)
844
self.limbo_dir = limbo_dir
847
class OutOfDateTree(BzrNewError):
848
"""Working tree is out of date, please run 'bzr update'."""
850
def __init__(self, tree):
851
BzrNewError.__init__(self)
855
class MergeModifiedFormatError(BzrNewError):
856
"""Error in merge modified format"""
859
class ConflictFormatError(BzrNewError):
860
"""Format error in conflict listings"""
863
class CorruptRepository(BzrNewError):
864
"""An error has been detected in the repository %(repo_path)s.
865
Please run bzr reconcile on this repository."""
867
def __init__(self, repo):
868
BzrNewError.__init__(self)
869
self.repo_path = repo.bzrdir.root_transport.base
872
class UpgradeRequired(BzrNewError):
873
"""To use this feature you must upgrade your branch at %(path)s."""
875
def __init__(self, path):
876
BzrNewError.__init__(self)
880
class LocalRequiresBoundBranch(BzrNewError):
881
"""Cannot perform local-only commits on unbound branches."""
884
class MissingProgressBarFinish(BzrNewError):
885
"""A nested progress bar was not 'finished' correctly."""
888
class UnsupportedOperation(BzrNewError):
889
"""The method %(mname)s is not supported on objects of type %(tname)s."""
890
def __init__(self, method, method_self):
892
self.mname = method.__name__
893
self.tname = type(method_self).__name__
896
class BinaryFile(BzrNewError):
897
"""File is binary but should be text."""
900
class IllegalPath(BzrNewError):
901
"""The path %(path)s is not permitted on this platform"""
903
def __init__(self, path):
904
BzrNewError.__init__(self)