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
123
def __init__(self, **kwds):
134
def __init__(self, *args, **kwds):
135
# XXX: Use the underlying BzrError to always generate the args attribute
136
# if it doesn't exist. We can't use super here, because exceptions are
137
# old-style classes in python2.4 (but new in 2.5). --bmc, 20060426
138
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
139
'please convert %s to use BzrError instead'
140
% self.__class__.__name__,
143
BzrError.__init__(self, *args)
124
144
for key, value in kwds.items():
125
145
setattr(self, key, value)
127
147
def __str__(self):
129
return self.__doc__ % self.__dict__
130
except (NameError, ValueError, KeyError), e:
131
return 'Unprintable exception %s: %s' \
132
% (self.__class__.__name__, str(e))
135
class BzrCheckError(BzrNewError):
136
"""Internal check failed: %(message)s"""
138
is_user_error = False
149
# __str__() should always return a 'str' object
150
# never a 'unicode' object.
151
s = self.__doc__ % self.__dict__
152
if isinstance(s, unicode):
153
return s.encode('utf8')
155
except (TypeError, NameError, ValueError, KeyError), e:
156
return 'Unprintable exception %s(%r): %s' \
157
% (self.__class__.__name__,
158
self.__dict__, str(e))
161
class AlreadyBuilding(BzrError):
163
_fmt = "The tree builder is already building a tree."
166
class BzrCheckError(BzrError):
168
_fmt = "Internal check failed: %(message)s"
170
internal_error = True
140
172
def __init__(self, message):
141
BzrNewError.__init__(self)
173
BzrError.__init__(self)
142
174
self.message = message
145
class InvalidEntryName(BzrNewError):
146
"""Invalid entry name: %(name)s"""
177
class InvalidEntryName(BzrError):
179
_fmt = "Invalid entry name: %(name)s"
148
is_user_error = False
181
internal_error = True
150
183
def __init__(self, name):
151
BzrNewError.__init__(self)
184
BzrError.__init__(self)
155
class InvalidRevisionNumber(BzrNewError):
156
"""Invalid revision number %(revno)d"""
188
class InvalidRevisionNumber(BzrError):
190
_fmt = "Invalid revision number %(revno)s"
157
192
def __init__(self, revno):
158
BzrNewError.__init__(self)
193
BzrError.__init__(self)
159
194
self.revno = revno
162
class InvalidRevisionId(BzrNewError):
163
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
197
class InvalidRevisionId(BzrError):
199
_fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
164
201
def __init__(self, revision_id, branch):
165
202
# branch can be any string or object with __str__ defined
166
BzrNewError.__init__(self)
203
BzrError.__init__(self)
167
204
self.revision_id = revision_id
168
205
self.branch = branch
171
class NoWorkingTree(BzrNewError):
172
"""No WorkingTree exists for %(base)s."""
207
class ReservedId(BzrError):
209
_fmt = "Reserved revision-id {%(revision_id)s}"
211
def __init__(self, revision_id):
212
self.revision_id = revision_id
214
class NoSuchId(BzrError):
216
_fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
218
def __init__(self, tree, file_id):
219
BzrError.__init__(self)
220
self.file_id = file_id
224
class InventoryModified(BzrError):
226
_fmt = ("The current inventory for the tree %(tree)r has been modified, "
227
"so a clean inventory cannot be read without data loss.")
229
internal_error = True
231
def __init__(self, tree):
235
class NoWorkingTree(BzrError):
237
_fmt = "No WorkingTree exists for %(base)s."
174
239
def __init__(self, base):
175
BzrNewError.__init__(self)
240
BzrError.__init__(self)
179
class NotLocalUrl(BzrNewError):
180
"""%(url)s is not a local path."""
244
class NotBuilding(BzrError):
246
_fmt = "Not currently building a tree."
249
class NotLocalUrl(BzrError):
251
_fmt = "%(url)s is not a local path."
182
253
def __init__(self, url):
183
BzrNewError.__init__(self)
187
class BzrCommandError(BzrNewError):
257
class WorkingTreeAlreadyPopulated(BzrError):
259
_fmt = """Working tree already populated in %(base)s"""
261
internal_error = True
263
def __init__(self, base):
266
class BzrCommandError(BzrError):
188
267
"""Error from user command"""
269
internal_error = False
192
271
# Error from malformed user command; please avoid raising this as a
193
272
# generic exception not caused by user input.
298
472
class AlreadyBranchError(PathError):
299
"""Already a branch: %(path)s."""
474
_fmt = "Already a branch: %(path)s."
302
477
class BranchExistsWithoutWorkingTree(PathError):
303
"""Directory contains a branch, but no working tree \
304
(use bzr checkout if you wish to build a working tree): %(path)s"""
307
class NoRepositoryPresent(BzrNewError):
308
"""No repository present: %(path)r"""
479
_fmt = "Directory contains a branch, but no working tree \
480
(use bzr checkout if you wish to build a working tree): %(path)s"
483
class AtomicFileAlreadyClosed(PathError):
485
_fmt = "'%(function)s' called on an AtomicFile after it was closed: %(path)s"
487
def __init__(self, path, function):
488
PathError.__init__(self, path=path, extra=None)
489
self.function = function
492
class InaccessibleParent(PathError):
494
_fmt = "Parent not accessible given base %(base)s and relative path %(path)s"
496
def __init__(self, path, base):
497
PathError.__init__(self, path)
501
class NoRepositoryPresent(BzrError):
503
_fmt = "No repository present: %(path)r"
309
504
def __init__(self, bzrdir):
310
BzrNewError.__init__(self)
505
BzrError.__init__(self)
311
506
self.path = bzrdir.transport.clone('..').base
314
class FileInWrongBranch(BzrNewError):
315
"""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."
317
513
def __init__(self, branch, path):
318
BzrNewError.__init__(self)
514
BzrError.__init__(self)
319
515
self.branch = branch
320
516
self.branch_base = branch.base
324
class UnsupportedFormatError(BzrNewError):
325
"""Unsupported branch format: %(format)s"""
328
class UnknownFormatError(BzrNewError):
329
"""Unknown branch format: %(format)r"""
332
class IncompatibleFormat(BzrNewError):
333
"""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."
335
534
def __init__(self, format, bzrdir_format):
336
BzrNewError.__init__(self)
535
BzrError.__init__(self)
337
536
self.format = format
338
537
self.bzrdir = bzrdir_format
341
class NotVersionedError(BzrNewError):
342
"""%(path)s is not versioned"""
343
def __init__(self, path):
344
BzrNewError.__init__(self)
348
class PathsNotVersionedError(BzrNewError):
349
# used when reporting several paths are not versioned
350
"""Path(s) are not versioned: %(paths_as_string)s"""
540
class IncompatibleRevision(BzrError):
542
_fmt = "Revision is not compatible with %(repo_format)s"
544
def __init__(self, repo_format):
545
BzrError.__init__(self)
546
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 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"
352
596
def __init__(self, paths):
353
597
from bzrlib.osutils import quotefn
354
BzrNewError.__init__(self)
598
BzrError.__init__(self)
355
599
self.paths = paths
356
600
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
359
class PathsDoNotExist(BzrNewError):
360
"""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"
362
607
# used when reporting that paths are neither versioned nor in the working
365
def __init__(self, paths):
610
def __init__(self, paths, extra=None):
366
611
# circular import
367
612
from bzrlib.osutils import quotefn
368
BzrNewError.__init__(self)
613
BzrError.__init__(self)
369
614
self.paths = paths
370
615
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
373
class BadFileKindError(BzrNewError):
374
"""Cannot operate on %(filename)s of unsupported kind %(kind)s"""
377
class ForbiddenControlFileError(BzrNewError):
378
"""Cannot operate on %(filename)s because it is a control file"""
381
class LockError(BzrNewError):
382
"""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
383
638
# All exceptions from the lock/unlock functions should be from
384
639
# this exception class. They will be translated as necessary. The
385
640
# original exception is available as e.original_error
795
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
798
1213
class SigningFailed(BzrError):
1215
_fmt = "Failed to gpg sign data with command %(command_line)r"
799
1217
def __init__(self, command_line):
800
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
1218
BzrError.__init__(self, command_line=command_line)
804
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"
805
1227
def __init__(self, tree):
806
BzrError.__init__(self, "The working tree for %s has changed since"
807
" last commit, but weave merge requires that it be"
808
" unchanged." % tree.basedir)
811
class CantReprocessAndShowBase(BzrNewError):
812
"""Can't reprocess and show base.
813
Reprocessing obscures relationship of conflicting lines to base."""
816
class GraphCycleError(BzrNewError):
817
"""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"
818
1241
def __init__(self, graph):
819
BzrNewError.__init__(self)
1242
BzrError.__init__(self)
820
1243
self.graph = graph
823
class NotConflicted(BzrNewError):
824
"""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."
826
1273
def __init__(self, filename):
827
BzrNewError.__init__(self)
1274
BzrError.__init__(self)
828
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
831
1288
class MustUseDecorated(Exception):
832
"""A decorating function has requested its original command be used.
834
This should never escape bzr, so does not need to be printable.
838
class NoBundleFound(BzrNewError):
839
"""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"
840
1297
def __init__(self, filename):
841
BzrNewError.__init__(self)
1298
BzrError.__init__(self)
842
1299
self.filename = filename
845
class BundleNotSupported(BzrNewError):
846
"""Unable to handle bundle version %(version)s: %(msg)s"""
1302
class BundleNotSupported(BzrError):
1304
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
847
1306
def __init__(self, version, msg):
848
BzrNewError.__init__(self)
1307
BzrError.__init__(self)
849
1308
self.version = version
853
class MissingText(BzrNewError):
854
"""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"
856
1316
def __init__(self, branch, text_revision, file_id):
857
BzrNewError.__init__(self)
1317
BzrError.__init__(self)
858
1318
self.branch = branch
859
1319
self.base = branch.base
860
1320
self.text_revision = text_revision
861
1321
self.file_id = file_id
864
class DuplicateKey(BzrNewError):
865
"""Key %(key)s is already present in map"""
868
class MalformedTransform(BzrNewError):
869
"""Tree transform is malformed %(conflicts)r"""
872
class BzrBadParameter(BzrNewError):
873
"""A bad parameter : %(param)s is not usable.
875
This exception should never be thrown, but it is a base class for all
876
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.
878
1353
def __init__(self, param):
879
BzrNewError.__init__(self)
1354
BzrError.__init__(self)
880
1355
self.param = param
883
1358
class BzrBadParameterNotUnicode(BzrBadParameter):
884
"""Parameter %(param)s is neither unicode nor utf8."""
887
class ReusingTransform(BzrNewError):
888
"""Attempt to reuse a transform that has already been applied."""
891
class CantMoveRoot(BzrNewError):
892
"""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)
895
1415
class BzrBadParameterNotString(BzrBadParameter):
896
"""Parameter %(param)s is not a string or unicode string."""
1417
_fmt = "Parameter %(param)s is not a string or unicode string."
899
1420
class BzrBadParameterMissing(BzrBadParameter):
900
"""Parameter $(param)s is required but not present."""
1422
_fmt = "Parameter $(param)s is required but not present."
903
1425
class BzrBadParameterUnicode(BzrBadParameter):
904
"""Parameter %(param)s is unicode but only byte-strings are permitted."""
1427
_fmt = "Parameter %(param)s is unicode but only byte-strings are permitted."
907
1430
class BzrBadParameterContainsNewline(BzrBadParameter):
908
"""Parameter %(param)s contains a newline."""
911
class DependencyNotPresent(BzrNewError):
912
"""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'
914
1439
def __init__(self, library, error):
915
BzrNewError.__init__(self, library=library, error=error)
1440
BzrError.__init__(self, library=library, error=error)
918
1443
class ParamikoNotPresent(DependencyNotPresent):
919
"""Unable to import paramiko (required for sftp support): %(error)s"""
1445
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
921
1447
def __init__(self, error):
922
1448
DependencyNotPresent.__init__(self, 'paramiko', error)
925
class UninitializableFormat(BzrNewError):
926
"""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."
928
1460
def __init__(self, format):
929
BzrNewError.__init__(self)
933
class NoDiff(BzrNewError):
934
"""Diff is not installed on this machine: %(msg)s"""
1461
BzrError.__init__(self)
1462
self.format = format
1465
class BadConversionTarget(BzrError):
1467
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1469
def __init__(self, problem, format):
1470
BzrError.__init__(self)
1471
self.problem = problem
1472
self.format = format
1475
class NoDiff(BzrError):
1477
_fmt = "Diff is not installed on this machine: %(msg)s"
936
1479
def __init__(self, msg):
937
BzrNewError.__init__(self, msg=msg)
940
class NoDiff3(BzrNewError):
941
"""Diff3 is not installed on this machine."""
944
class ExistingLimbo(BzrNewError):
945
"""This tree contains left-over files from a failed operation.
946
Please examine %(limbo_dir)s to see if it contains any files you wish to
947
keep, and delete it when you are done.
949
def __init__(self, limbo_dir):
950
BzrNewError.__init__(self)
951
self.limbo_dir = limbo_dir
954
class ImmortalLimbo(BzrNewError):
955
"""Unable to delete transform temporary directory $(limbo_dir)s.
956
Please examine %(limbo_dir)s to see if it contains any files you wish to
957
keep, and delete it when you are done.
959
def __init__(self, limbo_dir):
960
BzrNewError.__init__(self)
961
self.limbo_dir = limbo_dir
964
class OutOfDateTree(BzrNewError):
965
"""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'."
967
1514
def __init__(self, tree):
968
BzrNewError.__init__(self)
1515
BzrError.__init__(self)
969
1516
self.tree = tree
972
class MergeModifiedFormatError(BzrNewError):
973
"""Error in merge modified format"""
976
class ConflictFormatError(BzrNewError):
977
"""Format error in conflict listings"""
980
class CorruptRepository(BzrNewError):
981
"""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.
982
1532
Please run bzr reconcile on this repository."""
984
1534
def __init__(self, repo):
985
BzrNewError.__init__(self)
1535
BzrError.__init__(self)
986
1536
self.repo_path = repo.bzrdir.root_transport.base
989
class UpgradeRequired(BzrNewError):
990
"""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."
992
1543
def __init__(self, path):
993
BzrNewError.__init__(self)
1544
BzrError.__init__(self)
994
1545
self.path = path
997
class LocalRequiresBoundBranch(BzrNewError):
998
"""Cannot perform local-only commits on unbound branches."""
1001
class MissingProgressBarFinish(BzrNewError):
1002
"""A nested progress bar was not 'finished' correctly."""
1005
class InvalidProgressBarType(BzrNewError):
1006
"""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
1007
1561
Select one of: %(valid_types)s"""
1009
1563
def __init__(self, bar_type, valid_types):
1010
BzrNewError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1013
class UnsupportedOperation(BzrNewError):
1014
"""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."
1015
1571
def __init__(self, method, method_self):
1016
1572
self.method = method
1017
1573
self.mname = method.__name__
1018
1574
self.tname = type(method_self).__name__
1021
class BinaryFile(BzrNewError):
1022
"""File is binary but should be text."""
1025
class IllegalPath(BzrNewError):
1026
"""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"
1028
1594
def __init__(self, path):
1029
BzrNewError.__init__(self)
1595
BzrError.__init__(self)
1030
1596
self.path = path
1033
class TestamentMismatch(BzrNewError):
1034
"""Testament did not match expected value.
1599
class TestamentMismatch(BzrError):
1601
_fmt = """Testament did not match expected value.
1035
1602
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1038
1605
def __init__(self, revision_id, expected, measured):
1039
1606
self.revision_id = revision_id
1040
1607
self.expected = expected
1041
1608
self.measured = measured
1044
class NotABundle(BzrNewError):
1045
"""Not a bzr revision-bundle: %(text)r"""
1047
def __init__(self, text):
1051
class BadBundle(Exception): pass
1054
class MalformedHeader(BadBundle): pass
1057
class MalformedPatches(BadBundle): pass
1060
class MalformedFooter(BadBundle): pass
1611
class NotABundle(BzrError):
1613
_fmt = "Not a bzr revision-bundle: %(text)r"
1615
def __init__(self, text):
1616
BzrError.__init__(self)
1620
class BadBundle(BzrError):
1622
_fmt = "Bad bzr revision-bundle: %(text)r"
1624
def __init__(self, text):
1625
BzrError.__init__(self)
1629
class MalformedHeader(BadBundle):
1631
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1634
class MalformedPatches(BadBundle):
1636
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1639
class MalformedFooter(BadBundle):
1641
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1644
class UnsupportedEOLMarker(BadBundle):
1646
_fmt = "End of line marker was not \\n in bzr revision-bundle"
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"
1658
def __init__(self, bundle_format, other):
1659
BzrError.__init__(self)
1660
self.bundle_format = bundle_format
1664
class BadInventoryFormat(BzrError):
1666
_fmt = "Root class for inventory serialization errors"
1669
class UnexpectedInventoryFormat(BadInventoryFormat):
1671
_fmt = "The inventory was not in the expected format:\n %(msg)s"
1673
def __init__(self, msg):
1674
BadInventoryFormat.__init__(self, msg=msg)
1677
class NoSmartMedium(BzrError):
1679
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1681
def __init__(self, transport):
1682
self.transport = transport
1685
class NoSmartServer(NotBranchError):
1687
_fmt = "No smart server available at %(url)s"
1689
def __init__(self, url):
1693
class UnknownSSH(BzrError):
1695
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
1697
def __init__(self, vendor):
1698
BzrError.__init__(self)
1699
self.vendor = vendor
1702
class GhostRevisionUnusableHere(BzrError):
1704
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1706
def __init__(self, revision_id):
1707
BzrError.__init__(self)
1708
self.revision_id = revision_id
1711
class IllegalUseOfScopeReplacer(BzrError):
1713
_fmt = "ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"
1715
internal_error = True
1717
def __init__(self, name, msg, extra=None):
1718
BzrError.__init__(self)
1722
self.extra = ': ' + str(extra)
1727
class InvalidImportLine(BzrError):
1729
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
1731
internal_error = True
1733
def __init__(self, text, msg):
1734
BzrError.__init__(self)
1739
class ImportNameCollision(BzrError):
1741
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
1743
internal_error = True
1745
def __init__(self, name):
1746
BzrError.__init__(self)