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
492
359
class InaccessibleParent(PathError):
494
_fmt = "Parent not accessible given base %(base)s and relative path %(path)s"
360
"""Parent not accessible given base %(base)s and relative path %(path)s"""
496
362
def __init__(self, path, base):
497
363
PathError.__init__(self, path)
501
class NoRepositoryPresent(BzrError):
503
_fmt = "No repository present: %(path)r"
367
class NoRepositoryPresent(BzrNewError):
368
"""No repository present: %(path)r"""
504
369
def __init__(self, bzrdir):
505
BzrError.__init__(self)
370
BzrNewError.__init__(self)
506
371
self.path = bzrdir.transport.clone('..').base
509
class FileInWrongBranch(BzrError):
511
_fmt = "File %(path)s in not in branch %(branch_base)s."
374
class FileInWrongBranch(BzrNewError):
375
"""File %(path)s in not in branch %(branch_base)s."""
513
377
def __init__(self, branch, path):
514
BzrError.__init__(self)
378
BzrNewError.__init__(self)
515
379
self.branch = branch
516
380
self.branch_base = branch.base
520
class UnsupportedFormatError(BzrError):
522
_fmt = "Unsupported branch format: %(format)s"
525
class UnknownFormatError(BzrError):
527
_fmt = "Unknown branch format: %(format)r"
530
class IncompatibleFormat(BzrError):
532
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
384
class UnsupportedFormatError(BzrNewError):
385
"""Unsupported branch format: %(format)s"""
388
class UnknownFormatError(BzrNewError):
389
"""Unknown branch format: %(format)r"""
392
class IncompatibleFormat(BzrNewError):
393
"""Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
534
395
def __init__(self, format, bzrdir_format):
535
BzrError.__init__(self)
396
BzrNewError.__init__(self)
536
397
self.format = format
537
398
self.bzrdir = bzrdir_format
540
class IncompatibleRevision(BzrError):
542
_fmt = "Revision is not compatible with %(repo_format)s"
401
class IncompatibleRevision(BzrNewError):
402
"""Revision is not compatible with %(repo_format)s"""
544
404
def __init__(self, repo_format):
545
BzrError.__init__(self)
405
BzrNewError.__init__(self)
546
406
self.repo_format = repo_format
549
class AlreadyVersionedError(BzrError):
550
"""Used when a path is expected not to be versioned, but it is."""
552
_fmt = "%(context_info)s%(path)s is already versioned"
554
def __init__(self, path, context_info=None):
555
"""Construct a new AlreadyVersionedError.
557
:param path: This is the path which is versioned,
558
which should be in a user friendly form.
559
:param context_info: If given, this is information about the context,
560
which could explain why this is expected to not be versioned.
562
BzrError.__init__(self)
564
if context_info is None:
565
self.context_info = ''
567
self.context_info = context_info + ". "
570
class NotVersionedError(BzrError):
571
"""Used when a path is expected to be versioned, but it is not."""
573
_fmt = "%(context_info)s%(path)s is not versioned"
575
def __init__(self, path, context_info=None):
576
"""Construct a new NotVersionedError.
578
:param path: This is the path which is not versioned,
579
which should be in a user friendly form.
580
:param context_info: If given, this is information about the context,
581
which could explain why this is expected to be versioned.
583
BzrError.__init__(self)
585
if context_info is None:
586
self.context_info = ''
588
self.context_info = context_info + ". "
591
class PathsNotVersionedError(BzrError):
592
"""Used when reporting several paths which are not versioned"""
594
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
409
class NotVersionedError(BzrNewError):
410
"""%(path)s is not versioned"""
411
def __init__(self, path):
412
BzrNewError.__init__(self)
416
class PathsNotVersionedError(BzrNewError):
417
# used when reporting several paths are not versioned
418
"""Path(s) are not versioned: %(paths_as_string)s"""
596
420
def __init__(self, paths):
597
421
from bzrlib.osutils import quotefn
598
BzrError.__init__(self)
422
BzrNewError.__init__(self)
599
423
self.paths = paths
600
424
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
603
class PathsDoNotExist(BzrError):
605
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
427
class PathsDoNotExist(BzrNewError):
428
"""Path(s) do not exist: %(paths_as_string)s"""
607
430
# used when reporting that paths are neither versioned nor in the working
610
def __init__(self, paths, extra=None):
433
def __init__(self, paths):
611
434
# circular import
612
435
from bzrlib.osutils import quotefn
613
BzrError.__init__(self)
436
BzrNewError.__init__(self)
614
437
self.paths = paths
615
438
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
617
self.extra = ': ' + str(extra)
622
class BadFileKindError(BzrError):
624
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
626
def __init__(self, filename, kind):
627
BzrError.__init__(self, filename=filename, kind=kind)
630
class ForbiddenControlFileError(BzrError):
632
_fmt = "Cannot operate on %(filename)s because it is a control file"
635
class LockError(BzrError):
637
_fmt = "Lock error: %(message)s"
639
internal_error = True
441
class BadFileKindError(BzrNewError):
442
"""Cannot operate on %(filename)s of unsupported kind %(kind)s"""
445
class ForbiddenControlFileError(BzrNewError):
446
"""Cannot operate on %(filename)s because it is a control file"""
449
class LockError(BzrNewError):
450
"""Lock error: %(message)s"""
641
451
# All exceptions from the lock/unlock functions should be from
642
452
# this exception class. They will be translated as necessary. The
643
453
# original exception is available as e.original_error
1263
890
BzrError.__init__(self, message)
1266
class NoEmailInUsername(BzrError):
1268
_fmt = "%(username)r does not seem to contain a reasonable email address"
893
class NoEmailInUsername(BzrNewError):
894
"""%(username)r does not seem to contain a reasonable email address"""
1270
896
def __init__(self, username):
1271
BzrError.__init__(self)
897
BzrNewError.__init__(self)
1272
898
self.username = username
1275
901
class SigningFailed(BzrError):
1277
_fmt = "Failed to gpg sign data with command %(command_line)r"
1279
902
def __init__(self, command_line):
1280
BzrError.__init__(self, command_line=command_line)
903
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
1283
907
class WorkingTreeNotRevision(BzrError):
1285
_fmt = ("The working tree for %(basedir)s has changed since"
1286
" the last commit, but weave merge requires that it be"
1289
908
def __init__(self, tree):
1290
BzrError.__init__(self, basedir=tree.basedir)
1293
class CantReprocessAndShowBase(BzrError):
1295
_fmt = "Can't reprocess and show base, because reprocessing obscures " \
1296
"the relationship of conflicting lines to the base"
1299
class GraphCycleError(BzrError):
1301
_fmt = "Cycle in graph %(graph)r"
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"""
1303
921
def __init__(self, graph):
1304
BzrError.__init__(self)
922
BzrNewError.__init__(self)
1305
923
self.graph = graph
1308
class WritingCompleted(BzrError):
1310
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1311
"called upon it - accept bytes may not be called anymore.")
1313
internal_error = True
1315
def __init__(self, request):
1316
self.request = request
1319
class WritingNotComplete(BzrError):
1321
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1322
"called upon it - until the write phase is complete no "
1323
"data may be read.")
1325
internal_error = True
1327
def __init__(self, request):
1328
self.request = request
1331
class NotConflicted(BzrError):
1333
_fmt = "File %(filename)s is not conflicted."
926
class NotConflicted(BzrNewError):
927
"""File %(filename)s is not conflicted."""
1335
929
def __init__(self, filename):
1336
BzrError.__init__(self)
930
BzrNewError.__init__(self)
1337
931
self.filename = filename
1340
class MediumNotConnected(BzrError):
1342
_fmt = """The medium '%(medium)s' is not connected."""
1344
internal_error = True
1346
def __init__(self, medium):
1347
self.medium = medium
1350
934
class MustUseDecorated(Exception):
1352
_fmt = """A decorating function has requested its original command be used."""
1355
class NoBundleFound(BzrError):
1357
_fmt = "No bundle was found in %(filename)s"
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"""
1359
943
def __init__(self, filename):
1360
BzrError.__init__(self)
944
BzrNewError.__init__(self)
1361
945
self.filename = filename
1364
class BundleNotSupported(BzrError):
1366
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
948
class BundleNotSupported(BzrNewError):
949
"""Unable to handle bundle version %(version)s: %(msg)s"""
1368
950
def __init__(self, version, msg):
1369
BzrError.__init__(self)
951
BzrNewError.__init__(self)
1370
952
self.version = version
1374
class MissingText(BzrError):
1376
_fmt = "Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"
956
class MissingText(BzrNewError):
957
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
1378
959
def __init__(self, branch, text_revision, file_id):
1379
BzrError.__init__(self)
960
BzrNewError.__init__(self)
1380
961
self.branch = branch
1381
962
self.base = branch.base
1382
963
self.text_revision = text_revision
1383
964
self.file_id = file_id
1386
class DuplicateFileId(BzrError):
1388
_fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1390
def __init__(self, file_id, entry):
1391
BzrError.__init__(self)
1392
self.file_id = file_id
1396
class DuplicateKey(BzrError):
1398
_fmt = "Key %(key)s is already present in map"
1401
class MalformedTransform(BzrError):
1403
_fmt = "Tree transform is malformed %(conflicts)r"
1406
class NoFinalPath(BzrError):
1408
_fmt = ("No final name for trans_id %(trans_id)r\n"
1409
"file-id: %(file_id)r\n"
1410
"root trans-id: %(root_trans_id)r\n")
1412
def __init__(self, trans_id, transform):
1413
self.trans_id = trans_id
1414
self.file_id = transform.final_file_id(trans_id)
1415
self.root_trans_id = transform.root
1418
class BzrBadParameter(BzrError):
1420
_fmt = "Bad parameter: %(param)r"
1422
# This exception should never be thrown, but it is a base class for all
1423
# parameter-to-function errors.
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.
1425
981
def __init__(self, param):
1426
BzrError.__init__(self)
982
BzrNewError.__init__(self)
1427
983
self.param = param
1430
986
class BzrBadParameterNotUnicode(BzrBadParameter):
1432
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1435
class ReusingTransform(BzrError):
1437
_fmt = "Attempt to reuse a transform that has already been applied."
1440
class CantMoveRoot(BzrError):
1442
_fmt = "Moving the root directory is not supported at this time"
1445
class BzrMoveFailedError(BzrError):
1447
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1449
def __init__(self, from_path='', to_path='', extra=None):
1450
BzrError.__init__(self)
1452
self.extra = ': ' + str(extra)
1456
has_from = len(from_path) > 0
1457
has_to = len(to_path) > 0
1459
self.from_path = osutils.splitpath(from_path)[-1]
1464
self.to_path = osutils.splitpath(to_path)[-1]
1469
if has_from and has_to:
1470
self.operator = " =>"
1472
self.from_path = "from " + from_path
1474
self.operator = "to"
1476
self.operator = "file"
1479
class BzrRenameFailedError(BzrMoveFailedError):
1481
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1483
def __init__(self, from_path, to_path, extra=None):
1484
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
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"""
1487
998
class BzrBadParameterNotString(BzrBadParameter):
1489
_fmt = "Parameter %(param)s is not a string or unicode string."
999
"""Parameter %(param)s is not a string or unicode string."""
1492
1002
class BzrBadParameterMissing(BzrBadParameter):
1494
_fmt = "Parameter $(param)s is required but not present."
1003
"""Parameter $(param)s is required but not present."""
1497
1006
class BzrBadParameterUnicode(BzrBadParameter):
1499
_fmt = "Parameter %(param)s is unicode but only byte-strings are permitted."
1007
"""Parameter %(param)s is unicode but only byte-strings are permitted."""
1502
1010
class BzrBadParameterContainsNewline(BzrBadParameter):
1504
_fmt = "Parameter %(param)s contains a newline."
1507
class DependencyNotPresent(BzrError):
1509
_fmt = 'Unable to import library "%(library)s": %(error)s'
1011
"""Parameter %(param)s contains a newline."""
1014
class DependencyNotPresent(BzrNewError):
1015
"""Unable to import library "%(library)s": %(error)s"""
1511
1017
def __init__(self, library, error):
1512
BzrError.__init__(self, library=library, error=error)
1018
BzrNewError.__init__(self, library=library, error=error)
1515
1021
class ParamikoNotPresent(DependencyNotPresent):
1517
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1022
"""Unable to import paramiko (required for sftp support): %(error)s"""
1519
1024
def __init__(self, error):
1520
1025
DependencyNotPresent.__init__(self, 'paramiko', error)
1523
class PointlessMerge(BzrError):
1525
_fmt = "Nothing to merge."
1528
class UninitializableFormat(BzrError):
1530
_fmt = "Format %(format)s cannot be initialised by this version of bzr."
1028
class PointlessMerge(BzrNewError):
1029
"""Nothing to merge."""
1032
class UninitializableFormat(BzrNewError):
1033
"""Format %(format)s cannot be initialised by this version of bzr."""
1532
1035
def __init__(self, format):
1533
BzrError.__init__(self)
1036
BzrNewError.__init__(self)
1534
1037
self.format = format
1537
class BadConversionTarget(BzrError):
1539
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1040
class BadConversionTarget(BzrNewError):
1041
"""Cannot convert to format %(format)s. %(problem)s"""
1541
1043
def __init__(self, problem, format):
1542
BzrError.__init__(self)
1044
BzrNewError.__init__(self)
1543
1045
self.problem = problem
1544
1046
self.format = format
1547
class NoDiff(BzrError):
1549
_fmt = "Diff is not installed on this machine: %(msg)s"
1049
class NoDiff(BzrNewError):
1050
"""Diff is not installed on this machine: %(msg)s"""
1551
1052
def __init__(self, msg):
1552
BzrError.__init__(self, msg=msg)
1555
class NoDiff3(BzrError):
1557
_fmt = "Diff3 is not installed on this machine."
1560
class ExistingLimbo(BzrError):
1562
_fmt = """This tree contains left-over files from a failed operation.
1563
Please examine %(limbo_dir)s to see if it contains any files you wish to
1564
keep, and delete it when you are done."""
1566
def __init__(self, limbo_dir):
1567
BzrError.__init__(self)
1568
self.limbo_dir = limbo_dir
1571
class ImmortalLimbo(BzrError):
1573
_fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
1574
Please examine %(limbo_dir)s to see if it contains any files you wish to
1575
keep, and delete it when you are done."""
1577
def __init__(self, limbo_dir):
1578
BzrError.__init__(self)
1579
self.limbo_dir = limbo_dir
1582
class OutOfDateTree(BzrError):
1584
_fmt = "Working tree is out of date, please run 'bzr update'."
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'."""
1586
1083
def __init__(self, tree):
1587
BzrError.__init__(self)
1084
BzrNewError.__init__(self)
1588
1085
self.tree = tree
1591
class MergeModifiedFormatError(BzrError):
1593
_fmt = "Error in merge modified format"
1596
class ConflictFormatError(BzrError):
1598
_fmt = "Format error in conflict listings"
1601
class CorruptRepository(BzrError):
1603
_fmt = """An error has been detected in the repository %(repo_path)s.
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.
1604
1098
Please run bzr reconcile on this repository."""
1606
1100
def __init__(self, repo):
1607
BzrError.__init__(self)
1101
BzrNewError.__init__(self)
1608
1102
self.repo_path = repo.bzrdir.root_transport.base
1611
class UpgradeRequired(BzrError):
1613
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1105
class UpgradeRequired(BzrNewError):
1106
"""To use this feature you must upgrade your branch at %(path)s."""
1615
1108
def __init__(self, path):
1616
BzrError.__init__(self)
1109
BzrNewError.__init__(self)
1617
1110
self.path = path
1620
class LocalRequiresBoundBranch(BzrError):
1622
_fmt = "Cannot perform local-only commits on unbound branches."
1625
class MissingProgressBarFinish(BzrError):
1627
_fmt = "A nested progress bar was not 'finished' correctly."
1630
class InvalidProgressBarType(BzrError):
1632
_fmt = """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
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
1633
1123
Select one of: %(valid_types)s"""
1635
1125
def __init__(self, bar_type, valid_types):
1636
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1639
class UnsupportedOperation(BzrError):
1641
_fmt = "The method %(mname)s is not supported on objects of type %(tname)s."
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."""
1643
1131
def __init__(self, method, method_self):
1644
1132
self.method = method
1645
1133
self.mname = method.__name__
1646
1134
self.tname = type(method_self).__name__
1649
class CannotSetRevisionId(UnsupportedOperation):
1650
"""Raised when a commit is attempting to set a revision id but cant."""
1653
class NonAsciiRevisionId(UnsupportedOperation):
1654
"""Raised when a commit is attempting to set a non-ascii revision id but cant."""
1657
class BinaryFile(BzrError):
1659
_fmt = "File is binary but should be text."
1662
class IllegalPath(BzrError):
1664
_fmt = "The path %(path)s is not permitted on this platform"
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"""
1666
1144
def __init__(self, path):
1667
BzrError.__init__(self)
1145
BzrNewError.__init__(self)
1668
1146
self.path = path
1671
class TestamentMismatch(BzrError):
1673
_fmt = """Testament did not match expected value.
1149
class TestamentMismatch(BzrNewError):
1150
"""Testament did not match expected value.
1674
1151
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1677
1154
def __init__(self, revision_id, expected, measured):
1678
1155
self.revision_id = revision_id
1679
1156
self.expected = expected
1680
1157
self.measured = measured
1683
class NotABundle(BzrError):
1685
_fmt = "Not a bzr revision-bundle: %(text)r"
1160
class NotABundle(BzrNewError):
1161
"""Not a bzr revision-bundle: %(text)r"""
1687
1163
def __init__(self, text):
1688
BzrError.__init__(self)
1164
BzrNewError.__init__(self)
1689
1165
self.text = text
1692
class BadBundle(BzrError):
1694
_fmt = "Bad bzr revision-bundle: %(text)r"
1168
class BadBundle(BzrNewError):
1169
"""Bad bzr revision-bundle: %(text)r"""
1696
1171
def __init__(self, text):
1697
BzrError.__init__(self)
1172
BzrNewError.__init__(self)
1698
1173
self.text = text
1701
1176
class MalformedHeader(BadBundle):
1703
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1177
"""Malformed bzr revision-bundle header: %(text)r"""
1179
def __init__(self, text):
1180
BzrNewError.__init__(self)
1706
1184
class MalformedPatches(BadBundle):
1708
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1185
"""Malformed patches in bzr revision-bundle: %(text)r"""
1187
def __init__(self, text):
1188
BzrNewError.__init__(self)
1711
1192
class MalformedFooter(BadBundle):
1713
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1193
"""Malformed footer in bzr revision-bundle: %(text)r"""
1195
def __init__(self, text):
1196
BzrNewError.__init__(self)
1716
1200
class UnsupportedEOLMarker(BadBundle):
1718
_fmt = "End of line marker was not \\n in bzr revision-bundle"
1201
"""End of line marker was not \\n in bzr revision-bundle"""
1720
1203
def __init__(self):
1721
# XXX: BadBundle's constructor assumes there's explanatory text,
1722
# but for this there is not
1723
BzrError.__init__(self)
1726
class IncompatibleBundleFormat(BzrError):
1728
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1204
BzrNewError.__init__(self)
1207
class IncompatibleFormat(BzrNewError):
1208
"""Bundle format %(bundle_format)s is incompatible with %(other)s"""
1730
1210
def __init__(self, bundle_format, other):
1731
BzrError.__init__(self)
1211
BzrNewError.__init__(self)
1732
1212
self.bundle_format = bundle_format
1733
1213
self.other = other
1736
class BadInventoryFormat(BzrError):
1738
_fmt = "Root class for inventory serialization errors"
1216
class BadInventoryFormat(BzrNewError):
1217
"""Root class for inventory serialization errors"""
1741
1220
class UnexpectedInventoryFormat(BadInventoryFormat):
1743
_fmt = "The inventory was not in the expected format:\n %(msg)s"
1221
"""The inventory was not in the expected format:\n %(msg)s"""
1745
1223
def __init__(self, msg):
1746
1224
BadInventoryFormat.__init__(self, msg=msg)
1749
class RootNotRich(BzrError):
1751
_fmt = """This operation requires rich root data storage"""
1754
class NoSmartMedium(BzrError):
1756
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1758
internal_error = True
1760
def __init__(self, transport):
1761
self.transport = transport
1764
1227
class NoSmartServer(NotBranchError):
1766
_fmt = "No smart server available at %(url)s"
1228
"""No smart server available at %(url)s"""
1768
1230
def __init__(self, url):
1772
class UnknownSSH(BzrError):
1774
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
1234
class UnknownSSH(BzrNewError):
1235
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1776
1237
def __init__(self, vendor):
1777
BzrError.__init__(self)
1238
BzrNewError.__init__(self)
1778
1239
self.vendor = vendor
1781
class GhostRevisionUnusableHere(BzrError):
1783
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1242
class GhostRevisionUnusableHere(BzrNewError):
1243
"""Ghost revision {%(revision_id)s} cannot be used here."""
1785
1245
def __init__(self, revision_id):
1786
BzrError.__init__(self)
1246
BzrNewError.__init__(self)
1787
1247
self.revision_id = revision_id
1790
class IllegalUseOfScopeReplacer(BzrError):
1792
_fmt = "ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"
1794
internal_error = True
1250
class IllegalUseOfScopeReplacer(BzrNewError):
1251
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1253
is_user_error = False
1796
1255
def __init__(self, name, msg, extra=None):
1797
BzrError.__init__(self)
1256
BzrNewError.__init__(self)
1798
1257
self.name = name