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 (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
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=%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),
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
359
492
class InaccessibleParent(PathError):
360
"""Parent not accessible given base %(base)s and relative path %(path)s"""
494
_fmt = "Parent not accessible given base %(base)s and relative path %(path)s"
362
496
def __init__(self, path, base):
363
497
PathError.__init__(self, path)
367
class NoRepositoryPresent(BzrNewError):
368
"""No repository present: %(path)r"""
501
class NoRepositoryPresent(BzrError):
503
_fmt = "No repository present: %(path)r"
369
504
def __init__(self, bzrdir):
370
BzrNewError.__init__(self)
505
BzrError.__init__(self)
371
506
self.path = bzrdir.transport.clone('..').base
374
class FileInWrongBranch(BzrNewError):
375
"""File %(path)s in not in branch %(branch_base)s."""
509
class FileInWrongBranch(BzrError):
511
_fmt = "File %(path)s in not in branch %(branch_base)s."
377
513
def __init__(self, branch, path):
378
BzrNewError.__init__(self)
514
BzrError.__init__(self)
379
515
self.branch = branch
380
516
self.branch_base = branch.base
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."""
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."
395
534
def __init__(self, format, bzrdir_format):
396
BzrNewError.__init__(self)
535
BzrError.__init__(self)
397
536
self.format = format
398
537
self.bzrdir = bzrdir_format
401
class IncompatibleRevision(BzrNewError):
402
"""Revision is not compatible with %(repo_format)s"""
540
class IncompatibleRevision(BzrError):
542
_fmt = "Revision is not compatible with %(repo_format)s"
404
544
def __init__(self, repo_format):
405
BzrNewError.__init__(self)
545
BzrError.__init__(self)
406
546
self.repo_format = repo_format
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"""
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 NotVersionedError.
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"
420
596
def __init__(self, paths):
421
597
from bzrlib.osutils import quotefn
422
BzrNewError.__init__(self)
598
BzrError.__init__(self)
423
599
self.paths = paths
424
600
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
427
class PathsDoNotExist(BzrNewError):
428
"""Path(s) do not exist: %(paths_as_string)s"""
603
class PathsDoNotExist(BzrError):
605
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
430
607
# used when reporting that paths are neither versioned nor in the working
433
def __init__(self, paths):
610
def __init__(self, paths, extra=None):
434
611
# circular import
435
612
from bzrlib.osutils import quotefn
436
BzrNewError.__init__(self)
613
BzrError.__init__(self)
437
614
self.paths = paths
438
615
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
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"""
617
self.extra = ': ' + str(extra)
622
class BadFileKindError(BzrError):
624
_fmt = "Cannot operate on %(filename)s of unsupported kind %(kind)s"
627
class ForbiddenControlFileError(BzrError):
629
_fmt = "Cannot operate on %(filename)s because it is a control file"
632
class LockError(BzrError):
634
_fmt = "Lock error: %(message)s"
636
internal_error = True
451
638
# All exceptions from the lock/unlock functions should be from
452
639
# this exception class. They will be translated as necessary. The
453
640
# original exception is available as e.original_error
890
1201
BzrError.__init__(self, message)
1204
class NoEmailInUsername(BzrError):
1206
_fmt = "%(username)r does not seem to contain a reasonable email address"
1208
def __init__(self, username):
1209
BzrError.__init__(self)
1210
self.username = username
893
1213
class SigningFailed(BzrError):
1215
_fmt = "Failed to gpg sign data with command %(command_line)r"
894
1217
def __init__(self, command_line):
895
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
1218
BzrError.__init__(self, command_line=command_line)
899
1221
class WorkingTreeNotRevision(BzrError):
1223
_fmt = ("The working tree for %(basedir)s has changed since"
1224
" the last commit, but weave merge requires that it be"
900
1227
def __init__(self, tree):
901
BzrError.__init__(self, "The working tree for %s has changed since"
902
" last commit, but weave merge requires that it be"
903
" unchanged." % tree.basedir)
906
class CantReprocessAndShowBase(BzrNewError):
907
"""Can't reprocess and show base.
908
Reprocessing obscures relationship of conflicting lines to base."""
911
class GraphCycleError(BzrNewError):
912
"""Cycle in graph %(graph)r"""
1228
BzrError.__init__(self, basedir=tree.basedir)
1231
class CantReprocessAndShowBase(BzrError):
1233
_fmt = "Can't reprocess and show base, because reprocessing obscures " \
1234
"the relationship of conflicting lines to the base"
1237
class GraphCycleError(BzrError):
1239
_fmt = "Cycle in graph %(graph)r"
913
1241
def __init__(self, graph):
914
BzrNewError.__init__(self)
1242
BzrError.__init__(self)
915
1243
self.graph = graph
918
class NotConflicted(BzrNewError):
919
"""File %(filename)s is not conflicted."""
1246
class WritingCompleted(BzrError):
1248
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1249
"called upon it - accept bytes may not be called anymore.")
1251
internal_error = True
1253
def __init__(self, request):
1254
self.request = request
1257
class WritingNotComplete(BzrError):
1259
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1260
"called upon it - until the write phase is complete no "
1261
"data may be read.")
1263
internal_error = True
1265
def __init__(self, request):
1266
self.request = request
1269
class NotConflicted(BzrError):
1271
_fmt = "File %(filename)s is not conflicted."
921
1273
def __init__(self, filename):
922
BzrNewError.__init__(self)
1274
BzrError.__init__(self)
923
1275
self.filename = filename
1278
class MediumNotConnected(BzrError):
1280
_fmt = """The medium '%(medium)s' is not connected."""
1282
internal_error = True
1284
def __init__(self, medium):
1285
self.medium = medium
926
1288
class MustUseDecorated(Exception):
927
"""A decorating function has requested its original command be used.
929
This should never escape bzr, so does not need to be printable.
933
class NoBundleFound(BzrNewError):
934
"""No bundle was found in %(filename)s"""
1290
_fmt = """A decorating function has requested its original command be used."""
1293
class NoBundleFound(BzrError):
1295
_fmt = "No bundle was found in %(filename)s"
935
1297
def __init__(self, filename):
936
BzrNewError.__init__(self)
1298
BzrError.__init__(self)
937
1299
self.filename = filename
940
class BundleNotSupported(BzrNewError):
941
"""Unable to handle bundle version %(version)s: %(msg)s"""
1302
class BundleNotSupported(BzrError):
1304
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
942
1306
def __init__(self, version, msg):
943
BzrNewError.__init__(self)
1307
BzrError.__init__(self)
944
1308
self.version = version
948
class MissingText(BzrNewError):
949
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
1312
class MissingText(BzrError):
1314
_fmt = "Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"
951
1316
def __init__(self, branch, text_revision, file_id):
952
BzrNewError.__init__(self)
1317
BzrError.__init__(self)
953
1318
self.branch = branch
954
1319
self.base = branch.base
955
1320
self.text_revision = text_revision
956
1321
self.file_id = file_id
959
class DuplicateKey(BzrNewError):
960
"""Key %(key)s is already present in map"""
963
class MalformedTransform(BzrNewError):
964
"""Tree transform is malformed %(conflicts)r"""
967
class BzrBadParameter(BzrNewError):
968
"""A bad parameter : %(param)s is not usable.
970
This exception should never be thrown, but it is a base class for all
971
parameter-to-function errors.
1324
class DuplicateKey(BzrError):
1326
_fmt = "Key %(key)s is already present in map"
1329
class MalformedTransform(BzrError):
1331
_fmt = "Tree transform is malformed %(conflicts)r"
1334
class NoFinalPath(BzrError):
1336
_fmt = ("No final name for trans_id %(trans_id)r\n"
1337
"file-id: %(file_id)r\n"
1338
"root trans-id: %(root_trans_id)r\n")
1340
def __init__(self, trans_id, transform):
1341
self.trans_id = trans_id
1342
self.file_id = transform.final_file_id(trans_id)
1343
self.root_trans_id = transform.root
1346
class BzrBadParameter(BzrError):
1348
_fmt = "Bad parameter: %(param)r"
1350
# This exception should never be thrown, but it is a base class for all
1351
# parameter-to-function errors.
973
1353
def __init__(self, param):
974
BzrNewError.__init__(self)
1354
BzrError.__init__(self)
975
1355
self.param = param
978
1358
class BzrBadParameterNotUnicode(BzrBadParameter):
979
"""Parameter %(param)s is neither unicode nor utf8."""
982
class ReusingTransform(BzrNewError):
983
"""Attempt to reuse a transform that has already been applied."""
986
class CantMoveRoot(BzrNewError):
987
"""Moving the root directory is not supported at this time"""
1360
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1363
class ReusingTransform(BzrError):
1365
_fmt = "Attempt to reuse a transform that has already been applied."
1368
class CantMoveRoot(BzrError):
1370
_fmt = "Moving the root directory is not supported at this time"
1373
class BzrMoveFailedError(BzrError):
1375
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1377
def __init__(self, from_path='', to_path='', extra=None):
1378
BzrError.__init__(self)
1380
self.extra = ': ' + str(extra)
1384
has_from = len(from_path) > 0
1385
has_to = len(to_path) > 0
1387
self.from_path = osutils.splitpath(from_path)[-1]
1392
self.to_path = osutils.splitpath(to_path)[-1]
1397
if has_from and has_to:
1398
self.operator = " =>"
1400
self.from_path = "from " + from_path
1402
self.operator = "to"
1404
self.operator = "file"
1407
class BzrRenameFailedError(BzrMoveFailedError):
1409
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1411
def __init__(self, from_path, to_path, extra=None):
1412
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
990
1415
class BzrBadParameterNotString(BzrBadParameter):
991
"""Parameter %(param)s is not a string or unicode string."""
1417
_fmt = "Parameter %(param)s is not a string or unicode string."
994
1420
class BzrBadParameterMissing(BzrBadParameter):
995
"""Parameter $(param)s is required but not present."""
1422
_fmt = "Parameter $(param)s is required but not present."
998
1425
class BzrBadParameterUnicode(BzrBadParameter):
999
"""Parameter %(param)s is unicode but only byte-strings are permitted."""
1427
_fmt = "Parameter %(param)s is unicode but only byte-strings are permitted."
1002
1430
class BzrBadParameterContainsNewline(BzrBadParameter):
1003
"""Parameter %(param)s contains a newline."""
1006
class DependencyNotPresent(BzrNewError):
1007
"""Unable to import library "%(library)s": %(error)s"""
1432
_fmt = "Parameter %(param)s contains a newline."
1435
class DependencyNotPresent(BzrError):
1437
_fmt = 'Unable to import library "%(library)s": %(error)s'
1009
1439
def __init__(self, library, error):
1010
BzrNewError.__init__(self, library=library, error=error)
1440
BzrError.__init__(self, library=library, error=error)
1013
1443
class ParamikoNotPresent(DependencyNotPresent):
1014
"""Unable to import paramiko (required for sftp support): %(error)s"""
1445
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1016
1447
def __init__(self, error):
1017
1448
DependencyNotPresent.__init__(self, 'paramiko', error)
1020
class PointlessMerge(BzrNewError):
1021
"""Nothing to merge."""
1024
class UninitializableFormat(BzrNewError):
1025
"""Format %(format)s cannot be initialised by this version of bzr."""
1451
class PointlessMerge(BzrError):
1453
_fmt = "Nothing to merge."
1456
class UninitializableFormat(BzrError):
1458
_fmt = "Format %(format)s cannot be initialised by this version of bzr."
1027
1460
def __init__(self, format):
1028
BzrNewError.__init__(self)
1461
BzrError.__init__(self)
1029
1462
self.format = format
1032
class BadConversionTarget(BzrNewError):
1033
"""Cannot convert to format %(format)s. %(problem)s"""
1465
class BadConversionTarget(BzrError):
1467
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1035
1469
def __init__(self, problem, format):
1036
BzrNewError.__init__(self)
1470
BzrError.__init__(self)
1037
1471
self.problem = problem
1038
1472
self.format = format
1041
class NoDiff(BzrNewError):
1042
"""Diff is not installed on this machine: %(msg)s"""
1475
class NoDiff(BzrError):
1477
_fmt = "Diff is not installed on this machine: %(msg)s"
1044
1479
def __init__(self, msg):
1045
BzrNewError.__init__(self, msg=msg)
1048
class NoDiff3(BzrNewError):
1049
"""Diff3 is not installed on this machine."""
1052
class ExistingLimbo(BzrNewError):
1053
"""This tree contains left-over files from a failed operation.
1054
Please examine %(limbo_dir)s to see if it contains any files you wish to
1055
keep, and delete it when you are done.
1057
def __init__(self, limbo_dir):
1058
BzrNewError.__init__(self)
1059
self.limbo_dir = limbo_dir
1062
class ImmortalLimbo(BzrNewError):
1063
"""Unable to delete transform temporary directory $(limbo_dir)s.
1064
Please examine %(limbo_dir)s to see if it contains any files you wish to
1065
keep, and delete it when you are done.
1067
def __init__(self, limbo_dir):
1068
BzrNewError.__init__(self)
1069
self.limbo_dir = limbo_dir
1072
class OutOfDateTree(BzrNewError):
1073
"""Working tree is out of date, please run 'bzr update'."""
1480
BzrError.__init__(self, msg=msg)
1483
class NoDiff3(BzrError):
1485
_fmt = "Diff3 is not installed on this machine."
1488
class ExistingLimbo(BzrError):
1490
_fmt = """This tree contains left-over files from a failed operation.
1491
Please examine %(limbo_dir)s to see if it contains any files you wish to
1492
keep, and delete it when you are done."""
1494
def __init__(self, limbo_dir):
1495
BzrError.__init__(self)
1496
self.limbo_dir = limbo_dir
1499
class ImmortalLimbo(BzrError):
1501
_fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
1502
Please examine %(limbo_dir)s to see if it contains any files you wish to
1503
keep, and delete it when you are done."""
1505
def __init__(self, limbo_dir):
1506
BzrError.__init__(self)
1507
self.limbo_dir = limbo_dir
1510
class OutOfDateTree(BzrError):
1512
_fmt = "Working tree is out of date, please run 'bzr update'."
1075
1514
def __init__(self, tree):
1076
BzrNewError.__init__(self)
1515
BzrError.__init__(self)
1077
1516
self.tree = tree
1080
class MergeModifiedFormatError(BzrNewError):
1081
"""Error in merge modified format"""
1084
class ConflictFormatError(BzrNewError):
1085
"""Format error in conflict listings"""
1088
class CorruptRepository(BzrNewError):
1089
"""An error has been detected in the repository %(repo_path)s.
1519
class MergeModifiedFormatError(BzrError):
1521
_fmt = "Error in merge modified format"
1524
class ConflictFormatError(BzrError):
1526
_fmt = "Format error in conflict listings"
1529
class CorruptRepository(BzrError):
1531
_fmt = """An error has been detected in the repository %(repo_path)s.
1090
1532
Please run bzr reconcile on this repository."""
1092
1534
def __init__(self, repo):
1093
BzrNewError.__init__(self)
1535
BzrError.__init__(self)
1094
1536
self.repo_path = repo.bzrdir.root_transport.base
1097
class UpgradeRequired(BzrNewError):
1098
"""To use this feature you must upgrade your branch at %(path)s."""
1539
class UpgradeRequired(BzrError):
1541
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1100
1543
def __init__(self, path):
1101
BzrNewError.__init__(self)
1544
BzrError.__init__(self)
1102
1545
self.path = path
1105
class LocalRequiresBoundBranch(BzrNewError):
1106
"""Cannot perform local-only commits on unbound branches."""
1109
class MissingProgressBarFinish(BzrNewError):
1110
"""A nested progress bar was not 'finished' correctly."""
1113
class InvalidProgressBarType(BzrNewError):
1114
"""Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1548
class LocalRequiresBoundBranch(BzrError):
1550
_fmt = "Cannot perform local-only commits on unbound branches."
1553
class MissingProgressBarFinish(BzrError):
1555
_fmt = "A nested progress bar was not 'finished' correctly."
1558
class InvalidProgressBarType(BzrError):
1560
_fmt = """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1115
1561
Select one of: %(valid_types)s"""
1117
1563
def __init__(self, bar_type, valid_types):
1118
BzrNewError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1121
class UnsupportedOperation(BzrNewError):
1122
"""The method %(mname)s is not supported on objects of type %(tname)s."""
1564
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1567
class UnsupportedOperation(BzrError):
1569
_fmt = "The method %(mname)s is not supported on objects of type %(tname)s."
1123
1571
def __init__(self, method, method_self):
1124
1572
self.method = method
1125
1573
self.mname = method.__name__
1126
1574
self.tname = type(method_self).__name__
1129
class BinaryFile(BzrNewError):
1130
"""File is binary but should be text."""
1133
class IllegalPath(BzrNewError):
1134
"""The path %(path)s is not permitted on this platform"""
1577
class CannotSetRevisionId(UnsupportedOperation):
1578
"""Raised when a commit is attempting to set a revision id but cant."""
1581
class NonAsciiRevisionId(UnsupportedOperation):
1582
"""Raised when a commit is attempting to set a non-ascii revision id but cant."""
1585
class BinaryFile(BzrError):
1587
_fmt = "File is binary but should be text."
1590
class IllegalPath(BzrError):
1592
_fmt = "The path %(path)s is not permitted on this platform"
1136
1594
def __init__(self, path):
1137
BzrNewError.__init__(self)
1595
BzrError.__init__(self)
1138
1596
self.path = path
1141
class TestamentMismatch(BzrNewError):
1142
"""Testament did not match expected value.
1599
class TestamentMismatch(BzrError):
1601
_fmt = """Testament did not match expected value.
1143
1602
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1146
1605
def __init__(self, revision_id, expected, measured):
1147
1606
self.revision_id = revision_id
1148
1607
self.expected = expected
1149
1608
self.measured = measured
1152
class NotABundle(BzrNewError):
1153
"""Not a bzr revision-bundle: %(text)r"""
1611
class NotABundle(BzrError):
1613
_fmt = "Not a bzr revision-bundle: %(text)r"
1155
1615
def __init__(self, text):
1156
BzrNewError.__init__(self)
1616
BzrError.__init__(self)
1157
1617
self.text = text
1160
class BadBundle(BzrNewError):
1161
"""Bad bzr revision-bundle: %(text)r"""
1620
class BadBundle(BzrError):
1622
_fmt = "Bad bzr revision-bundle: %(text)r"
1163
1624
def __init__(self, text):
1164
BzrNewError.__init__(self)
1625
BzrError.__init__(self)
1165
1626
self.text = text
1168
1629
class MalformedHeader(BadBundle):
1169
"""Malformed bzr revision-bundle header: %(text)r"""
1171
def __init__(self, text):
1172
BzrNewError.__init__(self)
1631
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1176
1634
class MalformedPatches(BadBundle):
1177
"""Malformed patches in bzr revision-bundle: %(text)r"""
1179
def __init__(self, text):
1180
BzrNewError.__init__(self)
1636
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1184
1639
class MalformedFooter(BadBundle):
1185
"""Malformed footer in bzr revision-bundle: %(text)r"""
1187
def __init__(self, text):
1188
BzrNewError.__init__(self)
1641
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1192
1644
class UnsupportedEOLMarker(BadBundle):
1193
"""End of line marker was not \\n in bzr revision-bundle"""
1646
_fmt = "End of line marker was not \\n in bzr revision-bundle"
1195
1648
def __init__(self):
1196
BzrNewError.__init__(self)
1199
class IncompatibleFormat(BzrNewError):
1200
"""Bundle format %(bundle_format)s is incompatible with %(other)s"""
1649
# XXX: BadBundle's constructor assumes there's explanatory text,
1650
# but for this there is not
1651
BzrError.__init__(self)
1654
class IncompatibleBundleFormat(BzrError):
1656
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1202
1658
def __init__(self, bundle_format, other):
1203
BzrNewError.__init__(self)
1659
BzrError.__init__(self)
1204
1660
self.bundle_format = bundle_format
1205
1661
self.other = other
1208
class BadInventoryFormat(BzrNewError):
1209
"""Root class for inventory serialization errors"""
1664
class BadInventoryFormat(BzrError):
1666
_fmt = "Root class for inventory serialization errors"
1212
1669
class UnexpectedInventoryFormat(BadInventoryFormat):
1213
"""The inventory was not in the expected format:\n %(msg)s"""
1671
_fmt = "The inventory was not in the expected format:\n %(msg)s"
1215
1673
def __init__(self, msg):
1216
1674
BadInventoryFormat.__init__(self, msg=msg)
1677
class NoSmartMedium(BzrError):
1679
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1680
internal_error = True
1682
def __init__(self, transport):
1683
self.transport = transport
1219
1686
class NoSmartServer(NotBranchError):
1220
"""No smart server available at %(url)s"""
1688
_fmt = "No smart server available at %(url)s"
1222
1690
def __init__(self, url):
1226
class UnknownSSH(BzrNewError):
1227
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1694
class UnknownSSH(BzrError):
1696
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
1229
1698
def __init__(self, vendor):
1230
BzrNewError.__init__(self)
1699
BzrError.__init__(self)
1231
1700
self.vendor = vendor
1234
class GhostRevisionUnusableHere(BzrNewError):
1235
"""Ghost revision {%(revision_id)s} cannot be used here."""
1703
class GhostRevisionUnusableHere(BzrError):
1705
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1237
1707
def __init__(self, revision_id):
1238
BzrNewError.__init__(self)
1708
BzrError.__init__(self)
1239
1709
self.revision_id = revision_id
1242
class IllegalUseOfScopeReplacer(BzrNewError):
1243
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1245
is_user_error = False
1712
class IllegalUseOfScopeReplacer(BzrError):
1714
_fmt = "ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"
1716
internal_error = True
1247
1718
def __init__(self, name, msg, extra=None):
1248
BzrNewError.__init__(self)
1719
BzrError.__init__(self)
1249
1720
self.name = name