85
39
# constructed to make sure it will succeed. But that says nothing about
86
40
# exceptions that are never raised.
88
# TODO: Convert all the other error classes here to BzrNewError, and eliminate
91
# TODO: The pattern (from hct) of using classes docstrings as message
92
# templates is cute but maybe not such a great idea - perhaps should have a
93
# separate static message_template.
42
# TODO: selftest assertRaises should probably also check that every error
43
# raised can be formatted as a string successfully, and without giving
96
47
class BzrError(StandardError):
49
Base class for errors raised by bzrlib.
51
:cvar internal_error: if True this was probably caused by a bzr bug and
52
should be displayed with a traceback; if False (or absent) this was
53
probably a user or environment error and they don't need the gory details.
54
(That can be overridden by -Derror on the command line.)
56
:cvar _fmt: Format string to display the error; this is expanded
57
by the instance's dict.
60
internal_error = False
62
def __init__(self, msg=None, **kwds):
63
"""Construct a new BzrError.
65
There are two alternative forms for constructing these objects.
66
Either a preformatted string may be passed, or a set of named
67
arguments can be given. The first is for generic "user" errors which
68
are not intended to be caught and so do not need a specific subclass.
69
The second case is for use with subclasses that provide a _fmt format
70
string to print the arguments.
72
Keyword arguments are taken as parameters to the error, which can
73
be inserted into the format string template. It's recommended
74
that subclasses override the __init__ method to require specific
77
:param msg: If given, this is the literal complete text for the error,
78
not subject to expansion.
80
StandardError.__init__(self)
82
# I was going to deprecate this, but it actually turns out to be
83
# quite handy - mbp 20061103.
84
self._preformatted_string = msg
86
self._preformatted_string = None
87
for key, value in kwds.items():
88
setattr(self, key, value)
100
90
def __str__(self):
101
# XXX: Should we show the exception class in
102
# exceptions that don't provide their own message?
103
# maybe it should be done at a higher level
104
## n = self.__class__.__name__ + ': '
106
if len(self.args) == 1:
107
return str(self.args[0])
108
elif len(self.args) == 2:
109
# further explanation or suggestions
111
return n + '\n '.join([self.args[0]] + self.args[1])
113
return n + "%r" % self
115
return n + `self.args`
91
s = getattr(self, '_preformatted_string', None)
93
# contains a preformatted message; must be cast to plain str
96
fmt = self._get_format_string()
98
s = fmt % self.__dict__
99
# __str__() should always return a 'str' object
100
# never a 'unicode' object.
101
if isinstance(s, unicode):
102
return s.encode('utf8')
104
except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
105
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
106
% (self.__class__.__name__,
108
getattr(self, '_fmt', None),
111
def _get_format_string(self):
112
"""Return format string for this exception or None"""
113
fmt = getattr(self, '_fmt', None)
116
fmt = getattr(self, '__doc__', None)
118
symbol_versioning.warn("%s uses its docstring as a format, "
119
"it should use _fmt instead" % self.__class__.__name__,
122
return 'Unprintable exception %s: dict=%r, fmt=%r' \
123
% (self.__class__.__name__,
125
getattr(self, '_fmt', None),
118
129
class BzrNewError(BzrError):
130
"""Deprecated error base class."""
120
131
# base classes should override the docstring with their human-
121
132
# readable explanation
123
134
def __init__(self, *args, **kwds):
124
# XXX: Use the underlying BzrError to always generate the args attribute
125
# if it doesn't exist. We can't use super here, because exceptions are
126
# old-style classes in python2.4 (but new in 2.5). --bmc, 20060426
135
# XXX: Use the underlying BzrError to always generate the args
136
# attribute if it doesn't exist. We can't use super here, because
137
# exceptions are old-style classes in python2.4 (but new in 2.5).
139
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
140
'please convert %s to use BzrError instead'
141
% self.__class__.__name__,
127
144
BzrError.__init__(self, *args)
128
145
for key, value in kwds.items():
129
146
setattr(self, key, value)
137
154
return s.encode('utf8')
139
156
except (TypeError, NameError, ValueError, KeyError), e:
140
return 'Unprintable exception %s(%r): %s' \
157
return 'Unprintable exception %s(%r): %r' \
141
158
% (self.__class__.__name__,
142
self.__dict__, str(e))
145
class AlreadyBuilding(BzrNewError):
146
"""The tree builder is already building a tree."""
149
class BzrCheckError(BzrNewError):
150
"""Internal check failed: %(message)s"""
152
is_user_error = False
162
class AlreadyBuilding(BzrError):
164
_fmt = "The tree builder is already building a tree."
167
class BzrCheckError(BzrError):
169
_fmt = "Internal check failed: %(message)s"
171
internal_error = True
154
173
def __init__(self, message):
155
BzrNewError.__init__(self)
174
BzrError.__init__(self)
156
175
self.message = message
159
class InvalidEntryName(BzrNewError):
160
"""Invalid entry name: %(name)s"""
162
is_user_error = False
178
class DisabledMethod(BzrError):
180
_fmt = "The smart server method '%(class_name)s' is disabled."
182
internal_error = True
184
def __init__(self, class_name):
185
BzrError.__init__(self)
186
self.class_name = class_name
189
class IncompatibleAPI(BzrError):
191
_fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
192
'It supports versions "%(minimum)s" to "%(current)s".'
194
def __init__(self, api, wanted, minimum, current):
197
self.minimum = minimum
198
self.current = current
201
class InvalidEntryName(BzrError):
203
_fmt = "Invalid entry name: %(name)s"
205
internal_error = True
164
207
def __init__(self, name):
165
BzrNewError.__init__(self)
208
BzrError.__init__(self)
169
class InvalidRevisionNumber(BzrNewError):
170
"""Invalid revision number %(revno)d"""
212
class InvalidRevisionNumber(BzrError):
214
_fmt = "Invalid revision number %(revno)s"
171
216
def __init__(self, revno):
172
BzrNewError.__init__(self)
217
BzrError.__init__(self)
173
218
self.revno = revno
176
class InvalidRevisionId(BzrNewError):
177
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
221
class InvalidRevisionId(BzrError):
223
_fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
179
225
def __init__(self, revision_id, branch):
180
226
# branch can be any string or object with __str__ defined
181
BzrNewError.__init__(self)
227
BzrError.__init__(self)
182
228
self.revision_id = revision_id
183
229
self.branch = branch
186
class NoSuchId(BzrNewError):
187
"""The file id %(file_id)s is not present in the tree %(tree)s."""
231
class ReservedId(BzrError):
233
_fmt = "Reserved revision-id {%(revision_id)s}"
235
def __init__(self, revision_id):
236
self.revision_id = revision_id
239
class NoHelpTopic(BzrError):
241
_fmt = ("No help could be found for '%(topic)s'. "
242
"Please use 'bzr help topics' to obtain a list of topics.")
244
def __init__(self, topic):
248
class NoSuchId(BzrError):
250
_fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
189
252
def __init__(self, tree, file_id):
190
BzrNewError.__init__(self)
253
BzrError.__init__(self)
191
254
self.file_id = file_id
195
class NoWorkingTree(BzrNewError):
196
"""No WorkingTree exists for %(base)s."""
258
class InventoryModified(BzrError):
260
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
261
" so a clean inventory cannot be read without data loss.")
263
internal_error = True
265
def __init__(self, tree):
269
class NoWorkingTree(BzrError):
271
_fmt = "No WorkingTree exists for %(base)s."
198
273
def __init__(self, base):
199
BzrNewError.__init__(self)
274
BzrError.__init__(self)
203
class NotBuilding(BzrNewError):
204
"""Not currently building a tree."""
207
class NotLocalUrl(BzrNewError):
208
"""%(url)s is not a local path."""
278
class NotBuilding(BzrError):
280
_fmt = "Not currently building a tree."
283
class NotLocalUrl(BzrError):
285
_fmt = "%(url)s is not a local path."
210
287
def __init__(self, url):
211
BzrNewError.__init__(self)
215
class BzrCommandError(BzrNewError):
291
class WorkingTreeAlreadyPopulated(BzrError):
293
_fmt = """Working tree already populated in %(base)s"""
295
internal_error = True
297
def __init__(self, base):
300
class BzrCommandError(BzrError):
216
301
"""Error from user command"""
303
internal_error = False
220
305
# Error from malformed user command; please avoid raising this as a
221
306
# generic exception not caused by user input.
367
546
class InaccessibleParent(PathError):
368
"""Parent not accessible given base %(base)s and relative path %(path)s"""
548
_fmt = ("Parent not accessible given base %(base)s and"
549
" relative path %(path)s")
370
551
def __init__(self, path, base):
371
552
PathError.__init__(self, path)
375
class NoRepositoryPresent(BzrNewError):
376
"""No repository present: %(path)r"""
556
class NoRepositoryPresent(BzrError):
558
_fmt = "No repository present: %(path)r"
377
559
def __init__(self, bzrdir):
378
BzrNewError.__init__(self)
560
BzrError.__init__(self)
379
561
self.path = bzrdir.transport.clone('..').base
382
class FileInWrongBranch(BzrNewError):
383
"""File %(path)s in not in branch %(branch_base)s."""
564
class FileInWrongBranch(BzrError):
566
_fmt = "File %(path)s in not in branch %(branch_base)s."
385
568
def __init__(self, branch, path):
386
BzrNewError.__init__(self)
569
BzrError.__init__(self)
387
570
self.branch = branch
388
571
self.branch_base = branch.base
392
class UnsupportedFormatError(BzrNewError):
393
"""Unsupported branch format: %(format)s"""
396
class UnknownFormatError(BzrNewError):
397
"""Unknown branch format: %(format)r"""
400
class IncompatibleFormat(BzrNewError):
401
"""Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
575
class UnsupportedFormatError(BzrError):
577
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
580
class UnknownFormatError(BzrError):
582
_fmt = "Unknown branch format: %(format)r"
585
class IncompatibleFormat(BzrError):
587
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
403
589
def __init__(self, format, bzrdir_format):
404
BzrNewError.__init__(self)
590
BzrError.__init__(self)
405
591
self.format = format
406
592
self.bzrdir = bzrdir_format
409
class IncompatibleRevision(BzrNewError):
410
"""Revision is not compatible with %(repo_format)s"""
595
class IncompatibleRepositories(BzrError):
597
_fmt = "Repository %(target)s is not compatible with repository"\
600
def __init__(self, source, target):
601
BzrError.__init__(self, target=target, source=source)
604
class IncompatibleRevision(BzrError):
606
_fmt = "Revision is not compatible with %(repo_format)s"
412
608
def __init__(self, repo_format):
413
BzrNewError.__init__(self)
609
BzrError.__init__(self)
414
610
self.repo_format = repo_format
417
class NotVersionedError(BzrNewError):
418
"""%(path)s is not versioned"""
419
def __init__(self, path):
420
BzrNewError.__init__(self)
424
class PathsNotVersionedError(BzrNewError):
425
# used when reporting several paths are not versioned
426
"""Path(s) are not versioned: %(paths_as_string)s"""
613
class AlreadyVersionedError(BzrError):
614
"""Used when a path is expected not to be versioned, but it is."""
616
_fmt = "%(context_info)s%(path)s is already versioned"
618
def __init__(self, path, context_info=None):
619
"""Construct a new AlreadyVersionedError.
621
:param path: This is the path which is versioned,
622
which should be in a user friendly form.
623
:param context_info: If given, this is information about the context,
624
which could explain why this is expected to not be versioned.
626
BzrError.__init__(self)
628
if context_info is None:
629
self.context_info = ''
631
self.context_info = context_info + ". "
634
class NotVersionedError(BzrError):
635
"""Used when a path is expected to be versioned, but it is not."""
637
_fmt = "%(context_info)s%(path)s is not versioned"
639
def __init__(self, path, context_info=None):
640
"""Construct a new NotVersionedError.
642
:param path: This is the path which is not versioned,
643
which should be in a user friendly form.
644
:param context_info: If given, this is information about the context,
645
which could explain why this is expected to be versioned.
647
BzrError.__init__(self)
649
if context_info is None:
650
self.context_info = ''
652
self.context_info = context_info + ". "
655
class PathsNotVersionedError(BzrError):
656
"""Used when reporting several paths which are not versioned"""
658
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
428
660
def __init__(self, paths):
429
661
from bzrlib.osutils import quotefn
430
BzrNewError.__init__(self)
662
BzrError.__init__(self)
431
663
self.paths = paths
432
664
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
435
class PathsDoNotExist(BzrNewError):
436
"""Path(s) do not exist: %(paths_as_string)s"""
667
class PathsDoNotExist(BzrError):
669
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
438
671
# used when reporting that paths are neither versioned nor in the working
441
def __init__(self, paths):
674
def __init__(self, paths, extra=None):
442
675
# circular import
443
676
from bzrlib.osutils import quotefn
444
BzrNewError.__init__(self)
677
BzrError.__init__(self)
445
678
self.paths = paths
446
679
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
449
class BadFileKindError(BzrNewError):
450
"""Cannot operate on %(filename)s of unsupported kind %(kind)s"""
453
class ForbiddenControlFileError(BzrNewError):
454
"""Cannot operate on %(filename)s because it is a control file"""
457
class LockError(BzrNewError):
458
"""Lock error: %(message)s"""
681
self.extra = ': ' + str(extra)
686
class BadFileKindError(BzrError):
688
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
690
def __init__(self, filename, kind):
691
BzrError.__init__(self, filename=filename, kind=kind)
694
class ForbiddenControlFileError(BzrError):
696
_fmt = "Cannot operate on %(filename)s because it is a control file"
699
class LockError(BzrError):
701
_fmt = "Lock error: %(msg)s"
703
internal_error = True
459
705
# All exceptions from the lock/unlock functions should be from
460
706
# this exception class. They will be translated as necessary. The
461
707
# original exception is available as e.original_error
463
709
# New code should prefer to raise specific subclasses
464
710
def __init__(self, message):
465
self.message = message
711
# Python 2.5 uses a slot for StandardError.message,
712
# so use a different variable name
713
# so it is exposed in self.__dict__
717
class LockActive(LockError):
719
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
721
internal_error = False
723
def __init__(self, lock_description):
724
self.lock_description = lock_description
468
727
class CommitNotPossible(LockError):
469
"""A commit was attempted but we do not have a write lock open."""
729
_fmt = "A commit was attempted but we do not have a write lock open."
470
731
def __init__(self):
474
735
class AlreadyCommitted(LockError):
475
"""A rollback was requested, but is not able to be accomplished."""
737
_fmt = "A rollback was requested, but is not able to be accomplished."
476
739
def __init__(self):
480
743
class ReadOnlyError(LockError):
481
"""A write attempt was made in a read only transaction on %(obj)s"""
745
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
747
# TODO: There should also be an error indicating that you need a write
748
# lock and don't have any lock at all... mbp 20070226
482
750
def __init__(self, obj):
486
class OutSideTransaction(BzrNewError):
487
"""A transaction related operation was attempted after the transaction finished."""
754
class ReadOnlyLockError(LockError):
756
_fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
758
def __init__(self, fname, msg):
759
LockError.__init__(self, '')
764
class OutSideTransaction(BzrError):
766
_fmt = ("A transaction related operation was attempted after"
767
" the transaction finished.")
490
770
class ObjectNotLocked(LockError):
491
"""%(obj)r is not locked"""
493
is_user_error = False
772
_fmt = "%(obj)r is not locked"
495
774
# this can indicate that any particular object is not locked; see also
496
775
# LockNotHeld which means that a particular *lock* object is not held by
535
833
class LockNotHeld(LockError):
536
"""Lock not held: %(lock)s"""
835
_fmt = "Lock not held: %(lock)s"
837
internal_error = False
537
839
def __init__(self, lock):
541
class PointlessCommit(BzrNewError):
542
"""No changes to commit"""
545
class UpgradeReadonly(BzrNewError):
546
"""Upgrade URL cannot work with readonly URL's."""
549
class UpToDateFormat(BzrNewError):
550
"""The branch format %(format)s is already at the most recent format."""
843
class TokenLockingNotSupported(LockError):
845
_fmt = "The object %(obj)s does not support token specifying a token when locking."
847
internal_error = True
849
def __init__(self, obj):
853
class TokenMismatch(LockBroken):
855
_fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
857
internal_error = True
859
def __init__(self, given_token, lock_token):
860
self.given_token = given_token
861
self.lock_token = lock_token
864
class PointlessCommit(BzrError):
866
_fmt = "No changes to commit"
869
class CannotCommitSelectedFileMerge(BzrError):
871
_fmt = 'Selected-file commit of merges is not supported yet:'\
872
' files %(files_str)s'
874
def __init__(self, files):
875
files_str = ', '.join(files)
876
BzrError.__init__(self, files=files, files_str=files_str)
879
class UpgradeReadonly(BzrError):
881
_fmt = "Upgrade URL cannot work with readonly URLs."
884
class UpToDateFormat(BzrError):
886
_fmt = "The branch format %(format)s is already at the most recent format."
552
888
def __init__(self, format):
553
BzrNewError.__init__(self)
889
BzrError.__init__(self)
554
890
self.format = format
557
893
class StrictCommitFailed(Exception):
558
"""Commit refused because there are unknowns in the tree."""
561
class NoSuchRevision(BzrNewError):
562
"""Branch %(branch)s has no revision %(revision)s"""
564
is_user_error = False
895
_fmt = "Commit refused because there are unknowns in the tree."
898
class NoSuchRevision(BzrError):
900
_fmt = "Branch %(branch)s has no revision %(revision)s"
902
internal_error = True
566
904
def __init__(self, branch, revision):
567
BzrNewError.__init__(self, branch=branch, revision=revision)
570
class NoSuchRevisionSpec(BzrNewError):
571
"""No namespace registered for string: %(spec)r"""
905
BzrError.__init__(self, branch=branch, revision=revision)
908
class NotLeftParentDescendant(BzrError):
910
_fmt = ("Revision %(old_revision)s is not the left parent of"
911
" %(new_revision)s, but branch %(branch_location)s expects this")
913
internal_error = True
915
def __init__(self, branch, old_revision, new_revision):
916
BzrError.__init__(self, branch_location=branch.base,
917
old_revision=old_revision,
918
new_revision=new_revision)
921
class NoSuchRevisionSpec(BzrError):
923
_fmt = "No namespace registered for string: %(spec)r"
573
925
def __init__(self, spec):
574
BzrNewError.__init__(self, spec=spec)
577
class InvalidRevisionSpec(BzrNewError):
578
"""Requested revision: '%(spec)s' does not exist in branch:
579
%(branch)s%(extra)s"""
926
BzrError.__init__(self, spec=spec)
929
class NoSuchRevisionInTree(NoSuchRevision):
930
"""When using Tree.revision_tree, and the revision is not accessible."""
932
_fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
934
def __init__(self, tree, revision_id):
935
BzrError.__init__(self)
937
self.revision_id = revision_id
940
class InvalidRevisionSpec(BzrError):
942
_fmt = ("Requested revision: %(spec)r does not exist in branch:"
943
" %(branch)s%(extra)s")
581
945
def __init__(self, spec, branch, extra=None):
582
BzrNewError.__init__(self, branch=branch, spec=spec)
946
BzrError.__init__(self, branch=branch, spec=spec)
584
948
self.extra = '\n' + str(extra)
621
1009
class NoCommonRoot(BzrError):
1011
_fmt = ("Revisions are not derived from the same root: "
1012
"%(revision_a)s %(revision_b)s.")
622
1014
def __init__(self, revision_a, revision_b):
623
msg = "Revisions are not derived from the same root: %s %s." \
624
% (revision_a, revision_b)
625
BzrError.__init__(self, msg)
1015
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
629
1018
class NotAncestor(BzrError):
1020
_fmt = "Revision %(rev_id)s is not an ancestor of %(not_ancestor_id)s"
630
1022
def __init__(self, rev_id, not_ancestor_id):
631
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
633
BzrError.__init__(self, msg)
635
self.not_ancestor_id = not_ancestor_id
1023
BzrError.__init__(self, rev_id=rev_id,
1024
not_ancestor_id=not_ancestor_id)
638
1027
class InstallFailed(BzrError):
639
1029
def __init__(self, revisions):
640
msg = "Could not install revisions:\n%s" % " ,".join(revisions)
1030
revision_str = ", ".join(str(r) for r in revisions)
1031
msg = "Could not install revisions:\n%s" % revision_str
641
1032
BzrError.__init__(self, msg)
642
1033
self.revisions = revisions
645
1036
class AmbiguousBase(BzrError):
646
1038
def __init__(self, bases):
647
1039
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
648
1040
DeprecationWarning)
649
msg = "The correct base is unclear, because %s are all equally close" %\
1041
msg = ("The correct base is unclear, because %s are all equally close"
651
1043
BzrError.__init__(self, msg)
652
1044
self.bases = bases
655
class NoCommits(BzrNewError):
656
"""Branch %(branch)s has no commits."""
1047
class NoCommits(BzrError):
1049
_fmt = "Branch %(branch)s has no commits."
658
1051
def __init__(self, branch):
659
BzrNewError.__init__(self, branch=branch)
1052
BzrError.__init__(self, branch=branch)
662
1055
class UnlistableStore(BzrError):
663
1057
def __init__(self, store):
664
1058
BzrError.__init__(self, "Store %s is not listable" % store)
668
1062
class UnlistableBranch(BzrError):
669
1064
def __init__(self, br):
670
1065
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
673
class BoundBranchOutOfDate(BzrNewError):
674
"""Bound branch %(branch)s is out of date with master branch %(master)s."""
1068
class BoundBranchOutOfDate(BzrError):
1070
_fmt = ("Bound branch %(branch)s is out of date"
1071
" with master branch %(master)s.")
675
1073
def __init__(self, branch, master):
676
BzrNewError.__init__(self)
1074
BzrError.__init__(self)
677
1075
self.branch = branch
678
1076
self.master = master
681
class CommitToDoubleBoundBranch(BzrNewError):
682
"""Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."""
1079
class CommitToDoubleBoundBranch(BzrError):
1081
_fmt = ("Cannot commit to branch %(branch)s."
1082
" It is bound to %(master)s, which is bound to %(remote)s.")
683
1084
def __init__(self, branch, master, remote):
684
BzrNewError.__init__(self)
1085
BzrError.__init__(self)
685
1086
self.branch = branch
686
1087
self.master = master
687
1088
self.remote = remote
690
class OverwriteBoundBranch(BzrNewError):
691
"""Cannot pull --overwrite to a branch which is bound %(branch)s"""
1091
class OverwriteBoundBranch(BzrError):
1093
_fmt = "Cannot pull --overwrite to a branch which is bound %(branch)s"
692
1095
def __init__(self, branch):
693
BzrNewError.__init__(self)
1096
BzrError.__init__(self)
694
1097
self.branch = branch
697
class BoundBranchConnectionFailure(BzrNewError):
698
"""Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"""
1100
class BoundBranchConnectionFailure(BzrError):
1102
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1103
" => %(target)s: %(error)s")
699
1105
def __init__(self, branch, target, error):
700
BzrNewError.__init__(self)
1106
BzrError.__init__(self)
701
1107
self.branch = branch
702
1108
self.target = target
703
1109
self.error = error
706
class WeaveError(BzrNewError):
707
"""Error in processing weave: %(message)s"""
1112
class WeaveError(BzrError):
1114
_fmt = "Error in processing weave: %(message)s"
709
1116
def __init__(self, message=None):
710
BzrNewError.__init__(self)
1117
BzrError.__init__(self)
711
1118
self.message = message
714
1121
class WeaveRevisionAlreadyPresent(WeaveError):
715
"""Revision {%(revision_id)s} already present in %(weave)s"""
1123
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
716
1125
def __init__(self, revision_id, weave):
718
1127
WeaveError.__init__(self)
898
1435
BzrError.__init__(self, message)
1438
class NoEmailInUsername(BzrError):
1440
_fmt = "%(username)r does not seem to contain a reasonable email address"
1442
def __init__(self, username):
1443
BzrError.__init__(self)
1444
self.username = username
901
1447
class SigningFailed(BzrError):
1449
_fmt = "Failed to gpg sign data with command %(command_line)r"
902
1451
def __init__(self, command_line):
903
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
1452
BzrError.__init__(self, command_line=command_line)
907
1455
class WorkingTreeNotRevision(BzrError):
1457
_fmt = ("The working tree for %(basedir)s has changed since"
1458
" the last commit, but weave merge requires that it be"
908
1461
def __init__(self, tree):
909
BzrError.__init__(self, "The working tree for %s has changed since"
910
" last commit, but weave merge requires that it be"
911
" unchanged." % tree.basedir)
914
class CantReprocessAndShowBase(BzrNewError):
915
"""Can't reprocess and show base.
916
Reprocessing obscures relationship of conflicting lines to base."""
919
class GraphCycleError(BzrNewError):
920
"""Cycle in graph %(graph)r"""
1462
BzrError.__init__(self, basedir=tree.basedir)
1465
class CantReprocessAndShowBase(BzrError):
1467
_fmt = ("Can't reprocess and show base, because reprocessing obscures "
1468
"the relationship of conflicting lines to the base")
1471
class GraphCycleError(BzrError):
1473
_fmt = "Cycle in graph %(graph)r"
921
1475
def __init__(self, graph):
922
BzrNewError.__init__(self)
1476
BzrError.__init__(self)
923
1477
self.graph = graph
926
class NotConflicted(BzrNewError):
927
"""File %(filename)s is not conflicted."""
1480
class WritingCompleted(BzrError):
1482
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1483
"called upon it - accept bytes may not be called anymore.")
1485
internal_error = True
1487
def __init__(self, request):
1488
self.request = request
1491
class WritingNotComplete(BzrError):
1493
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1494
"called upon it - until the write phase is complete no "
1495
"data may be read.")
1497
internal_error = True
1499
def __init__(self, request):
1500
self.request = request
1503
class NotConflicted(BzrError):
1505
_fmt = "File %(filename)s is not conflicted."
929
1507
def __init__(self, filename):
930
BzrNewError.__init__(self)
1508
BzrError.__init__(self)
931
1509
self.filename = filename
1512
class MediumNotConnected(BzrError):
1514
_fmt = """The medium '%(medium)s' is not connected."""
1516
internal_error = True
1518
def __init__(self, medium):
1519
self.medium = medium
934
1522
class MustUseDecorated(Exception):
935
"""A decorating function has requested its original command be used.
937
This should never escape bzr, so does not need to be printable.
941
class NoBundleFound(BzrNewError):
942
"""No bundle was found in %(filename)s"""
1524
_fmt = "A decorating function has requested its original command be used."
1527
class NoBundleFound(BzrError):
1529
_fmt = "No bundle was found in %(filename)s"
943
1531
def __init__(self, filename):
944
BzrNewError.__init__(self)
1532
BzrError.__init__(self)
945
1533
self.filename = filename
948
class BundleNotSupported(BzrNewError):
949
"""Unable to handle bundle version %(version)s: %(msg)s"""
1536
class BundleNotSupported(BzrError):
1538
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
950
1540
def __init__(self, version, msg):
951
BzrNewError.__init__(self)
1541
BzrError.__init__(self)
952
1542
self.version = version
956
class MissingText(BzrNewError):
957
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
1546
class MissingText(BzrError):
1548
_fmt = ("Branch %(base)s is missing revision"
1549
" %(text_revision)s of %(file_id)s")
959
1551
def __init__(self, branch, text_revision, file_id):
960
BzrNewError.__init__(self)
1552
BzrError.__init__(self)
961
1553
self.branch = branch
962
1554
self.base = branch.base
963
1555
self.text_revision = text_revision
964
1556
self.file_id = file_id
967
class DuplicateKey(BzrNewError):
968
"""Key %(key)s is already present in map"""
971
class MalformedTransform(BzrNewError):
972
"""Tree transform is malformed %(conflicts)r"""
975
class BzrBadParameter(BzrNewError):
976
"""A bad parameter : %(param)s is not usable.
978
This exception should never be thrown, but it is a base class for all
979
parameter-to-function errors.
1559
class DuplicateFileId(BzrError):
1561
_fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1563
def __init__(self, file_id, entry):
1564
BzrError.__init__(self)
1565
self.file_id = file_id
1569
class DuplicateKey(BzrError):
1571
_fmt = "Key %(key)s is already present in map"
1574
class DuplicateHelpPrefix(BzrError):
1576
_fmt = "The prefix %(prefix)s is in the help search path twice."
1578
def __init__(self, prefix):
1579
self.prefix = prefix
1582
class MalformedTransform(BzrError):
1584
_fmt = "Tree transform is malformed %(conflicts)r"
1587
class NoFinalPath(BzrError):
1589
_fmt = ("No final name for trans_id %(trans_id)r\n"
1590
"file-id: %(file_id)r\n"
1591
"root trans-id: %(root_trans_id)r\n")
1593
def __init__(self, trans_id, transform):
1594
self.trans_id = trans_id
1595
self.file_id = transform.final_file_id(trans_id)
1596
self.root_trans_id = transform.root
1599
class BzrBadParameter(BzrError):
1601
_fmt = "Bad parameter: %(param)r"
1603
internal_error = True
1605
# This exception should never be thrown, but it is a base class for all
1606
# parameter-to-function errors.
981
1608
def __init__(self, param):
982
BzrNewError.__init__(self)
1609
BzrError.__init__(self)
983
1610
self.param = param
986
1613
class BzrBadParameterNotUnicode(BzrBadParameter):
987
"""Parameter %(param)s is neither unicode nor utf8."""
990
class ReusingTransform(BzrNewError):
991
"""Attempt to reuse a transform that has already been applied."""
994
class CantMoveRoot(BzrNewError):
995
"""Moving the root directory is not supported at this time"""
1615
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1618
class ReusingTransform(BzrError):
1620
_fmt = "Attempt to reuse a transform that has already been applied."
1623
class CantMoveRoot(BzrError):
1625
_fmt = "Moving the root directory is not supported at this time"
1628
class BzrMoveFailedError(BzrError):
1630
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1632
def __init__(self, from_path='', to_path='', extra=None):
1633
BzrError.__init__(self)
1635
self.extra = ': ' + str(extra)
1639
has_from = len(from_path) > 0
1640
has_to = len(to_path) > 0
1642
self.from_path = osutils.splitpath(from_path)[-1]
1647
self.to_path = osutils.splitpath(to_path)[-1]
1652
if has_from and has_to:
1653
self.operator = " =>"
1655
self.from_path = "from " + from_path
1657
self.operator = "to"
1659
self.operator = "file"
1662
class BzrRenameFailedError(BzrMoveFailedError):
1664
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1666
def __init__(self, from_path, to_path, extra=None):
1667
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1669
class BzrRemoveChangedFilesError(BzrError):
1670
"""Used when user is trying to remove changed files."""
1672
_fmt = ("Can't remove changed or unknown files:\n%(changes_as_text)s"
1673
"Use --keep to not delete them, or --force to delete them regardless.")
1675
def __init__(self, tree_delta):
1676
BzrError.__init__(self)
1677
self.changes_as_text = tree_delta.get_changes_as_text()
1678
#self.paths_as_string = '\n'.join(changed_files)
1679
#self.paths_as_string = '\n'.join([quotefn(p) for p in changed_files])
998
1682
class BzrBadParameterNotString(BzrBadParameter):
999
"""Parameter %(param)s is not a string or unicode string."""
1684
_fmt = "Parameter %(param)s is not a string or unicode string."
1002
1687
class BzrBadParameterMissing(BzrBadParameter):
1003
"""Parameter $(param)s is required but not present."""
1689
_fmt = "Parameter $(param)s is required but not present."
1006
1692
class BzrBadParameterUnicode(BzrBadParameter):
1007
"""Parameter %(param)s is unicode but only byte-strings are permitted."""
1694
_fmt = ("Parameter %(param)s is unicode but"
1695
" only byte-strings are permitted.")
1010
1698
class BzrBadParameterContainsNewline(BzrBadParameter):
1011
"""Parameter %(param)s contains a newline."""
1014
class DependencyNotPresent(BzrNewError):
1015
"""Unable to import library "%(library)s": %(error)s"""
1700
_fmt = "Parameter %(param)s contains a newline."
1703
class DependencyNotPresent(BzrError):
1705
_fmt = 'Unable to import library "%(library)s": %(error)s'
1017
1707
def __init__(self, library, error):
1018
BzrNewError.__init__(self, library=library, error=error)
1708
BzrError.__init__(self, library=library, error=error)
1021
1711
class ParamikoNotPresent(DependencyNotPresent):
1022
"""Unable to import paramiko (required for sftp support): %(error)s"""
1713
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1024
1715
def __init__(self, error):
1025
1716
DependencyNotPresent.__init__(self, 'paramiko', error)
1028
class PointlessMerge(BzrNewError):
1029
"""Nothing to merge."""
1032
class UninitializableFormat(BzrNewError):
1033
"""Format %(format)s cannot be initialised by this version of bzr."""
1719
class PointlessMerge(BzrError):
1721
_fmt = "Nothing to merge."
1724
class UninitializableFormat(BzrError):
1726
_fmt = "Format %(format)s cannot be initialised by this version of bzr."
1035
1728
def __init__(self, format):
1036
BzrNewError.__init__(self)
1729
BzrError.__init__(self)
1037
1730
self.format = format
1040
class BadConversionTarget(BzrNewError):
1041
"""Cannot convert to format %(format)s. %(problem)s"""
1733
class BadConversionTarget(BzrError):
1735
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1043
1737
def __init__(self, problem, format):
1044
BzrNewError.__init__(self)
1738
BzrError.__init__(self)
1045
1739
self.problem = problem
1046
1740
self.format = format
1049
class NoDiff(BzrNewError):
1050
"""Diff is not installed on this machine: %(msg)s"""
1743
class NoDiff(BzrError):
1745
_fmt = "Diff is not installed on this machine: %(msg)s"
1052
1747
def __init__(self, msg):
1053
BzrNewError.__init__(self, msg=msg)
1056
class NoDiff3(BzrNewError):
1057
"""Diff3 is not installed on this machine."""
1060
class ExistingLimbo(BzrNewError):
1061
"""This tree contains left-over files from a failed operation.
1062
Please examine %(limbo_dir)s to see if it contains any files you wish to
1063
keep, and delete it when you are done.
1065
def __init__(self, limbo_dir):
1066
BzrNewError.__init__(self)
1067
self.limbo_dir = limbo_dir
1070
class ImmortalLimbo(BzrNewError):
1071
"""Unable to delete transform temporary directory $(limbo_dir)s.
1072
Please examine %(limbo_dir)s to see if it contains any files you wish to
1073
keep, and delete it when you are done.
1075
def __init__(self, limbo_dir):
1076
BzrNewError.__init__(self)
1077
self.limbo_dir = limbo_dir
1080
class OutOfDateTree(BzrNewError):
1081
"""Working tree is out of date, please run 'bzr update'."""
1748
BzrError.__init__(self, msg=msg)
1751
class NoDiff3(BzrError):
1753
_fmt = "Diff3 is not installed on this machine."
1756
class ExistingLimbo(BzrError):
1758
_fmt = """This tree contains left-over files from a failed operation.
1759
Please examine %(limbo_dir)s to see if it contains any files you wish to
1760
keep, and delete it when you are done."""
1762
def __init__(self, limbo_dir):
1763
BzrError.__init__(self)
1764
self.limbo_dir = limbo_dir
1767
class ImmortalLimbo(BzrError):
1769
_fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
1770
Please examine %(limbo_dir)s to see if it contains any files you wish to
1771
keep, and delete it when you are done."""
1773
def __init__(self, limbo_dir):
1774
BzrError.__init__(self)
1775
self.limbo_dir = limbo_dir
1778
class OutOfDateTree(BzrError):
1780
_fmt = "Working tree is out of date, please run 'bzr update'."
1083
1782
def __init__(self, tree):
1084
BzrNewError.__init__(self)
1783
BzrError.__init__(self)
1085
1784
self.tree = tree
1088
class MergeModifiedFormatError(BzrNewError):
1089
"""Error in merge modified format"""
1092
class ConflictFormatError(BzrNewError):
1093
"""Format error in conflict listings"""
1096
class CorruptRepository(BzrNewError):
1097
"""An error has been detected in the repository %(repo_path)s.
1098
Please run bzr reconcile on this repository."""
1787
class PublicBranchOutOfDate(BzrError):
1789
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1792
def __init__(self, public_location, revstring):
1793
import bzrlib.urlutils as urlutils
1794
public_location = urlutils.unescape_for_display(public_location,
1796
BzrError.__init__(self, public_location=public_location,
1797
revstring=revstring)
1800
class MergeModifiedFormatError(BzrError):
1802
_fmt = "Error in merge modified format"
1805
class ConflictFormatError(BzrError):
1807
_fmt = "Format error in conflict listings"
1810
class CorruptRepository(BzrError):
1812
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1813
"Please run bzr reconcile on this repository.")
1100
1815
def __init__(self, repo):
1101
BzrNewError.__init__(self)
1816
BzrError.__init__(self)
1102
1817
self.repo_path = repo.bzrdir.root_transport.base
1105
class UpgradeRequired(BzrNewError):
1106
"""To use this feature you must upgrade your branch at %(path)s."""
1820
class UpgradeRequired(BzrError):
1822
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1108
1824
def __init__(self, path):
1109
BzrNewError.__init__(self)
1825
BzrError.__init__(self)
1110
1826
self.path = path
1113
class LocalRequiresBoundBranch(BzrNewError):
1114
"""Cannot perform local-only commits on unbound branches."""
1117
class MissingProgressBarFinish(BzrNewError):
1118
"""A nested progress bar was not 'finished' correctly."""
1121
class InvalidProgressBarType(BzrNewError):
1122
"""Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1123
Select one of: %(valid_types)s"""
1829
class LocalRequiresBoundBranch(BzrError):
1831
_fmt = "Cannot perform local-only commits on unbound branches."
1834
class MissingProgressBarFinish(BzrError):
1836
_fmt = "A nested progress bar was not 'finished' correctly."
1839
class InvalidProgressBarType(BzrError):
1841
_fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
1842
" is not a supported type Select one of: %(valid_types)s")
1125
1844
def __init__(self, bar_type, valid_types):
1126
BzrNewError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1129
class UnsupportedOperation(BzrNewError):
1130
"""The method %(mname)s is not supported on objects of type %(tname)s."""
1845
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1848
class UnsupportedOperation(BzrError):
1850
_fmt = ("The method %(mname)s is not supported on"
1851
" objects of type %(tname)s.")
1131
1853
def __init__(self, method, method_self):
1132
1854
self.method = method
1133
1855
self.mname = method.__name__
1134
1856
self.tname = type(method_self).__name__
1137
class BinaryFile(BzrNewError):
1138
"""File is binary but should be text."""
1141
class IllegalPath(BzrNewError):
1142
"""The path %(path)s is not permitted on this platform"""
1859
class CannotSetRevisionId(UnsupportedOperation):
1860
"""Raised when a commit is attempting to set a revision id but cant."""
1863
class NonAsciiRevisionId(UnsupportedOperation):
1864
"""Raised when a commit is attempting to set a non-ascii revision id
1869
class BinaryFile(BzrError):
1871
_fmt = "File is binary but should be text."
1874
class IllegalPath(BzrError):
1876
_fmt = "The path %(path)s is not permitted on this platform"
1144
1878
def __init__(self, path):
1145
BzrNewError.__init__(self)
1879
BzrError.__init__(self)
1146
1880
self.path = path
1149
class TestamentMismatch(BzrNewError):
1150
"""Testament did not match expected value.
1151
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1883
class TestamentMismatch(BzrError):
1885
_fmt = """Testament did not match expected value.
1886
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1154
1889
def __init__(self, revision_id, expected, measured):
1155
1890
self.revision_id = revision_id
1156
1891
self.expected = expected
1157
1892
self.measured = measured
1160
class NotABundle(BzrNewError):
1161
"""Not a bzr revision-bundle: %(text)r"""
1895
class NotABundle(BzrError):
1897
_fmt = "Not a bzr revision-bundle: %(text)r"
1163
1899
def __init__(self, text):
1164
BzrNewError.__init__(self)
1900
BzrError.__init__(self)
1165
1901
self.text = text
1168
class BadBundle(BzrNewError):
1169
"""Bad bzr revision-bundle: %(text)r"""
1904
class BadBundle(BzrError):
1906
_fmt = "Bad bzr revision-bundle: %(text)r"
1171
1908
def __init__(self, text):
1172
BzrNewError.__init__(self)
1909
BzrError.__init__(self)
1173
1910
self.text = text
1176
1913
class MalformedHeader(BadBundle):
1177
"""Malformed bzr revision-bundle header: %(text)r"""
1179
def __init__(self, text):
1180
BzrNewError.__init__(self)
1915
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1184
1918
class MalformedPatches(BadBundle):
1185
"""Malformed patches in bzr revision-bundle: %(text)r"""
1187
def __init__(self, text):
1188
BzrNewError.__init__(self)
1920
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1192
1923
class MalformedFooter(BadBundle):
1193
"""Malformed footer in bzr revision-bundle: %(text)r"""
1195
def __init__(self, text):
1196
BzrNewError.__init__(self)
1925
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1200
1928
class UnsupportedEOLMarker(BadBundle):
1201
"""End of line marker was not \\n in bzr revision-bundle"""
1930
_fmt = "End of line marker was not \\n in bzr revision-bundle"
1203
1932
def __init__(self):
1204
BzrNewError.__init__(self)
1207
class IncompatibleFormat(BzrNewError):
1208
"""Bundle format %(bundle_format)s is incompatible with %(other)s"""
1933
# XXX: BadBundle's constructor assumes there's explanatory text,
1934
# but for this there is not
1935
BzrError.__init__(self)
1938
class IncompatibleBundleFormat(BzrError):
1940
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1210
1942
def __init__(self, bundle_format, other):
1211
BzrNewError.__init__(self)
1943
BzrError.__init__(self)
1212
1944
self.bundle_format = bundle_format
1213
1945
self.other = other
1216
class BadInventoryFormat(BzrNewError):
1217
"""Root class for inventory serialization errors"""
1948
class BadInventoryFormat(BzrError):
1950
_fmt = "Root class for inventory serialization errors"
1220
1953
class UnexpectedInventoryFormat(BadInventoryFormat):
1221
"""The inventory was not in the expected format:\n %(msg)s"""
1955
_fmt = "The inventory was not in the expected format:\n %(msg)s"
1223
1957
def __init__(self, msg):
1224
1958
BadInventoryFormat.__init__(self, msg=msg)
1961
class RootNotRich(BzrError):
1963
_fmt = """This operation requires rich root data storage"""
1966
class NoSmartMedium(BzrError):
1968
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1970
internal_error = True
1972
def __init__(self, transport):
1973
self.transport = transport
1227
1976
class NoSmartServer(NotBranchError):
1228
"""No smart server available at %(url)s"""
1978
_fmt = "No smart server available at %(url)s"
1230
1980
def __init__(self, url):
1234
class UnknownSSH(BzrNewError):
1235
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1984
class UnknownSSH(BzrError):
1986
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
1237
1988
def __init__(self, vendor):
1238
BzrNewError.__init__(self)
1989
BzrError.__init__(self)
1239
1990
self.vendor = vendor
1242
class GhostRevisionUnusableHere(BzrNewError):
1243
"""Ghost revision {%(revision_id)s} cannot be used here."""
1993
class SSHVendorNotFound(BzrError):
1995
_fmt = ("Don't know how to handle SSH connections."
1996
" Please set BZR_SSH environment variable.")
1999
class GhostRevisionUnusableHere(BzrError):
2001
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1245
2003
def __init__(self, revision_id):
1246
BzrNewError.__init__(self)
2004
BzrError.__init__(self)
1247
2005
self.revision_id = revision_id
1250
class IllegalUseOfScopeReplacer(BzrNewError):
1251
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1253
is_user_error = False
2008
class IllegalUseOfScopeReplacer(BzrError):
2010
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2011
" %(msg)s%(extra)s")
2013
internal_error = True
1255
2015
def __init__(self, name, msg, extra=None):
1256
BzrNewError.__init__(self)
2016
BzrError.__init__(self)
1257
2017
self.name = name
1262
2022
self.extra = ''
1265
class InvalidImportLine(BzrNewError):
1266
"""Not a valid import statement: %(msg)\n%(text)s"""
1268
is_user_error = False
2025
class InvalidImportLine(BzrError):
2027
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
2029
internal_error = True
1270
2031
def __init__(self, text, msg):
1271
BzrNewError.__init__(self)
2032
BzrError.__init__(self)
1272
2033
self.text = text
1276
class ImportNameCollision(BzrNewError):
1277
"""Tried to import an object to the same name as an existing object. %(name)s"""
1279
is_user_error = False
1281
def __init__(self, name):
1282
BzrNewError.__init__(self)
2037
class ImportNameCollision(BzrError):
2039
_fmt = ("Tried to import an object to the same name as"
2040
" an existing object. %(name)s")
2042
internal_error = True
2044
def __init__(self, name):
2045
BzrError.__init__(self)
2049
class NotAMergeDirective(BzrError):
2050
"""File starting with %(firstline)r is not a merge directive"""
2051
def __init__(self, firstline):
2052
BzrError.__init__(self, firstline=firstline)
2055
class NoMergeSource(BzrError):
2056
"""Raise if no merge source was specified for a merge directive"""
2058
_fmt = "A merge directive must provide either a bundle or a public"\
2062
class PatchMissing(BzrError):
2063
"""Raise a patch type was specified but no patch supplied"""
2065
_fmt = "patch_type was %(patch_type)s, but no patch was supplied."
2067
def __init__(self, patch_type):
2068
BzrError.__init__(self)
2069
self.patch_type = patch_type
2072
class UnsupportedInventoryKind(BzrError):
2074
_fmt = """Unsupported entry kind %(kind)s"""
2076
def __init__(self, kind):
2080
class BadSubsumeSource(BzrError):
2082
_fmt = """Can't subsume %(other_tree)s into %(tree)s. %(reason)s"""
2084
def __init__(self, tree, other_tree, reason):
2086
self.other_tree = other_tree
2087
self.reason = reason
2090
class SubsumeTargetNeedsUpgrade(BzrError):
2092
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2094
def __init__(self, other_tree):
2095
self.other_tree = other_tree
2098
class BadReferenceTarget(BzrError):
2100
_fmt = "Can't add reference to %(other_tree)s into %(tree)s. %(reason)s"
2102
internal_error = True
2104
def __init__(self, tree, other_tree, reason):
2106
self.other_tree = other_tree
2107
self.reason = reason
2110
class NoSuchTag(BzrError):
2112
_fmt = "No such tag: %(tag_name)s"
2114
def __init__(self, tag_name):
2115
self.tag_name = tag_name
2118
class TagsNotSupported(BzrError):
2120
_fmt = ("Tags not supported by %(branch)s;"
2121
" you may be able to use bzr upgrade --dirstate-tags.")
2123
def __init__(self, branch):
2124
self.branch = branch
2127
class TagAlreadyExists(BzrError):
2129
_fmt = "Tag %(tag_name)s already exists."
2131
def __init__(self, tag_name):
2132
self.tag_name = tag_name
2135
class MalformedBugIdentifier(BzrError):
2137
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2139
def __init__(self, bug_id, reason):
2140
self.bug_id = bug_id
2141
self.reason = reason
2144
class UnknownBugTrackerAbbreviation(BzrError):
2146
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2149
def __init__(self, abbreviation, branch):
2150
self.abbreviation = abbreviation
2151
self.branch = branch
2154
class UnexpectedSmartServerResponse(BzrError):
2156
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2158
def __init__(self, response_tuple):
2159
self.response_tuple = response_tuple
2162
class ContainerError(BzrError):
2163
"""Base class of container errors."""
2166
class UnknownContainerFormatError(ContainerError):
2168
_fmt = "Unrecognised container format: %(container_format)r"
2170
def __init__(self, container_format):
2171
self.container_format = container_format
2174
class UnexpectedEndOfContainerError(ContainerError):
2176
_fmt = "Unexpected end of container stream"
2178
internal_error = False
2181
class UnknownRecordTypeError(ContainerError):
2183
_fmt = "Unknown record type: %(record_type)r"
2185
def __init__(self, record_type):
2186
self.record_type = record_type
2189
class InvalidRecordError(ContainerError):
2191
_fmt = "Invalid record: %(reason)s"
2193
def __init__(self, reason):
2194
self.reason = reason
2197
class ContainerHasExcessDataError(ContainerError):
2199
_fmt = "Container has data after end marker: %(excess)r"
2201
def __init__(self, excess):
2202
self.excess = excess
2205
class DuplicateRecordNameError(ContainerError):
2207
_fmt = "Container has multiple records with the same name: \"%(name)s\""
2209
def __init__(self, name):
2213
class NoDestinationAddress(BzrError):
2215
_fmt = "Message does not have a destination address."
2217
internal_error = True
2220
class SMTPError(BzrError):
2222
_fmt = "SMTP error: %(error)s"
2224
def __init__(self, error):