39
85
# constructed to make sure it will succeed. But that says nothing about
40
86
# exceptions that are never raised.
42
# TODO: selftest assertRaises should probably also check that every error
43
# raised can be formatted as a string successfully, and without giving
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.
47
96
class BzrError(StandardError):
49
Base class for errors raised by bzrlib.
51
:cvar internal_error: if true (or absent) this was probably caused by a
52
bzr bug and should be displayed with a traceback; if False 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
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
86
self._preformatted_string = None
87
for key, value in kwds.items():
88
setattr(self, key, value)
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=%s' \
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),
115
return n + `self.args`
129
118
class BzrNewError(BzrError):
130
"""Deprecated error base class."""
131
120
# base classes should override the docstring with their human-
132
121
# readable explanation
134
def __init__(self, *args, **kwds):
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__,
144
BzrError.__init__(self, *args)
123
def __init__(self, **kwds):
145
124
for key, value in kwds.items():
146
125
setattr(self, key, value)
515
356
class InaccessibleParent(PathError):
517
_fmt = ("Parent not accessible given base %(base)s and"
518
" relative path %(path)s")
357
"""Parent not accessible given base %(base)s and relative path %(path)s"""
520
359
def __init__(self, path, base):
521
360
PathError.__init__(self, path)
525
class NoRepositoryPresent(BzrError):
527
_fmt = "No repository present: %(path)r"
364
class NoRepositoryPresent(BzrNewError):
365
"""No repository present: %(path)r"""
528
366
def __init__(self, bzrdir):
529
BzrError.__init__(self)
367
BzrNewError.__init__(self)
530
368
self.path = bzrdir.transport.clone('..').base
533
class FileInWrongBranch(BzrError):
535
_fmt = "File %(path)s in not in branch %(branch_base)s."
371
class FileInWrongBranch(BzrNewError):
372
"""File %(path)s in not in branch %(branch_base)s."""
537
374
def __init__(self, branch, path):
538
BzrError.__init__(self)
375
BzrNewError.__init__(self)
539
376
self.branch = branch
540
377
self.branch_base = branch.base
544
class UnsupportedFormatError(BzrError):
546
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
549
class UnknownFormatError(BzrError):
551
_fmt = "Unknown branch format: %(format)r"
554
class IncompatibleFormat(BzrError):
556
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
381
class UnsupportedFormatError(BzrNewError):
382
"""Unsupported branch format: %(format)s"""
385
class UnknownFormatError(BzrNewError):
386
"""Unknown branch format: %(format)r"""
389
class IncompatibleFormat(BzrNewError):
390
"""Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
558
392
def __init__(self, format, bzrdir_format):
559
BzrError.__init__(self)
393
BzrNewError.__init__(self)
560
394
self.format = format
561
395
self.bzrdir = bzrdir_format
564
class IncompatibleRepositories(BzrError):
566
_fmt = "Repository %(target)s is not compatible with repository"\
569
def __init__(self, source, target):
570
BzrError.__init__(self, target=target, source=source)
573
class IncompatibleRevision(BzrError):
575
_fmt = "Revision is not compatible with %(repo_format)s"
577
def __init__(self, repo_format):
578
BzrError.__init__(self)
579
self.repo_format = repo_format
582
class AlreadyVersionedError(BzrError):
583
"""Used when a path is expected not to be versioned, but it is."""
585
_fmt = "%(context_info)s%(path)s is already versioned"
587
def __init__(self, path, context_info=None):
588
"""Construct a new AlreadyVersionedError.
590
:param path: This is the path which is versioned,
591
which should be in a user friendly form.
592
:param context_info: If given, this is information about the context,
593
which could explain why this is expected to not be versioned.
595
BzrError.__init__(self)
597
if context_info is None:
598
self.context_info = ''
600
self.context_info = context_info + ". "
603
class NotVersionedError(BzrError):
604
"""Used when a path is expected to be versioned, but it is not."""
606
_fmt = "%(context_info)s%(path)s is not versioned"
608
def __init__(self, path, context_info=None):
609
"""Construct a new NotVersionedError.
611
:param path: This is the path which is not versioned,
612
which should be in a user friendly form.
613
:param context_info: If given, this is information about the context,
614
which could explain why this is expected to be versioned.
616
BzrError.__init__(self)
618
if context_info is None:
619
self.context_info = ''
621
self.context_info = context_info + ". "
624
class PathsNotVersionedError(BzrError):
625
"""Used when reporting several paths which are not versioned"""
627
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
398
class NotVersionedError(BzrNewError):
399
"""%(path)s is not versioned"""
400
def __init__(self, path):
401
BzrNewError.__init__(self)
405
class PathsNotVersionedError(BzrNewError):
406
# used when reporting several paths are not versioned
407
"""Path(s) are not versioned: %(paths_as_string)s"""
629
409
def __init__(self, paths):
630
410
from bzrlib.osutils import quotefn
631
BzrError.__init__(self)
411
BzrNewError.__init__(self)
632
412
self.paths = paths
633
413
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
636
class PathsDoNotExist(BzrError):
638
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
416
class PathsDoNotExist(BzrNewError):
417
"""Path(s) do not exist: %(paths_as_string)s"""
640
419
# used when reporting that paths are neither versioned nor in the working
643
def __init__(self, paths, extra=None):
422
def __init__(self, paths):
644
423
# circular import
645
424
from bzrlib.osutils import quotefn
646
BzrError.__init__(self)
425
BzrNewError.__init__(self)
647
426
self.paths = paths
648
427
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
650
self.extra = ': ' + str(extra)
655
class BadFileKindError(BzrError):
657
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
659
def __init__(self, filename, kind):
660
BzrError.__init__(self, filename=filename, kind=kind)
663
class ForbiddenControlFileError(BzrError):
665
_fmt = "Cannot operate on %(filename)s because it is a control file"
668
class LockError(BzrError):
670
_fmt = "Lock error: %(msg)s"
672
internal_error = True
430
class BadFileKindError(BzrNewError):
431
"""Cannot operate on %(filename)s of unsupported kind %(kind)s"""
434
class ForbiddenControlFileError(BzrNewError):
435
"""Cannot operate on %(filename)s because it is a control file"""
438
class LockError(BzrNewError):
439
"""Lock error: %(message)s"""
674
440
# All exceptions from the lock/unlock functions should be from
675
441
# this exception class. They will be translated as necessary. The
676
442
# original exception is available as e.original_error
678
444
# New code should prefer to raise specific subclasses
679
445
def __init__(self, message):
680
# Python 2.5 uses a slot for StandardError.message,
681
# so use a different variable name
682
# so it is exposed in self.__dict__
686
class LockActive(LockError):
688
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
690
internal_error = False
692
def __init__(self, lock_description):
693
self.lock_description = lock_description
446
self.message = message
696
449
class CommitNotPossible(LockError):
698
_fmt = "A commit was attempted but we do not have a write lock open."
450
"""A commit was attempted but we do not have a write lock open."""
700
451
def __init__(self):
704
455
class AlreadyCommitted(LockError):
706
_fmt = "A rollback was requested, but is not able to be accomplished."
456
"""A rollback was requested, but is not able to be accomplished."""
708
457
def __init__(self):
712
461
class ReadOnlyError(LockError):
714
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
716
# TODO: There should also be an error indicating that you need a write
717
# lock and don't have any lock at all... mbp 20070226
462
"""A write attempt was made in a read only transaction on %(obj)s"""
719
463
def __init__(self, obj):
723
class ReadOnlyLockError(LockError):
725
_fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
727
def __init__(self, fname, msg):
728
LockError.__init__(self, '')
733
class OutSideTransaction(BzrError):
735
_fmt = ("A transaction related operation was attempted after"
736
" the transaction finished.")
467
class OutSideTransaction(BzrNewError):
468
"""A transaction related operation was attempted after the transaction finished."""
739
471
class ObjectNotLocked(LockError):
472
"""%(obj)r is not locked"""
741
_fmt = "%(obj)r is not locked"
474
is_user_error = False
743
476
# this can indicate that any particular object is not locked; see also
744
477
# LockNotHeld which means that a particular *lock* object is not held by
968
602
class NoCommonRoot(BzrError):
970
_fmt = ("Revisions are not derived from the same root: "
971
"%(revision_a)s %(revision_b)s.")
973
603
def __init__(self, revision_a, revision_b):
974
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
604
msg = "Revisions are not derived from the same root: %s %s." \
605
% (revision_a, revision_b)
606
BzrError.__init__(self, msg)
977
610
class NotAncestor(BzrError):
979
_fmt = "Revision %(rev_id)s is not an ancestor of %(not_ancestor_id)s"
981
611
def __init__(self, rev_id, not_ancestor_id):
982
BzrError.__init__(self, rev_id=rev_id,
983
not_ancestor_id=not_ancestor_id)
612
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
614
BzrError.__init__(self, msg)
616
self.not_ancestor_id = not_ancestor_id
986
619
class InstallFailed(BzrError):
988
620
def __init__(self, revisions):
989
revision_str = ", ".join(str(r) for r in revisions)
990
msg = "Could not install revisions:\n%s" % revision_str
621
msg = "Could not install revisions:\n%s" % " ,".join(revisions)
991
622
BzrError.__init__(self, msg)
992
623
self.revisions = revisions
995
626
class AmbiguousBase(BzrError):
997
627
def __init__(self, bases):
998
628
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
999
629
DeprecationWarning)
1000
msg = ("The correct base is unclear, because %s are all equally close"
630
msg = "The correct base is unclear, because %s are all equally close" %\
1002
632
BzrError.__init__(self, msg)
1003
633
self.bases = bases
1006
class NoCommits(BzrError):
1008
_fmt = "Branch %(branch)s has no commits."
636
class NoCommits(BzrNewError):
637
"""Branch %(branch)s has no commits."""
1010
639
def __init__(self, branch):
1011
BzrError.__init__(self, branch=branch)
640
BzrNewError.__init__(self, branch=branch)
1014
643
class UnlistableStore(BzrError):
1016
644
def __init__(self, store):
1017
645
BzrError.__init__(self, "Store %s is not listable" % store)
1021
649
class UnlistableBranch(BzrError):
1023
650
def __init__(self, br):
1024
651
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
1027
class BoundBranchOutOfDate(BzrError):
1029
_fmt = ("Bound branch %(branch)s is out of date"
1030
" with master branch %(master)s.")
654
class BoundBranchOutOfDate(BzrNewError):
655
"""Bound branch %(branch)s is out of date with master branch %(master)s."""
1032
656
def __init__(self, branch, master):
1033
BzrError.__init__(self)
657
BzrNewError.__init__(self)
1034
658
self.branch = branch
1035
659
self.master = master
1038
class CommitToDoubleBoundBranch(BzrError):
1040
_fmt = ("Cannot commit to branch %(branch)s."
1041
" It is bound to %(master)s, which is bound to %(remote)s.")
662
class CommitToDoubleBoundBranch(BzrNewError):
663
"""Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."""
1043
664
def __init__(self, branch, master, remote):
1044
BzrError.__init__(self)
665
BzrNewError.__init__(self)
1045
666
self.branch = branch
1046
667
self.master = master
1047
668
self.remote = remote
1050
class OverwriteBoundBranch(BzrError):
1052
_fmt = "Cannot pull --overwrite to a branch which is bound %(branch)s"
671
class OverwriteBoundBranch(BzrNewError):
672
"""Cannot pull --overwrite to a branch which is bound %(branch)s"""
1054
673
def __init__(self, branch):
1055
BzrError.__init__(self)
674
BzrNewError.__init__(self)
1056
675
self.branch = branch
1059
class BoundBranchConnectionFailure(BzrError):
1061
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1062
" => %(target)s: %(error)s")
678
class BoundBranchConnectionFailure(BzrNewError):
679
"""Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"""
1064
680
def __init__(self, branch, target, error):
1065
BzrError.__init__(self)
681
BzrNewError.__init__(self)
1066
682
self.branch = branch
1067
683
self.target = target
1068
684
self.error = error
1071
class WeaveError(BzrError):
1073
_fmt = "Error in processing weave: %(message)s"
687
class WeaveError(BzrNewError):
688
"""Error in processing weave: %(message)s"""
1075
690
def __init__(self, message=None):
1076
BzrError.__init__(self)
691
BzrNewError.__init__(self)
1077
692
self.message = message
1080
695
class WeaveRevisionAlreadyPresent(WeaveError):
1082
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
696
"""Revision {%(revision_id)s} already present in %(weave)s"""
1084
697
def __init__(self, revision_id, weave):
1086
699
WeaveError.__init__(self)
1394
879
BzrError.__init__(self, message)
1397
class NoEmailInUsername(BzrError):
1399
_fmt = "%(username)r does not seem to contain a reasonable email address"
1401
def __init__(self, username):
1402
BzrError.__init__(self)
1403
self.username = username
1406
882
class SigningFailed(BzrError):
1408
_fmt = "Failed to gpg sign data with command %(command_line)r"
1410
883
def __init__(self, command_line):
1411
BzrError.__init__(self, command_line=command_line)
884
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
1414
888
class WorkingTreeNotRevision(BzrError):
1416
_fmt = ("The working tree for %(basedir)s has changed since"
1417
" the last commit, but weave merge requires that it be"
1420
889
def __init__(self, tree):
1421
BzrError.__init__(self, basedir=tree.basedir)
1424
class CantReprocessAndShowBase(BzrError):
1426
_fmt = ("Can't reprocess and show base, because reprocessing obscures "
1427
"the relationship of conflicting lines to the base")
1430
class GraphCycleError(BzrError):
1432
_fmt = "Cycle in graph %(graph)r"
890
BzrError.__init__(self, "The working tree for %s has changed since"
891
" last commit, but weave merge requires that it be"
892
" unchanged." % tree.basedir)
895
class CantReprocessAndShowBase(BzrNewError):
896
"""Can't reprocess and show base.
897
Reprocessing obscures relationship of conflicting lines to base."""
900
class GraphCycleError(BzrNewError):
901
"""Cycle in graph %(graph)r"""
1434
902
def __init__(self, graph):
1435
BzrError.__init__(self)
903
BzrNewError.__init__(self)
1436
904
self.graph = graph
1439
class WritingCompleted(BzrError):
1441
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1442
"called upon it - accept bytes may not be called anymore.")
1444
internal_error = True
1446
def __init__(self, request):
1447
self.request = request
1450
class WritingNotComplete(BzrError):
1452
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1453
"called upon it - until the write phase is complete no "
1454
"data may be read.")
1456
internal_error = True
1458
def __init__(self, request):
1459
self.request = request
1462
class NotConflicted(BzrError):
1464
_fmt = "File %(filename)s is not conflicted."
907
class NotConflicted(BzrNewError):
908
"""File %(filename)s is not conflicted."""
1466
910
def __init__(self, filename):
1467
BzrError.__init__(self)
911
BzrNewError.__init__(self)
1468
912
self.filename = filename
1471
class MediumNotConnected(BzrError):
1473
_fmt = """The medium '%(medium)s' is not connected."""
1475
internal_error = True
1477
def __init__(self, medium):
1478
self.medium = medium
1481
915
class MustUseDecorated(Exception):
1483
_fmt = "A decorating function has requested its original command be used."
1486
class NoBundleFound(BzrError):
1488
_fmt = "No bundle was found in %(filename)s"
916
"""A decorating function has requested its original command be used.
918
This should never escape bzr, so does not need to be printable.
922
class NoBundleFound(BzrNewError):
923
"""No bundle was found in %(filename)s"""
1490
924
def __init__(self, filename):
1491
BzrError.__init__(self)
925
BzrNewError.__init__(self)
1492
926
self.filename = filename
1495
class BundleNotSupported(BzrError):
1497
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
929
class BundleNotSupported(BzrNewError):
930
"""Unable to handle bundle version %(version)s: %(msg)s"""
1499
931
def __init__(self, version, msg):
1500
BzrError.__init__(self)
932
BzrNewError.__init__(self)
1501
933
self.version = version
1505
class MissingText(BzrError):
1507
_fmt = ("Branch %(base)s is missing revision"
1508
" %(text_revision)s of %(file_id)s")
937
class MissingText(BzrNewError):
938
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
1510
940
def __init__(self, branch, text_revision, file_id):
1511
BzrError.__init__(self)
941
BzrNewError.__init__(self)
1512
942
self.branch = branch
1513
943
self.base = branch.base
1514
944
self.text_revision = text_revision
1515
945
self.file_id = file_id
1518
class DuplicateFileId(BzrError):
1520
_fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1522
def __init__(self, file_id, entry):
1523
BzrError.__init__(self)
1524
self.file_id = file_id
1528
class DuplicateKey(BzrError):
1530
_fmt = "Key %(key)s is already present in map"
1533
class MalformedTransform(BzrError):
1535
_fmt = "Tree transform is malformed %(conflicts)r"
1538
class NoFinalPath(BzrError):
1540
_fmt = ("No final name for trans_id %(trans_id)r\n"
1541
"file-id: %(file_id)r\n"
1542
"root trans-id: %(root_trans_id)r\n")
1544
def __init__(self, trans_id, transform):
1545
self.trans_id = trans_id
1546
self.file_id = transform.final_file_id(trans_id)
1547
self.root_trans_id = transform.root
1550
class BzrBadParameter(BzrError):
1552
_fmt = "Bad parameter: %(param)r"
1554
# This exception should never be thrown, but it is a base class for all
1555
# parameter-to-function errors.
948
class DuplicateKey(BzrNewError):
949
"""Key %(key)s is already present in map"""
952
class MalformedTransform(BzrNewError):
953
"""Tree transform is malformed %(conflicts)r"""
956
class BzrBadParameter(BzrNewError):
957
"""A bad parameter : %(param)s is not usable.
959
This exception should never be thrown, but it is a base class for all
960
parameter-to-function errors.
1557
962
def __init__(self, param):
1558
BzrError.__init__(self)
963
BzrNewError.__init__(self)
1559
964
self.param = param
1562
967
class BzrBadParameterNotUnicode(BzrBadParameter):
1564
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1567
class ReusingTransform(BzrError):
1569
_fmt = "Attempt to reuse a transform that has already been applied."
1572
class CantMoveRoot(BzrError):
1574
_fmt = "Moving the root directory is not supported at this time"
1577
class BzrMoveFailedError(BzrError):
1579
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1581
def __init__(self, from_path='', to_path='', extra=None):
1582
BzrError.__init__(self)
1584
self.extra = ': ' + str(extra)
1588
has_from = len(from_path) > 0
1589
has_to = len(to_path) > 0
1591
self.from_path = osutils.splitpath(from_path)[-1]
1596
self.to_path = osutils.splitpath(to_path)[-1]
1601
if has_from and has_to:
1602
self.operator = " =>"
1604
self.from_path = "from " + from_path
1606
self.operator = "to"
1608
self.operator = "file"
1611
class BzrRenameFailedError(BzrMoveFailedError):
1613
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1615
def __init__(self, from_path, to_path, extra=None):
1616
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
968
"""Parameter %(param)s is neither unicode nor utf8."""
971
class ReusingTransform(BzrNewError):
972
"""Attempt to reuse a transform that has already been applied."""
975
class CantMoveRoot(BzrNewError):
976
"""Moving the root directory is not supported at this time"""
1619
979
class BzrBadParameterNotString(BzrBadParameter):
1621
_fmt = "Parameter %(param)s is not a string or unicode string."
980
"""Parameter %(param)s is not a string or unicode string."""
1624
983
class BzrBadParameterMissing(BzrBadParameter):
1626
_fmt = "Parameter $(param)s is required but not present."
984
"""Parameter $(param)s is required but not present."""
1629
987
class BzrBadParameterUnicode(BzrBadParameter):
1631
_fmt = ("Parameter %(param)s is unicode but"
1632
" only byte-strings are permitted.")
988
"""Parameter %(param)s is unicode but only byte-strings are permitted."""
1635
991
class BzrBadParameterContainsNewline(BzrBadParameter):
1637
_fmt = "Parameter %(param)s contains a newline."
1640
class DependencyNotPresent(BzrError):
1642
_fmt = 'Unable to import library "%(library)s": %(error)s'
992
"""Parameter %(param)s contains a newline."""
995
class DependencyNotPresent(BzrNewError):
996
"""Unable to import library "%(library)s": %(error)s"""
1644
998
def __init__(self, library, error):
1645
BzrError.__init__(self, library=library, error=error)
999
BzrNewError.__init__(self, library=library, error=error)
1648
1002
class ParamikoNotPresent(DependencyNotPresent):
1650
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1003
"""Unable to import paramiko (required for sftp support): %(error)s"""
1652
1005
def __init__(self, error):
1653
1006
DependencyNotPresent.__init__(self, 'paramiko', error)
1656
class PointlessMerge(BzrError):
1658
_fmt = "Nothing to merge."
1661
class UninitializableFormat(BzrError):
1663
_fmt = "Format %(format)s cannot be initialised by this version of bzr."
1009
class PointlessMerge(BzrNewError):
1010
"""Nothing to merge."""
1013
class UninitializableFormat(BzrNewError):
1014
"""Format %(format)s cannot be initialised by this version of bzr."""
1665
1016
def __init__(self, format):
1666
BzrError.__init__(self)
1017
BzrNewError.__init__(self)
1667
1018
self.format = format
1670
class BadConversionTarget(BzrError):
1672
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1021
class BadConversionTarget(BzrNewError):
1022
"""Cannot convert to format %(format)s. %(problem)s"""
1674
1024
def __init__(self, problem, format):
1675
BzrError.__init__(self)
1025
BzrNewError.__init__(self)
1676
1026
self.problem = problem
1677
1027
self.format = format
1680
class NoDiff(BzrError):
1682
_fmt = "Diff is not installed on this machine: %(msg)s"
1030
class NoDiff(BzrNewError):
1031
"""Diff is not installed on this machine: %(msg)s"""
1684
1033
def __init__(self, msg):
1685
BzrError.__init__(self, msg=msg)
1688
class NoDiff3(BzrError):
1690
_fmt = "Diff3 is not installed on this machine."
1693
class ExistingLimbo(BzrError):
1695
_fmt = """This tree contains left-over files from a failed operation.
1696
Please examine %(limbo_dir)s to see if it contains any files you wish to
1697
keep, and delete it when you are done."""
1699
def __init__(self, limbo_dir):
1700
BzrError.__init__(self)
1701
self.limbo_dir = limbo_dir
1704
class ImmortalLimbo(BzrError):
1706
_fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
1707
Please examine %(limbo_dir)s to see if it contains any files you wish to
1708
keep, and delete it when you are done."""
1710
def __init__(self, limbo_dir):
1711
BzrError.__init__(self)
1712
self.limbo_dir = limbo_dir
1715
class OutOfDateTree(BzrError):
1717
_fmt = "Working tree is out of date, please run 'bzr update'."
1034
BzrNewError.__init__(self, msg=msg)
1037
class NoDiff3(BzrNewError):
1038
"""Diff3 is not installed on this machine."""
1041
class ExistingLimbo(BzrNewError):
1042
"""This tree contains left-over files from a failed operation.
1043
Please examine %(limbo_dir)s to see if it contains any files you wish to
1044
keep, and delete it when you are done.
1046
def __init__(self, limbo_dir):
1047
BzrNewError.__init__(self)
1048
self.limbo_dir = limbo_dir
1051
class ImmortalLimbo(BzrNewError):
1052
"""Unable to delete transform temporary directory $(limbo_dir)s.
1053
Please examine %(limbo_dir)s to see if it contains any files you wish to
1054
keep, and delete it when you are done.
1056
def __init__(self, limbo_dir):
1057
BzrNewError.__init__(self)
1058
self.limbo_dir = limbo_dir
1061
class OutOfDateTree(BzrNewError):
1062
"""Working tree is out of date, please run 'bzr update'."""
1719
1064
def __init__(self, tree):
1720
BzrError.__init__(self)
1065
BzrNewError.__init__(self)
1721
1066
self.tree = tree
1724
class PublicBranchOutOfDate(BzrError):
1726
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1729
def __init__(self, public_location, revstring):
1730
import bzrlib.urlutils as urlutils
1731
public_location = urlutils.unescape_for_display(public_location,
1733
BzrError.__init__(self, public_location=public_location,
1734
revstring=revstring)
1737
class MergeModifiedFormatError(BzrError):
1739
_fmt = "Error in merge modified format"
1742
class ConflictFormatError(BzrError):
1744
_fmt = "Format error in conflict listings"
1747
class CorruptRepository(BzrError):
1749
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1750
"Please run bzr reconcile on this repository.")
1069
class MergeModifiedFormatError(BzrNewError):
1070
"""Error in merge modified format"""
1073
class ConflictFormatError(BzrNewError):
1074
"""Format error in conflict listings"""
1077
class CorruptRepository(BzrNewError):
1078
"""An error has been detected in the repository %(repo_path)s.
1079
Please run bzr reconcile on this repository."""
1752
1081
def __init__(self, repo):
1753
BzrError.__init__(self)
1082
BzrNewError.__init__(self)
1754
1083
self.repo_path = repo.bzrdir.root_transport.base
1757
class UpgradeRequired(BzrError):
1759
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1086
class UpgradeRequired(BzrNewError):
1087
"""To use this feature you must upgrade your branch at %(path)s."""
1761
1089
def __init__(self, path):
1762
BzrError.__init__(self)
1090
BzrNewError.__init__(self)
1763
1091
self.path = path
1766
class LocalRequiresBoundBranch(BzrError):
1768
_fmt = "Cannot perform local-only commits on unbound branches."
1771
class MissingProgressBarFinish(BzrError):
1773
_fmt = "A nested progress bar was not 'finished' correctly."
1776
class InvalidProgressBarType(BzrError):
1778
_fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
1779
" is not a supported type Select one of: %(valid_types)s")
1094
class LocalRequiresBoundBranch(BzrNewError):
1095
"""Cannot perform local-only commits on unbound branches."""
1098
class MissingProgressBarFinish(BzrNewError):
1099
"""A nested progress bar was not 'finished' correctly."""
1102
class InvalidProgressBarType(BzrNewError):
1103
"""Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1104
Select one of: %(valid_types)s"""
1781
1106
def __init__(self, bar_type, valid_types):
1782
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1785
class UnsupportedOperation(BzrError):
1787
_fmt = ("The method %(mname)s is not supported on"
1788
" objects of type %(tname)s.")
1107
BzrNewError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1110
class UnsupportedOperation(BzrNewError):
1111
"""The method %(mname)s is not supported on objects of type %(tname)s."""
1790
1112
def __init__(self, method, method_self):
1791
1113
self.method = method
1792
1114
self.mname = method.__name__
1793
1115
self.tname = type(method_self).__name__
1796
class CannotSetRevisionId(UnsupportedOperation):
1797
"""Raised when a commit is attempting to set a revision id but cant."""
1800
class NonAsciiRevisionId(UnsupportedOperation):
1801
"""Raised when a commit is attempting to set a non-ascii revision id
1806
class BinaryFile(BzrError):
1808
_fmt = "File is binary but should be text."
1811
class IllegalPath(BzrError):
1813
_fmt = "The path %(path)s is not permitted on this platform"
1118
class BinaryFile(BzrNewError):
1119
"""File is binary but should be text."""
1122
class IllegalPath(BzrNewError):
1123
"""The path %(path)s is not permitted on this platform"""
1815
1125
def __init__(self, path):
1816
BzrError.__init__(self)
1126
BzrNewError.__init__(self)
1817
1127
self.path = path
1820
class TestamentMismatch(BzrError):
1822
_fmt = """Testament did not match expected value.
1823
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1130
class TestamentMismatch(BzrNewError):
1131
"""Testament did not match expected value.
1132
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1826
1135
def __init__(self, revision_id, expected, measured):
1827
1136
self.revision_id = revision_id
1828
1137
self.expected = expected
1829
1138
self.measured = measured
1832
class NotABundle(BzrError):
1834
_fmt = "Not a bzr revision-bundle: %(text)r"
1141
class NotABundle(BzrNewError):
1142
"""Not a bzr revision-bundle: %(text)r"""
1836
1144
def __init__(self, text):
1837
BzrError.__init__(self)
1145
BzrNewError.__init__(self)
1838
1146
self.text = text
1841
class BadBundle(BzrError):
1843
_fmt = "Bad bzr revision-bundle: %(text)r"
1149
class BadBundle(BzrNewError):
1150
"""Bad bzr revision-bundle: %(text)r"""
1845
1152
def __init__(self, text):
1846
BzrError.__init__(self)
1153
BzrNewError.__init__(self)
1847
1154
self.text = text
1850
1157
class MalformedHeader(BadBundle):
1852
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1158
"""Malformed bzr revision-bundle header: %(text)r"""
1160
def __init__(self, text):
1161
BzrNewError.__init__(self)
1855
1165
class MalformedPatches(BadBundle):
1857
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1166
"""Malformed patches in bzr revision-bundle: %(text)r"""
1168
def __init__(self, text):
1169
BzrNewError.__init__(self)
1860
1173
class MalformedFooter(BadBundle):
1862
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1174
"""Malformed footer in bzr revision-bundle: %(text)r"""
1176
def __init__(self, text):
1177
BzrNewError.__init__(self)
1865
1181
class UnsupportedEOLMarker(BadBundle):
1867
_fmt = "End of line marker was not \\n in bzr revision-bundle"
1182
"""End of line marker was not \\n in bzr revision-bundle"""
1869
1184
def __init__(self):
1870
# XXX: BadBundle's constructor assumes there's explanatory text,
1871
# but for this there is not
1872
BzrError.__init__(self)
1875
class IncompatibleBundleFormat(BzrError):
1877
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1879
def __init__(self, bundle_format, other):
1880
BzrError.__init__(self)
1881
self.bundle_format = bundle_format
1885
class BadInventoryFormat(BzrError):
1887
_fmt = "Root class for inventory serialization errors"
1185
BzrNewError.__init__(self)
1188
class BadInventoryFormat(BzrNewError):
1189
"""Root class for inventory serialization errors"""
1890
1192
class UnexpectedInventoryFormat(BadInventoryFormat):
1892
_fmt = "The inventory was not in the expected format:\n %(msg)s"
1193
"""The inventory was not in the expected format:\n %(msg)s"""
1894
1195
def __init__(self, msg):
1895
1196
BadInventoryFormat.__init__(self, msg=msg)
1898
class RootNotRich(BzrError):
1900
_fmt = """This operation requires rich root data storage"""
1903
class NoSmartMedium(BzrError):
1905
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1907
internal_error = True
1909
def __init__(self, transport):
1910
self.transport = transport
1913
1199
class NoSmartServer(NotBranchError):
1915
_fmt = "No smart server available at %(url)s"
1200
"""No smart server available at %(url)s"""
1917
1202
def __init__(self, url):
1921
class UnknownSSH(BzrError):
1923
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
1206
class UnknownSSH(BzrNewError):
1207
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1925
1209
def __init__(self, vendor):
1926
BzrError.__init__(self)
1210
BzrNewError.__init__(self)
1927
1211
self.vendor = vendor
1930
class SSHVendorNotFound(BzrError):
1932
_fmt = ("Don't know how to handle SSH connections."
1933
" Please set BZR_SSH environment variable.")
1936
class GhostRevisionUnusableHere(BzrError):
1938
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1214
class GhostRevisionUnusableHere(BzrNewError):
1215
"""Ghost revision {%(revision_id)s} cannot be used here."""
1940
1217
def __init__(self, revision_id):
1941
BzrError.__init__(self)
1218
BzrNewError.__init__(self)
1942
1219
self.revision_id = revision_id
1945
class IllegalUseOfScopeReplacer(BzrError):
1947
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
1948
" %(msg)s%(extra)s")
1950
internal_error = True
1222
class IllegalUseOfScopeReplacer(BzrNewError):
1223
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1225
is_user_error = False
1952
1227
def __init__(self, name, msg, extra=None):
1953
BzrError.__init__(self)
1228
BzrNewError.__init__(self)
1954
1229
self.name = name