1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
# -*- coding: UTF-8 -*-
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
5
6
# the Free Software Foundation; either version 2 of the License, or
6
7
# (at your option) any later version.
8
9
# This program is distributed in the hope that it will be useful,
9
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
12
# GNU General Public License for more details.
13
14
# You should have received a copy of the GNU General Public License
14
15
# along with this program; if not, write to the Free Software
15
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Exceptions for bzr, and reporting of them.
25
from bzrlib.patches import (
34
# TODO: is there any value in providing the .args field used by standard
35
# python exceptions? A list of values with no names seems less useful
38
# TODO: Perhaps convert the exception to a string at the moment it's
39
# constructed to make sure it will succeed. But that says nothing about
40
# 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
19
__copyright__ = "Copyright (C) 2005 Canonical Ltd."
20
__author__ = "Martin Pool <mbp@canonical.com>"
23
######################################################################
47
25
class BzrError(StandardError):
49
Base class for errors raised by bzrlib.
51
:cvar internal_error: if True this was probably caused by a bzr bug and
52
should be displayed with a traceback; if False (or absent) this was
53
probably a user or environment error and they don't need the gory details.
54
(That can be overridden by -Derror on the command line.)
56
:cvar _fmt: Format string to display the error; this is expanded
57
by the instance's dict.
60
internal_error = False
62
def __init__(self, msg=None, **kwds):
63
"""Construct a new BzrError.
65
There are two alternative forms for constructing these objects.
66
Either a preformatted string may be passed, or a set of named
67
arguments can be given. The first is for generic "user" errors which
68
are not intended to be caught and so do not need a specific subclass.
69
The second case is for use with subclasses that provide a _fmt format
70
string to print the arguments.
72
Keyword arguments are taken as parameters to the error, which can
73
be inserted into the format string template. It's recommended
74
that subclasses override the __init__ method to require specific
77
:param msg: If given, this is the literal complete text for the error,
78
not subject to expansion.
80
StandardError.__init__(self)
82
# I was going to deprecate this, but it actually turns out to be
83
# quite handy - mbp 20061103.
84
self._preformatted_string = msg
86
self._preformatted_string = None
87
for key, value in kwds.items():
88
setattr(self, key, value)
91
s = getattr(self, '_preformatted_string', None)
93
# contains a preformatted message; must be cast to plain str
96
fmt = self._get_format_string()
98
s = fmt % self.__dict__
99
# __str__() should always return a 'str' object
100
# never a 'unicode' object.
101
if isinstance(s, unicode):
102
return s.encode('utf8')
104
except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
105
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
106
% (self.__class__.__name__,
108
getattr(self, '_fmt', None),
111
def _get_format_string(self):
112
"""Return format string for this exception or None"""
113
fmt = getattr(self, '_fmt', None)
116
fmt = getattr(self, '__doc__', None)
118
symbol_versioning.warn("%s uses its docstring as a format, "
119
"it should use _fmt instead" % self.__class__.__name__,
122
return 'Unprintable exception %s: dict=%r, fmt=%r' \
123
% (self.__class__.__name__,
125
getattr(self, '_fmt', None),
129
class BzrNewError(BzrError):
130
"""Deprecated error base class."""
131
# base classes should override the docstring with their human-
132
# 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)
145
for key, value in kwds.items():
146
setattr(self, key, value)
150
# __str__() should always return a 'str' object
151
# never a 'unicode' object.
152
s = self.__doc__ % self.__dict__
153
if isinstance(s, unicode):
154
return s.encode('utf8')
156
except (TypeError, NameError, ValueError, KeyError), e:
157
return 'Unprintable exception %s(%r): %r' \
158
% (self.__class__.__name__,
162
class AlreadyBuilding(BzrError):
164
_fmt = "The tree builder is already building a tree."
167
28
class BzrCheckError(BzrError):
169
_fmt = "Internal check failed: %(message)s"
171
internal_error = True
173
def __init__(self, message):
174
BzrError.__init__(self)
175
self.message = message
178
class DisabledMethod(BzrError):
180
_fmt = "The smart server method '%(class_name)s' is disabled."
182
internal_error = True
184
def __init__(self, class_name):
185
BzrError.__init__(self)
186
self.class_name = class_name
189
class IncompatibleAPI(BzrError):
191
_fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
192
'It supports versions "%(minimum)s" to "%(current)s".'
194
def __init__(self, api, wanted, minimum, current):
197
self.minimum = minimum
198
self.current = current
201
class InProcessTransport(BzrError):
203
_fmt = "The transport '%(transport)s' is only accessible within this " \
206
def __init__(self, transport):
207
self.transport = transport
210
class InvalidEntryName(BzrError):
212
_fmt = "Invalid entry name: %(name)s"
214
internal_error = True
216
def __init__(self, name):
217
BzrError.__init__(self)
221
class InvalidRevisionNumber(BzrError):
223
_fmt = "Invalid revision number %(revno)s"
225
def __init__(self, revno):
226
BzrError.__init__(self)
230
class InvalidRevisionId(BzrError):
232
_fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
234
def __init__(self, revision_id, branch):
235
# branch can be any string or object with __str__ defined
236
BzrError.__init__(self)
237
self.revision_id = revision_id
240
class ReservedId(BzrError):
242
_fmt = "Reserved revision-id {%(revision_id)s}"
244
def __init__(self, revision_id):
245
self.revision_id = revision_id
248
class NoHelpTopic(BzrError):
250
_fmt = ("No help could be found for '%(topic)s'. "
251
"Please use 'bzr help topics' to obtain a list of topics.")
253
def __init__(self, topic):
257
class NoSuchId(BzrError):
259
_fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
261
def __init__(self, tree, file_id):
262
BzrError.__init__(self)
263
self.file_id = file_id
267
class InventoryModified(BzrError):
269
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
270
" so a clean inventory cannot be read without data loss.")
272
internal_error = True
274
def __init__(self, tree):
278
class NoWorkingTree(BzrError):
280
_fmt = "No WorkingTree exists for %(base)s."
282
def __init__(self, base):
283
BzrError.__init__(self)
287
class NotBuilding(BzrError):
289
_fmt = "Not currently building a tree."
292
class NotLocalUrl(BzrError):
294
_fmt = "%(url)s is not a local path."
296
def __init__(self, url):
300
class WorkingTreeAlreadyPopulated(BzrError):
302
_fmt = """Working tree already populated in %(base)s"""
304
internal_error = True
306
def __init__(self, base):
309
32
class BzrCommandError(BzrError):
310
"""Error from user command"""
312
internal_error = False
314
# Error from malformed user command; please avoid raising this as a
315
# generic exception not caused by user input.
317
# I think it's a waste of effort to differentiate between errors that
318
# are not intended to be caught anyway. UI code need not subclass
319
# BzrCommandError, and non-UI code should not throw a subclass of
320
# BzrCommandError. ADHB 20051211
321
def __init__(self, msg):
322
# Object.__str__() must return a real string
323
# returning a Unicode string is a python error.
324
if isinstance(msg, unicode):
325
self.msg = msg.encode('utf8')
333
class NotWriteLocked(BzrError):
335
_fmt = """%(not_locked)r is not write locked but needs to be."""
337
def __init__(self, not_locked):
338
self.not_locked = not_locked
341
class BzrOptionError(BzrCommandError):
343
_fmt = "Error in command line options"
346
class BadOptionValue(BzrError):
348
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
350
def __init__(self, name, value):
351
BzrError.__init__(self, name=name, value=value)
354
class StrictCommitFailed(BzrError):
356
_fmt = "Commit refused because there are unknown files in the tree"
359
# XXX: Should be unified with TransportError; they seem to represent the
361
# RBC 20060929: I think that unifiying with TransportError would be a mistake
362
# - this is finer than a TransportError - and more useful as such. It
363
# differentiates between 'transport has failed' and 'operation on a transport
365
class PathError(BzrError):
367
_fmt = "Generic path error: %(path)r%(extra)s)"
369
def __init__(self, path, extra=None):
370
BzrError.__init__(self)
373
self.extra = ': ' + str(extra)
378
class NoSuchFile(PathError):
380
_fmt = "No such file: %(path)r%(extra)s"
383
class FileExists(PathError):
385
_fmt = "File exists: %(path)r%(extra)s"
388
class RenameFailedFilesExist(BzrError):
389
"""Used when renaming and both source and dest exist."""
391
_fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
394
def __init__(self, source, dest, extra=None):
395
BzrError.__init__(self)
396
self.source = str(source)
397
self.dest = str(dest)
399
self.extra = ' ' + str(extra)
404
class NotADirectory(PathError):
406
_fmt = "%(path)r is not a directory %(extra)s"
409
class NotInWorkingDirectory(PathError):
411
_fmt = "%(path)r is not in the working directory %(extra)s"
414
class DirectoryNotEmpty(PathError):
416
_fmt = "Directory not empty: %(path)r%(extra)s"
419
class ReadingCompleted(BzrError):
421
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
422
"called upon it - the request has been completed and no more "
425
internal_error = True
427
def __init__(self, request):
428
self.request = request
431
class ResourceBusy(PathError):
433
_fmt = "Device or resource busy: %(path)r%(extra)s"
436
class PermissionDenied(PathError):
438
_fmt = "Permission denied: %(path)r%(extra)s"
441
class InvalidURL(PathError):
443
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
446
class InvalidURLJoin(PathError):
448
_fmt = "Invalid URL join request: %(args)s%(extra)s"
450
def __init__(self, msg, base, args):
451
PathError.__init__(self, base, msg)
452
self.args = [base] + list(args)
455
class UnknownHook(BzrError):
457
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
459
def __init__(self, hook_type, hook_name):
460
BzrError.__init__(self)
461
self.type = hook_type
462
self.hook = hook_name
465
class UnsupportedProtocol(PathError):
467
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
469
def __init__(self, url, extra):
470
PathError.__init__(self, url, extra=extra)
473
class ReadError(PathError):
475
_fmt = """Error reading from %(path)r."""
478
class ShortReadvError(PathError):
480
_fmt = ("readv() read %(actual)s bytes rather than %(length)s bytes"
481
" at %(offset)s for %(path)s%(extra)s")
483
internal_error = True
485
def __init__(self, path, offset, length, actual, extra=None):
486
PathError.__init__(self, path, extra=extra)
492
class PathNotChild(BzrError):
494
_fmt = "Path %(path)r is not a child of path %(base)r%(extra)s"
496
internal_error = True
498
def __init__(self, path, base, extra=None):
499
BzrError.__init__(self)
503
self.extra = ': ' + str(extra)
508
class InvalidNormalization(PathError):
510
_fmt = "Path %(path)r is not unicode normalized"
513
# TODO: This is given a URL; we try to unescape it but doing that from inside
514
# the exception object is a bit undesirable.
515
# TODO: Probably this behavior of should be a common superclass
516
class NotBranchError(PathError):
518
_fmt = "Not a branch: %(path)s"
520
def __init__(self, path):
521
import bzrlib.urlutils as urlutils
522
self.path = urlutils.unescape_for_display(path, 'ascii')
525
class NoSubmitBranch(PathError):
527
_fmt = 'No submit branch available for branch "%(path)s"'
529
def __init__(self, branch):
530
import bzrlib.urlutils as urlutils
531
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
534
class AlreadyBranchError(PathError):
536
_fmt = "Already a branch: %(path)s."
539
class BranchExistsWithoutWorkingTree(PathError):
541
_fmt = "Directory contains a branch, but no working tree \
542
(use bzr checkout if you wish to build a working tree): %(path)s"
545
class AtomicFileAlreadyClosed(PathError):
547
_fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
550
def __init__(self, path, function):
551
PathError.__init__(self, path=path, extra=None)
552
self.function = function
555
class InaccessibleParent(PathError):
557
_fmt = ("Parent not accessible given base %(base)s and"
558
" relative path %(path)s")
560
def __init__(self, path, base):
561
PathError.__init__(self, path)
565
class NoRepositoryPresent(BzrError):
567
_fmt = "No repository present: %(path)r"
568
def __init__(self, bzrdir):
569
BzrError.__init__(self)
570
self.path = bzrdir.transport.clone('..').base
573
class FileInWrongBranch(BzrError):
575
_fmt = "File %(path)s in not in branch %(branch_base)s."
577
def __init__(self, branch, path):
578
BzrError.__init__(self)
580
self.branch_base = branch.base
584
class UnsupportedFormatError(BzrError):
586
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
589
class UnknownFormatError(BzrError):
591
_fmt = "Unknown branch format: %(format)r"
594
class IncompatibleFormat(BzrError):
596
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
598
def __init__(self, format, bzrdir_format):
599
BzrError.__init__(self)
601
self.bzrdir = bzrdir_format
604
class IncompatibleRepositories(BzrError):
606
_fmt = "Repository %(target)s is not compatible with repository"\
609
def __init__(self, source, target):
610
BzrError.__init__(self, target=target, source=source)
613
class IncompatibleRevision(BzrError):
615
_fmt = "Revision is not compatible with %(repo_format)s"
617
def __init__(self, repo_format):
618
BzrError.__init__(self)
619
self.repo_format = repo_format
622
class AlreadyVersionedError(BzrError):
623
"""Used when a path is expected not to be versioned, but it is."""
625
_fmt = "%(context_info)s%(path)s is already versioned"
627
def __init__(self, path, context_info=None):
628
"""Construct a new AlreadyVersionedError.
630
:param path: This is the path which is versioned,
631
which should be in a user friendly form.
632
:param context_info: If given, this is information about the context,
633
which could explain why this is expected to not be versioned.
635
BzrError.__init__(self)
637
if context_info is None:
638
self.context_info = ''
640
self.context_info = context_info + ". "
643
class NotVersionedError(BzrError):
644
"""Used when a path is expected to be versioned, but it is not."""
646
_fmt = "%(context_info)s%(path)s is not versioned"
648
def __init__(self, path, context_info=None):
649
"""Construct a new NotVersionedError.
651
:param path: This is the path which is not versioned,
652
which should be in a user friendly form.
653
:param context_info: If given, this is information about the context,
654
which could explain why this is expected to be versioned.
656
BzrError.__init__(self)
658
if context_info is None:
659
self.context_info = ''
661
self.context_info = context_info + ". "
664
class PathsNotVersionedError(BzrError):
665
"""Used when reporting several paths which are not versioned"""
667
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
669
def __init__(self, paths):
670
from bzrlib.osutils import quotefn
671
BzrError.__init__(self)
673
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
676
class PathsDoNotExist(BzrError):
678
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
680
# used when reporting that paths are neither versioned nor in the working
683
def __init__(self, paths, extra=None):
685
from bzrlib.osutils import quotefn
686
BzrError.__init__(self)
688
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
690
self.extra = ': ' + str(extra)
33
# Error from malformed user command
37
class NotBranchError(BzrError):
38
"""Specified path is not in a branch"""
695
42
class BadFileKindError(BzrError):
697
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
699
def __init__(self, filename, kind):
700
BzrError.__init__(self, filename=filename, kind=kind)
703
class ForbiddenControlFileError(BzrError):
705
_fmt = "Cannot operate on %(filename)s because it is a control file"
708
class LockError(BzrError):
710
_fmt = "Lock error: %(msg)s"
712
internal_error = True
714
# All exceptions from the lock/unlock functions should be from
715
# this exception class. They will be translated as necessary. The
716
# original exception is available as e.original_error
718
# New code should prefer to raise specific subclasses
719
def __init__(self, message):
720
# Python 2.5 uses a slot for StandardError.message,
721
# so use a different variable name
722
# so it is exposed in self.__dict__
726
class LockActive(LockError):
728
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
730
internal_error = False
732
def __init__(self, lock_description):
733
self.lock_description = lock_description
736
class CommitNotPossible(LockError):
738
_fmt = "A commit was attempted but we do not have a write lock open."
744
class AlreadyCommitted(LockError):
746
_fmt = "A rollback was requested, but is not able to be accomplished."
752
class ReadOnlyError(LockError):
754
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
756
# TODO: There should also be an error indicating that you need a write
757
# lock and don't have any lock at all... mbp 20070226
759
def __init__(self, obj):
763
class ReadOnlyLockError(LockError):
765
_fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
767
def __init__(self, fname, msg):
768
LockError.__init__(self, '')
773
class OutSideTransaction(BzrError):
775
_fmt = ("A transaction related operation was attempted after"
776
" the transaction finished.")
779
class ObjectNotLocked(LockError):
781
_fmt = "%(obj)r is not locked"
783
# this can indicate that any particular object is not locked; see also
784
# LockNotHeld which means that a particular *lock* object is not held by
785
# the caller -- perhaps they should be unified.
786
def __init__(self, obj):
790
class ReadOnlyObjectDirtiedError(ReadOnlyError):
792
_fmt = "Cannot change object %(obj)r in read only transaction"
794
def __init__(self, obj):
798
class UnlockableTransport(LockError):
800
_fmt = "Cannot lock: transport is read only: %(transport)s"
802
def __init__(self, transport):
803
self.transport = transport
806
class LockContention(LockError):
808
_fmt = "Could not acquire lock %(lock)s"
809
# TODO: show full url for lock, combining the transport and relative
812
internal_error = False
814
def __init__(self, lock):
818
class LockBroken(LockError):
820
_fmt = ("Lock was broken while still open: %(lock)s"
821
" - check storage consistency!")
823
internal_error = False
825
def __init__(self, lock):
829
class LockBreakMismatch(LockError):
831
_fmt = ("Lock was released and re-acquired before being broken:"
832
" %(lock)s: held by %(holder)r, wanted to break %(target)r")
834
internal_error = False
836
def __init__(self, lock, holder, target):
842
class LockNotHeld(LockError):
844
_fmt = "Lock not held: %(lock)s"
846
internal_error = False
848
def __init__(self, lock):
852
class TokenLockingNotSupported(LockError):
854
_fmt = "The object %(obj)s does not support token specifying a token when locking."
856
internal_error = True
858
def __init__(self, obj):
862
class TokenMismatch(LockBroken):
864
_fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
866
internal_error = True
868
def __init__(self, given_token, lock_token):
869
self.given_token = given_token
870
self.lock_token = lock_token
873
class PointlessCommit(BzrError):
875
_fmt = "No changes to commit"
878
class CannotCommitSelectedFileMerge(BzrError):
880
_fmt = 'Selected-file commit of merges is not supported yet:'\
881
' files %(files_str)s'
883
def __init__(self, files):
884
files_str = ', '.join(files)
885
BzrError.__init__(self, files=files, files_str=files_str)
888
class UpgradeReadonly(BzrError):
890
_fmt = "Upgrade URL cannot work with readonly URLs."
893
class UpToDateFormat(BzrError):
895
_fmt = "The branch format %(format)s is already at the most recent format."
897
def __init__(self, format):
898
BzrError.__init__(self)
902
class StrictCommitFailed(Exception):
904
_fmt = "Commit refused because there are unknowns in the tree."
907
class NoSuchRevision(BzrError):
909
_fmt = "Branch %(branch)s has no revision %(revision)s"
911
internal_error = True
913
def __init__(self, branch, revision):
914
BzrError.__init__(self, branch=branch, revision=revision)
917
class NotLeftParentDescendant(BzrError):
919
_fmt = ("Revision %(old_revision)s is not the left parent of"
920
" %(new_revision)s, but branch %(branch_location)s expects this")
922
internal_error = True
924
def __init__(self, branch, old_revision, new_revision):
925
BzrError.__init__(self, branch_location=branch.base,
926
old_revision=old_revision,
927
new_revision=new_revision)
930
class NoSuchRevisionSpec(BzrError):
932
_fmt = "No namespace registered for string: %(spec)r"
934
def __init__(self, spec):
935
BzrError.__init__(self, spec=spec)
938
class NoSuchRevisionInTree(NoSuchRevision):
939
"""When using Tree.revision_tree, and the revision is not accessible."""
941
_fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
943
def __init__(self, tree, revision_id):
944
BzrError.__init__(self)
946
self.revision_id = revision_id
949
class InvalidRevisionSpec(BzrError):
951
_fmt = ("Requested revision: %(spec)r does not exist in branch:"
952
" %(branch)s%(extra)s")
954
def __init__(self, spec, branch, extra=None):
955
BzrError.__init__(self, branch=branch, spec=spec)
957
self.extra = '\n' + str(extra)
962
class HistoryMissing(BzrError):
964
_fmt = "%(branch)s is missing %(object_type)s {%(object_id)s}"
967
class AppendRevisionsOnlyViolation(BzrError):
969
_fmt = ('Operation denied because it would change the main history,'
970
' which is not permitted by the append_revisions_only setting on'
971
' branch "%(location)s".')
973
def __init__(self, location):
974
import bzrlib.urlutils as urlutils
975
location = urlutils.unescape_for_display(location, 'ascii')
976
BzrError.__init__(self, location=location)
979
class DivergedBranches(BzrError):
981
_fmt = ("These branches have diverged."
982
" Use the merge command to reconcile them.")
984
internal_error = False
986
def __init__(self, branch1, branch2):
987
self.branch1 = branch1
988
self.branch2 = branch2
991
class NotLefthandHistory(BzrError):
993
_fmt = "Supplied history does not follow left-hand parents"
995
internal_error = True
997
def __init__(self, history):
998
BzrError.__init__(self, history=history)
1001
class UnrelatedBranches(BzrError):
1003
_fmt = ("Branches have no common ancestor, and"
1004
" no merge base revision was specified.")
1006
internal_error = False
1009
class NoCommonAncestor(BzrError):
1011
_fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1013
def __init__(self, revision_a, revision_b):
1014
self.revision_a = revision_a
1015
self.revision_b = revision_b
1018
class NoCommonRoot(BzrError):
1020
_fmt = ("Revisions are not derived from the same root: "
1021
"%(revision_a)s %(revision_b)s.")
1023
def __init__(self, revision_a, revision_b):
1024
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
1027
class NotAncestor(BzrError):
1029
_fmt = "Revision %(rev_id)s is not an ancestor of %(not_ancestor_id)s"
1031
def __init__(self, rev_id, not_ancestor_id):
1032
BzrError.__init__(self, rev_id=rev_id,
1033
not_ancestor_id=not_ancestor_id)
1036
class InstallFailed(BzrError):
1038
def __init__(self, revisions):
1039
revision_str = ", ".join(str(r) for r in revisions)
1040
msg = "Could not install revisions:\n%s" % revision_str
1041
BzrError.__init__(self, msg)
1042
self.revisions = revisions
1045
class AmbiguousBase(BzrError):
1047
def __init__(self, bases):
1048
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
1050
msg = ("The correct base is unclear, because %s are all equally close"
1052
BzrError.__init__(self, msg)
1056
class NoCommits(BzrError):
1058
_fmt = "Branch %(branch)s has no commits."
1060
def __init__(self, branch):
1061
BzrError.__init__(self, branch=branch)
1064
class UnlistableStore(BzrError):
1066
def __init__(self, store):
1067
BzrError.__init__(self, "Store %s is not listable" % store)
1071
class UnlistableBranch(BzrError):
1073
def __init__(self, br):
1074
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
1077
class BoundBranchOutOfDate(BzrError):
1079
_fmt = ("Bound branch %(branch)s is out of date"
1080
" with master branch %(master)s.")
1082
def __init__(self, branch, master):
1083
BzrError.__init__(self)
1084
self.branch = branch
1085
self.master = master
1088
class CommitToDoubleBoundBranch(BzrError):
1090
_fmt = ("Cannot commit to branch %(branch)s."
1091
" It is bound to %(master)s, which is bound to %(remote)s.")
1093
def __init__(self, branch, master, remote):
1094
BzrError.__init__(self)
1095
self.branch = branch
1096
self.master = master
1097
self.remote = remote
1100
class OverwriteBoundBranch(BzrError):
1102
_fmt = "Cannot pull --overwrite to a branch which is bound %(branch)s"
1104
def __init__(self, branch):
1105
BzrError.__init__(self)
1106
self.branch = branch
1109
class BoundBranchConnectionFailure(BzrError):
1111
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1112
" => %(target)s: %(error)s")
1114
def __init__(self, branch, target, error):
1115
BzrError.__init__(self)
1116
self.branch = branch
1117
self.target = target
1121
class WeaveError(BzrError):
1123
_fmt = "Error in processing weave: %(message)s"
1125
def __init__(self, message=None):
1126
BzrError.__init__(self)
1127
self.message = message
1130
class WeaveRevisionAlreadyPresent(WeaveError):
1132
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1134
def __init__(self, revision_id, weave):
1136
WeaveError.__init__(self)
1137
self.revision_id = revision_id
1141
class WeaveRevisionNotPresent(WeaveError):
1143
_fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1145
def __init__(self, revision_id, weave):
1146
WeaveError.__init__(self)
1147
self.revision_id = revision_id
1151
class WeaveFormatError(WeaveError):
1153
_fmt = "Weave invariant violated: %(what)s"
1155
def __init__(self, what):
1156
WeaveError.__init__(self)
1160
class WeaveParentMismatch(WeaveError):
1162
_fmt = "Parents are mismatched between two revisions."
1165
class WeaveInvalidChecksum(WeaveError):
1167
_fmt = "Text did not match it's checksum: %(message)s"
1170
class WeaveTextDiffers(WeaveError):
1172
_fmt = ("Weaves differ on text content. Revision:"
1173
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1175
def __init__(self, revision_id, weave_a, weave_b):
1176
WeaveError.__init__(self)
1177
self.revision_id = revision_id
1178
self.weave_a = weave_a
1179
self.weave_b = weave_b
1182
class WeaveTextDiffers(WeaveError):
1184
_fmt = ("Weaves differ on text content. Revision:"
1185
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1187
def __init__(self, revision_id, weave_a, weave_b):
1188
WeaveError.__init__(self)
1189
self.revision_id = revision_id
1190
self.weave_a = weave_a
1191
self.weave_b = weave_b
1194
class VersionedFileError(BzrError):
1196
_fmt = "Versioned file error"
1199
class RevisionNotPresent(VersionedFileError):
1201
_fmt = "Revision {%(revision_id)s} not present in %(file_id)s."
1203
def __init__(self, revision_id, file_id):
1204
VersionedFileError.__init__(self)
1205
self.revision_id = revision_id
1206
self.file_id = file_id
1209
class RevisionAlreadyPresent(VersionedFileError):
1211
_fmt = "Revision {%(revision_id)s} already present in %(file_id)s."
1213
def __init__(self, revision_id, file_id):
1214
VersionedFileError.__init__(self)
1215
self.revision_id = revision_id
1216
self.file_id = file_id
1219
class KnitError(BzrError):
1223
internal_error = True
1226
class KnitHeaderError(KnitError):
1228
_fmt = "Knit header error: %(badline)r unexpected for file %(filename)s"
1230
def __init__(self, badline, filename):
1231
KnitError.__init__(self)
1232
self.badline = badline
1233
self.filename = filename
1236
class KnitCorrupt(KnitError):
1238
_fmt = "Knit %(filename)s corrupt: %(how)s"
1240
def __init__(self, filename, how):
1241
KnitError.__init__(self)
1242
self.filename = filename
1246
class KnitIndexUnknownMethod(KnitError):
1247
"""Raised when we don't understand the storage method.
1249
Currently only 'fulltext' and 'line-delta' are supported.
1252
_fmt = ("Knit index %(filename)s does not have a known method"
1253
" in options: %(options)r")
1255
def __init__(self, filename, options):
1256
KnitError.__init__(self)
1257
self.filename = filename
1258
self.options = options
1261
class NoSuchExportFormat(BzrError):
1263
_fmt = "Export format %(format)r not supported"
1265
def __init__(self, format):
1266
BzrError.__init__(self)
1267
self.format = format
1270
class TransportError(BzrError):
1272
_fmt = "Transport error: %(msg)s %(orig_error)s"
1274
def __init__(self, msg=None, orig_error=None):
1275
if msg is None and orig_error is not None:
1276
msg = str(orig_error)
1277
if orig_error is None:
1282
self.orig_error = orig_error
1283
BzrError.__init__(self)
1286
class TooManyConcurrentRequests(BzrError):
1288
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1289
" Be sure to finish_writing and finish_reading on the"
1290
" currently open request.")
1292
internal_error = True
1294
def __init__(self, medium):
1295
self.medium = medium
1298
class SmartProtocolError(TransportError):
1300
_fmt = "Generic bzr smart protocol error: %(details)s"
1302
def __init__(self, details):
1303
self.details = details
1306
# A set of semi-meaningful errors which can be thrown
1307
class TransportNotPossible(TransportError):
1309
_fmt = "Transport operation not possible: %(msg)s %(orig_error)s"
1312
class ConnectionError(TransportError):
1314
_fmt = "Connection error: %(msg)s %(orig_error)s"
1317
class SocketConnectionError(ConnectionError):
1319
_fmt = "%(msg)s %(host)s%(port)s%(orig_error)s"
1321
def __init__(self, host, port=None, msg=None, orig_error=None):
1323
msg = 'Failed to connect to'
1324
if orig_error is None:
1327
orig_error = '; ' + str(orig_error)
1328
ConnectionError.__init__(self, msg=msg, orig_error=orig_error)
1333
self.port = ':%s' % port
1336
class ConnectionReset(TransportError):
1338
_fmt = "Connection closed: %(msg)s %(orig_error)s"
1341
class InvalidRange(TransportError):
1343
_fmt = "Invalid range access in %(path)s at %(offset)s."
1345
def __init__(self, path, offset):
1346
TransportError.__init__(self, ("Invalid range access in %s at %d"
1349
self.offset = offset
1352
class InvalidHttpResponse(TransportError):
1354
_fmt = "Invalid http response for %(path)s: %(msg)s"
1356
def __init__(self, path, msg, orig_error=None):
1358
TransportError.__init__(self, msg, orig_error=orig_error)
1361
class InvalidHttpRange(InvalidHttpResponse):
1363
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1365
def __init__(self, path, range, msg):
1367
InvalidHttpResponse.__init__(self, path, msg)
1370
class InvalidHttpContentType(InvalidHttpResponse):
1372
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1374
def __init__(self, path, ctype, msg):
1376
InvalidHttpResponse.__init__(self, path, msg)
1379
class RedirectRequested(TransportError):
1381
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1383
def __init__(self, source, target, is_permament=False, qual_proto=None):
1384
self.source = source
1385
self.target = target
1387
self.permanently = ' permanently'
1389
self.permanently = ''
1390
self.is_permament = is_permament
1391
self._qualified_proto = qual_proto
1392
TransportError.__init__(self)
1394
def _requalify_url(self, url):
1395
"""Restore the qualified proto in front of the url"""
1396
# When this exception is raised, source and target are in
1397
# user readable format. But some transports may use a
1398
# different proto (http+urllib:// will present http:// to
1399
# the user. If a qualified proto is specified, the code
1400
# trapping the exception can get the qualified urls to
1401
# properly handle the redirection themself (creating a
1402
# new transport object from the target url for example).
1403
# But checking that the scheme of the original and
1404
# redirected urls are the same can be tricky. (see the
1405
# FIXME in BzrDir.open_from_transport for the unique use
1407
if self._qualified_proto is None:
1410
# The TODO related to NotBranchError mention that doing
1411
# that kind of manipulation on the urls may not be the
1412
# exception object job. On the other hand, this object is
1413
# the interface between the code and the user so
1414
# presenting the urls in different ways is indeed its
1417
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1418
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1421
def get_source_url(self):
1422
return self._requalify_url(self.source)
1424
def get_target_url(self):
1425
return self._requalify_url(self.target)
1428
class TooManyRedirections(TransportError):
1430
_fmt = "Too many redirections"
1432
class ConflictsInTree(BzrError):
1434
_fmt = "Working tree has conflicts."
1437
class ParseConfigError(BzrError):
1439
def __init__(self, errors, filename):
1440
if filename is None:
1442
message = "Error(s) parsing config file %s:\n%s" % \
1443
(filename, ('\n'.join(e.message for e in errors)))
1444
BzrError.__init__(self, message)
1447
class NoEmailInUsername(BzrError):
1449
_fmt = "%(username)r does not seem to contain a reasonable email address"
1451
def __init__(self, username):
1452
BzrError.__init__(self)
1453
self.username = username
1456
class SigningFailed(BzrError):
1458
_fmt = "Failed to gpg sign data with command %(command_line)r"
1460
def __init__(self, command_line):
1461
BzrError.__init__(self, command_line=command_line)
1464
class WorkingTreeNotRevision(BzrError):
1466
_fmt = ("The working tree for %(basedir)s has changed since"
1467
" the last commit, but weave merge requires that it be"
1470
def __init__(self, tree):
1471
BzrError.__init__(self, basedir=tree.basedir)
1474
class CantReprocessAndShowBase(BzrError):
1476
_fmt = ("Can't reprocess and show base, because reprocessing obscures "
1477
"the relationship of conflicting lines to the base")
1480
class GraphCycleError(BzrError):
1482
_fmt = "Cycle in graph %(graph)r"
1484
def __init__(self, graph):
1485
BzrError.__init__(self)
1489
class WritingCompleted(BzrError):
1491
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1492
"called upon it - accept bytes may not be called anymore.")
1494
internal_error = True
1496
def __init__(self, request):
1497
self.request = request
1500
class WritingNotComplete(BzrError):
1502
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1503
"called upon it - until the write phase is complete no "
1504
"data may be read.")
1506
internal_error = True
1508
def __init__(self, request):
1509
self.request = request
1512
class NotConflicted(BzrError):
1514
_fmt = "File %(filename)s is not conflicted."
1516
def __init__(self, filename):
1517
BzrError.__init__(self)
1518
self.filename = filename
1521
class MediumNotConnected(BzrError):
1523
_fmt = """The medium '%(medium)s' is not connected."""
1525
internal_error = True
1527
def __init__(self, medium):
1528
self.medium = medium
1531
class MustUseDecorated(Exception):
1533
_fmt = "A decorating function has requested its original command be used."
1536
class NoBundleFound(BzrError):
1538
_fmt = "No bundle was found in %(filename)s"
1540
def __init__(self, filename):
1541
BzrError.__init__(self)
1542
self.filename = filename
1545
class BundleNotSupported(BzrError):
1547
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
1549
def __init__(self, version, msg):
1550
BzrError.__init__(self)
1551
self.version = version
1555
class MissingText(BzrError):
1557
_fmt = ("Branch %(base)s is missing revision"
1558
" %(text_revision)s of %(file_id)s")
1560
def __init__(self, branch, text_revision, file_id):
1561
BzrError.__init__(self)
1562
self.branch = branch
1563
self.base = branch.base
1564
self.text_revision = text_revision
1565
self.file_id = file_id
1568
class DuplicateFileId(BzrError):
1570
_fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1572
def __init__(self, file_id, entry):
1573
BzrError.__init__(self)
1574
self.file_id = file_id
1578
class DuplicateKey(BzrError):
1580
_fmt = "Key %(key)s is already present in map"
1583
class DuplicateHelpPrefix(BzrError):
1585
_fmt = "The prefix %(prefix)s is in the help search path twice."
1587
def __init__(self, prefix):
1588
self.prefix = prefix
1591
class MalformedTransform(BzrError):
1593
_fmt = "Tree transform is malformed %(conflicts)r"
1596
class NoFinalPath(BzrError):
1598
_fmt = ("No final name for trans_id %(trans_id)r\n"
1599
"file-id: %(file_id)r\n"
1600
"root trans-id: %(root_trans_id)r\n")
1602
def __init__(self, trans_id, transform):
1603
self.trans_id = trans_id
1604
self.file_id = transform.final_file_id(trans_id)
1605
self.root_trans_id = transform.root
1608
class BzrBadParameter(BzrError):
1610
_fmt = "Bad parameter: %(param)r"
1612
internal_error = True
1614
# This exception should never be thrown, but it is a base class for all
1615
# parameter-to-function errors.
1617
def __init__(self, param):
1618
BzrError.__init__(self)
1622
class BzrBadParameterNotUnicode(BzrBadParameter):
1624
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1627
class ReusingTransform(BzrError):
1629
_fmt = "Attempt to reuse a transform that has already been applied."
1632
class CantMoveRoot(BzrError):
1634
_fmt = "Moving the root directory is not supported at this time"
1637
class BzrMoveFailedError(BzrError):
1639
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1641
def __init__(self, from_path='', to_path='', extra=None):
1642
BzrError.__init__(self)
1644
self.extra = ': ' + str(extra)
1648
has_from = len(from_path) > 0
1649
has_to = len(to_path) > 0
1651
self.from_path = osutils.splitpath(from_path)[-1]
1656
self.to_path = osutils.splitpath(to_path)[-1]
1661
if has_from and has_to:
1662
self.operator = " =>"
1664
self.from_path = "from " + from_path
1666
self.operator = "to"
1668
self.operator = "file"
1671
class BzrRenameFailedError(BzrMoveFailedError):
1673
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1675
def __init__(self, from_path, to_path, extra=None):
1676
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1678
class BzrRemoveChangedFilesError(BzrError):
1679
"""Used when user is trying to remove changed files."""
1681
_fmt = ("Can't remove changed or unknown files:\n%(changes_as_text)s"
1682
"Use --keep to not delete them, or --force to delete them regardless.")
1684
def __init__(self, tree_delta):
1685
BzrError.__init__(self)
1686
self.changes_as_text = tree_delta.get_changes_as_text()
1687
#self.paths_as_string = '\n'.join(changed_files)
1688
#self.paths_as_string = '\n'.join([quotefn(p) for p in changed_files])
1691
class BzrBadParameterNotString(BzrBadParameter):
1693
_fmt = "Parameter %(param)s is not a string or unicode string."
1696
class BzrBadParameterMissing(BzrBadParameter):
1698
_fmt = "Parameter $(param)s is required but not present."
1701
class BzrBadParameterUnicode(BzrBadParameter):
1703
_fmt = ("Parameter %(param)s is unicode but"
1704
" only byte-strings are permitted.")
1707
class BzrBadParameterContainsNewline(BzrBadParameter):
1709
_fmt = "Parameter %(param)s contains a newline."
1712
class DependencyNotPresent(BzrError):
1714
_fmt = 'Unable to import library "%(library)s": %(error)s'
1716
def __init__(self, library, error):
1717
BzrError.__init__(self, library=library, error=error)
1720
class ParamikoNotPresent(DependencyNotPresent):
1722
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1724
def __init__(self, error):
1725
DependencyNotPresent.__init__(self, 'paramiko', error)
1728
class PointlessMerge(BzrError):
1730
_fmt = "Nothing to merge."
1733
class UninitializableFormat(BzrError):
1735
_fmt = "Format %(format)s cannot be initialised by this version of bzr."
1737
def __init__(self, format):
1738
BzrError.__init__(self)
1739
self.format = format
1742
class BadConversionTarget(BzrError):
1744
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1746
def __init__(self, problem, format):
1747
BzrError.__init__(self)
1748
self.problem = problem
1749
self.format = format
1752
class NoDiff(BzrError):
1754
_fmt = "Diff is not installed on this machine: %(msg)s"
1756
def __init__(self, msg):
1757
BzrError.__init__(self, msg=msg)
1760
class NoDiff3(BzrError):
1762
_fmt = "Diff3 is not installed on this machine."
1765
class ExistingLimbo(BzrError):
1767
_fmt = """This tree contains left-over files from a failed operation.
1768
Please examine %(limbo_dir)s to see if it contains any files you wish to
1769
keep, and delete it when you are done."""
1771
def __init__(self, limbo_dir):
1772
BzrError.__init__(self)
1773
self.limbo_dir = limbo_dir
1776
class ImmortalLimbo(BzrError):
1778
_fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
1779
Please examine %(limbo_dir)s to see if it contains any files you wish to
1780
keep, and delete it when you are done."""
1782
def __init__(self, limbo_dir):
1783
BzrError.__init__(self)
1784
self.limbo_dir = limbo_dir
1787
class OutOfDateTree(BzrError):
1789
_fmt = "Working tree is out of date, please run 'bzr update'."
1791
def __init__(self, tree):
1792
BzrError.__init__(self)
1796
class PublicBranchOutOfDate(BzrError):
1798
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1801
def __init__(self, public_location, revstring):
1802
import bzrlib.urlutils as urlutils
1803
public_location = urlutils.unescape_for_display(public_location,
1805
BzrError.__init__(self, public_location=public_location,
1806
revstring=revstring)
1809
class MergeModifiedFormatError(BzrError):
1811
_fmt = "Error in merge modified format"
1814
class ConflictFormatError(BzrError):
1816
_fmt = "Format error in conflict listings"
1819
class CorruptRepository(BzrError):
1821
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1822
"Please run bzr reconcile on this repository.")
1824
def __init__(self, repo):
1825
BzrError.__init__(self)
1826
self.repo_path = repo.bzrdir.root_transport.base
1829
class UpgradeRequired(BzrError):
1831
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1833
def __init__(self, path):
1834
BzrError.__init__(self)
1838
class LocalRequiresBoundBranch(BzrError):
1840
_fmt = "Cannot perform local-only commits on unbound branches."
1843
class MissingProgressBarFinish(BzrError):
1845
_fmt = "A nested progress bar was not 'finished' correctly."
1848
class InvalidProgressBarType(BzrError):
1850
_fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
1851
" is not a supported type Select one of: %(valid_types)s")
1853
def __init__(self, bar_type, valid_types):
1854
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1857
class UnsupportedOperation(BzrError):
1859
_fmt = ("The method %(mname)s is not supported on"
1860
" objects of type %(tname)s.")
1862
def __init__(self, method, method_self):
1863
self.method = method
1864
self.mname = method.__name__
1865
self.tname = type(method_self).__name__
1868
class CannotSetRevisionId(UnsupportedOperation):
1869
"""Raised when a commit is attempting to set a revision id but cant."""
1872
class NonAsciiRevisionId(UnsupportedOperation):
1873
"""Raised when a commit is attempting to set a non-ascii revision id
1878
class BinaryFile(BzrError):
1880
_fmt = "File is binary but should be text."
1883
class IllegalPath(BzrError):
1885
_fmt = "The path %(path)s is not permitted on this platform"
1887
def __init__(self, path):
1888
BzrError.__init__(self)
1892
class TestamentMismatch(BzrError):
1894
_fmt = """Testament did not match expected value.
1895
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1898
def __init__(self, revision_id, expected, measured):
1899
self.revision_id = revision_id
1900
self.expected = expected
1901
self.measured = measured
1904
class NotABundle(BzrError):
1906
_fmt = "Not a bzr revision-bundle: %(text)r"
1908
def __init__(self, text):
1909
BzrError.__init__(self)
1913
class BadBundle(BzrError):
1915
_fmt = "Bad bzr revision-bundle: %(text)r"
1917
def __init__(self, text):
1918
BzrError.__init__(self)
1922
class MalformedHeader(BadBundle):
1924
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1927
class MalformedPatches(BadBundle):
1929
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1932
class MalformedFooter(BadBundle):
1934
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1937
class UnsupportedEOLMarker(BadBundle):
1939
_fmt = "End of line marker was not \\n in bzr revision-bundle"
1942
# XXX: BadBundle's constructor assumes there's explanatory text,
1943
# but for this there is not
1944
BzrError.__init__(self)
1947
class IncompatibleBundleFormat(BzrError):
1949
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1951
def __init__(self, bundle_format, other):
1952
BzrError.__init__(self)
1953
self.bundle_format = bundle_format
1957
class BadInventoryFormat(BzrError):
1959
_fmt = "Root class for inventory serialization errors"
1962
class UnexpectedInventoryFormat(BadInventoryFormat):
1964
_fmt = "The inventory was not in the expected format:\n %(msg)s"
1966
def __init__(self, msg):
1967
BadInventoryFormat.__init__(self, msg=msg)
1970
class RootNotRich(BzrError):
1972
_fmt = """This operation requires rich root data storage"""
1975
class NoSmartMedium(BzrError):
1977
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1979
internal_error = True
1981
def __init__(self, transport):
1982
self.transport = transport
1985
class NoSmartServer(NotBranchError):
1987
_fmt = "No smart server available at %(url)s"
1989
def __init__(self, url):
1993
class UnknownSSH(BzrError):
1995
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
1997
def __init__(self, vendor):
1998
BzrError.__init__(self)
1999
self.vendor = vendor
2002
class SSHVendorNotFound(BzrError):
2004
_fmt = ("Don't know how to handle SSH connections."
2005
" Please set BZR_SSH environment variable.")
2008
class GhostRevisionUnusableHere(BzrError):
2010
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2012
def __init__(self, revision_id):
2013
BzrError.__init__(self)
2014
self.revision_id = revision_id
2017
class IllegalUseOfScopeReplacer(BzrError):
2019
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2020
" %(msg)s%(extra)s")
2022
internal_error = True
2024
def __init__(self, name, msg, extra=None):
2025
BzrError.__init__(self)
2029
self.extra = ': ' + str(extra)
2034
class InvalidImportLine(BzrError):
2036
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
2038
internal_error = True
2040
def __init__(self, text, msg):
2041
BzrError.__init__(self)
2046
class ImportNameCollision(BzrError):
2048
_fmt = ("Tried to import an object to the same name as"
2049
" an existing object. %(name)s")
2051
internal_error = True
2053
def __init__(self, name):
2054
BzrError.__init__(self)
2058
class NotAMergeDirective(BzrError):
2059
"""File starting with %(firstline)r is not a merge directive"""
2060
def __init__(self, firstline):
2061
BzrError.__init__(self, firstline=firstline)
2064
class NoMergeSource(BzrError):
2065
"""Raise if no merge source was specified for a merge directive"""
2067
_fmt = "A merge directive must provide either a bundle or a public"\
2071
class PatchMissing(BzrError):
2072
"""Raise a patch type was specified but no patch supplied"""
2074
_fmt = "patch_type was %(patch_type)s, but no patch was supplied."
2076
def __init__(self, patch_type):
2077
BzrError.__init__(self)
2078
self.patch_type = patch_type
2081
class UnsupportedInventoryKind(BzrError):
2083
_fmt = """Unsupported entry kind %(kind)s"""
2085
def __init__(self, kind):
2089
class BadSubsumeSource(BzrError):
2091
_fmt = """Can't subsume %(other_tree)s into %(tree)s. %(reason)s"""
2093
def __init__(self, tree, other_tree, reason):
2095
self.other_tree = other_tree
2096
self.reason = reason
2099
class SubsumeTargetNeedsUpgrade(BzrError):
2101
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2103
def __init__(self, other_tree):
2104
self.other_tree = other_tree
2107
class BadReferenceTarget(BzrError):
2109
_fmt = "Can't add reference to %(other_tree)s into %(tree)s. %(reason)s"
2111
internal_error = True
2113
def __init__(self, tree, other_tree, reason):
2115
self.other_tree = other_tree
2116
self.reason = reason
2119
class NoSuchTag(BzrError):
2121
_fmt = "No such tag: %(tag_name)s"
2123
def __init__(self, tag_name):
2124
self.tag_name = tag_name
2127
class TagsNotSupported(BzrError):
2129
_fmt = ("Tags not supported by %(branch)s;"
2130
" you may be able to use bzr upgrade --dirstate-tags.")
2132
def __init__(self, branch):
2133
self.branch = branch
2136
class TagAlreadyExists(BzrError):
2138
_fmt = "Tag %(tag_name)s already exists."
2140
def __init__(self, tag_name):
2141
self.tag_name = tag_name
2144
class MalformedBugIdentifier(BzrError):
2146
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2148
def __init__(self, bug_id, reason):
2149
self.bug_id = bug_id
2150
self.reason = reason
2153
class UnknownBugTrackerAbbreviation(BzrError):
2155
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2158
def __init__(self, abbreviation, branch):
2159
self.abbreviation = abbreviation
2160
self.branch = branch
2163
class UnexpectedSmartServerResponse(BzrError):
2165
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2167
def __init__(self, response_tuple):
2168
self.response_tuple = response_tuple
2171
class ContainerError(BzrError):
2172
"""Base class of container errors."""
2175
class UnknownContainerFormatError(ContainerError):
2177
_fmt = "Unrecognised container format: %(container_format)r"
2179
def __init__(self, container_format):
2180
self.container_format = container_format
2183
class UnexpectedEndOfContainerError(ContainerError):
2185
_fmt = "Unexpected end of container stream"
2187
internal_error = False
2190
class UnknownRecordTypeError(ContainerError):
2192
_fmt = "Unknown record type: %(record_type)r"
2194
def __init__(self, record_type):
2195
self.record_type = record_type
2198
class InvalidRecordError(ContainerError):
2200
_fmt = "Invalid record: %(reason)s"
2202
def __init__(self, reason):
2203
self.reason = reason
2206
class ContainerHasExcessDataError(ContainerError):
2208
_fmt = "Container has data after end marker: %(excess)r"
2210
def __init__(self, excess):
2211
self.excess = excess
2214
class DuplicateRecordNameError(ContainerError):
2216
_fmt = "Container has multiple records with the same name: \"%(name)s\""
2218
def __init__(self, name):
2222
class NoDestinationAddress(BzrError):
2224
_fmt = "Message does not have a destination address."
2226
internal_error = True
2229
class SMTPError(BzrError):
2231
_fmt = "SMTP error: %(error)s"
2233
def __init__(self, error):
43
"""Specified file is of a kind that cannot be added.
45
(For example a symlink or device file.)"""
49
class ForbiddenFileError(BzrError):
50
"""Cannot operate on a file because it is a control file."""
54
class LockError(Exception):
55
"""All exceptions from the lock/unlock functions should be from
56
this exception class. They will be translated as necessary. The
57
original exception is available as e.original_error
59
def __init__(self, e=None):
60
self.original_error = e
62
Exception.__init__(self, e)
64
Exception.__init__(self)