2
# -*- coding: UTF-8 -*-
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
6
5
# the Free Software Foundation; either version 2 of the License, or
7
6
# (at your option) any later version.
9
8
# This program is distributed in the hope that it will be useful,
10
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
11
# GNU General Public License for more details.
14
13
# You should have received a copy of the GNU General Public License
15
14
# along with this program; if not, write to the Free Software
16
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
__copyright__ = "Copyright (C) 2005 Canonical Ltd."
20
__author__ = "Martin Pool <mbp@canonical.com>"
23
######################################################################
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
47
# return codes from the bzr program
50
EXIT_INTERNAL_ERROR = 4
25
53
class BzrError(StandardError):
28
class BzrCheckError(BzrError):
55
Base class for errors raised by bzrlib.
57
:cvar internal_error: if True this was probably caused by a bzr bug and
58
should be displayed with a traceback; if False (or absent) this was
59
probably a user or environment error and they don't need the gory details.
60
(That can be overridden by -Derror on the command line.)
62
:cvar _fmt: Format string to display the error; this is expanded
63
by the instance's dict.
66
internal_error = False
68
def __init__(self, msg=None, **kwds):
69
"""Construct a new BzrError.
71
There are two alternative forms for constructing these objects.
72
Either a preformatted string may be passed, or a set of named
73
arguments can be given. The first is for generic "user" errors which
74
are not intended to be caught and so do not need a specific subclass.
75
The second case is for use with subclasses that provide a _fmt format
76
string to print the arguments.
78
Keyword arguments are taken as parameters to the error, which can
79
be inserted into the format string template. It's recommended
80
that subclasses override the __init__ method to require specific
83
:param msg: If given, this is the literal complete text for the error,
84
not subject to expansion.
86
StandardError.__init__(self)
88
# I was going to deprecate this, but it actually turns out to be
89
# quite handy - mbp 20061103.
90
self._preformatted_string = msg
92
self._preformatted_string = None
93
for key, value in kwds.items():
94
setattr(self, key, value)
97
s = getattr(self, '_preformatted_string', None)
99
# contains a preformatted message; must be cast to plain str
102
fmt = self._get_format_string()
104
d = dict(self.__dict__)
105
# special case: python2.5 puts the 'message' attribute in a
106
# slot, so it isn't seen in __dict__
107
d['message'] = getattr(self, 'message', 'no message')
109
# __str__() should always return a 'str' object
110
# never a 'unicode' object.
111
if isinstance(s, unicode):
112
return s.encode('utf8')
114
except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
115
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
116
% (self.__class__.__name__,
118
getattr(self, '_fmt', None),
121
def _get_format_string(self):
122
"""Return format string for this exception or None"""
123
fmt = getattr(self, '_fmt', None)
126
fmt = getattr(self, '__doc__', None)
128
symbol_versioning.warn("%s uses its docstring as a format, "
129
"it should use _fmt instead" % self.__class__.__name__,
132
return 'Unprintable exception %s: dict=%r, fmt=%r' \
133
% (self.__class__.__name__,
135
getattr(self, '_fmt', None),
139
class InternalBzrError(BzrError):
140
"""Base class for errors that are internal in nature.
142
This is a convenience class for errors that are internal. The
143
internal_error attribute can still be altered in subclasses, if needed.
144
Using this class is simply an easy way to get internal errors.
147
internal_error = True
150
class BzrNewError(BzrError):
151
"""Deprecated error base class."""
152
# base classes should override the docstring with their human-
153
# readable explanation
155
def __init__(self, *args, **kwds):
156
# XXX: Use the underlying BzrError to always generate the args
157
# attribute if it doesn't exist. We can't use super here, because
158
# exceptions are old-style classes in python2.4 (but new in 2.5).
160
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
161
'please convert %s to use BzrError instead'
162
% self.__class__.__name__,
165
BzrError.__init__(self, *args)
166
for key, value in kwds.items():
167
setattr(self, key, value)
171
# __str__() should always return a 'str' object
172
# never a 'unicode' object.
173
s = self.__doc__ % self.__dict__
174
if isinstance(s, unicode):
175
return s.encode('utf8')
177
except (TypeError, NameError, ValueError, KeyError), e:
178
return 'Unprintable exception %s(%r): %r' \
179
% (self.__class__.__name__,
183
class AlreadyBuilding(BzrError):
185
_fmt = "The tree builder is already building a tree."
188
class BzrCheckError(InternalBzrError):
190
_fmt = "Internal check failed: %(message)s"
192
def __init__(self, message):
193
BzrError.__init__(self)
194
self.message = message
197
class DisabledMethod(InternalBzrError):
199
_fmt = "The smart server method '%(class_name)s' is disabled."
201
def __init__(self, class_name):
202
BzrError.__init__(self)
203
self.class_name = class_name
206
class IncompatibleAPI(BzrError):
208
_fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
209
'It supports versions "%(minimum)s" to "%(current)s".'
211
def __init__(self, api, wanted, minimum, current):
214
self.minimum = minimum
215
self.current = current
218
class InProcessTransport(BzrError):
220
_fmt = "The transport '%(transport)s' is only accessible within this " \
223
def __init__(self, transport):
224
self.transport = transport
227
class InvalidEntryName(InternalBzrError):
229
_fmt = "Invalid entry name: %(name)s"
231
def __init__(self, name):
232
BzrError.__init__(self)
236
class InvalidRevisionNumber(BzrError):
238
_fmt = "Invalid revision number %(revno)s"
240
def __init__(self, revno):
241
BzrError.__init__(self)
245
class InvalidRevisionId(BzrError):
247
_fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
249
def __init__(self, revision_id, branch):
250
# branch can be any string or object with __str__ defined
251
BzrError.__init__(self)
252
self.revision_id = revision_id
256
class ReservedId(BzrError):
258
_fmt = "Reserved revision-id {%(revision_id)s}"
260
def __init__(self, revision_id):
261
self.revision_id = revision_id
264
class RootMissing(InternalBzrError):
266
_fmt = ("The root entry of a tree must be the first entry supplied to "
267
"record_entry_contents.")
270
class NoPublicBranch(BzrError):
272
_fmt = 'There is no public branch set for "%(branch_url)s".'
274
def __init__(self, branch):
275
import bzrlib.urlutils as urlutils
276
public_location = urlutils.unescape_for_display(branch.base, 'ascii')
277
BzrError.__init__(self, branch_url=public_location)
280
class NoHelpTopic(BzrError):
282
_fmt = ("No help could be found for '%(topic)s'. "
283
"Please use 'bzr help topics' to obtain a list of topics.")
285
def __init__(self, topic):
289
class NoSuchId(BzrError):
291
_fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
293
def __init__(self, tree, file_id):
294
BzrError.__init__(self)
295
self.file_id = file_id
299
class NoSuchIdInRepository(NoSuchId):
301
_fmt = ('The file id "%(file_id)s" is not present in the repository'
304
def __init__(self, repository, file_id):
305
BzrError.__init__(self, repository=repository, file_id=file_id)
308
class InventoryModified(InternalBzrError):
310
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
311
" so a clean inventory cannot be read without data loss.")
313
def __init__(self, tree):
317
class NoWorkingTree(BzrError):
319
_fmt = 'No WorkingTree exists for "%(base)s".'
321
def __init__(self, base):
322
BzrError.__init__(self)
326
class NotBuilding(BzrError):
328
_fmt = "Not currently building a tree."
331
class NotLocalUrl(BzrError):
333
_fmt = "%(url)s is not a local path."
335
def __init__(self, url):
339
class WorkingTreeAlreadyPopulated(InternalBzrError):
341
_fmt = 'Working tree already populated in "%(base)s"'
343
def __init__(self, base):
32
347
class BzrCommandError(BzrError):
33
# Error from malformed user command
37
class NotBranchError(BzrError):
38
"""Specified path is not in a branch"""
348
"""Error from user command"""
350
# Error from malformed user command; please avoid raising this as a
351
# generic exception not caused by user input.
353
# I think it's a waste of effort to differentiate between errors that
354
# are not intended to be caught anyway. UI code need not subclass
355
# BzrCommandError, and non-UI code should not throw a subclass of
356
# BzrCommandError. ADHB 20051211
357
def __init__(self, msg):
358
# Object.__str__() must return a real string
359
# returning a Unicode string is a python error.
360
if isinstance(msg, unicode):
361
self.msg = msg.encode('utf8')
369
class NotWriteLocked(BzrError):
371
_fmt = """%(not_locked)r is not write locked but needs to be."""
373
def __init__(self, not_locked):
374
self.not_locked = not_locked
377
class BzrOptionError(BzrCommandError):
379
_fmt = "Error in command line options"
382
class BadIndexFormatSignature(BzrError):
384
_fmt = "%(value)s is not an index of type %(_type)s."
386
def __init__(self, value, _type):
387
BzrError.__init__(self)
392
class BadIndexData(BzrError):
394
_fmt = "Error in data for index %(value)s."
396
def __init__(self, value):
397
BzrError.__init__(self)
401
class BadIndexDuplicateKey(BzrError):
403
_fmt = "The key '%(key)s' is already in index '%(index)s'."
405
def __init__(self, key, index):
406
BzrError.__init__(self)
411
class BadIndexKey(BzrError):
413
_fmt = "The key '%(key)s' is not a valid key."
415
def __init__(self, key):
416
BzrError.__init__(self)
420
class BadIndexOptions(BzrError):
422
_fmt = "Could not parse options for index %(value)s."
424
def __init__(self, value):
425
BzrError.__init__(self)
429
class BadIndexValue(BzrError):
431
_fmt = "The value '%(value)s' is not a valid value."
433
def __init__(self, value):
434
BzrError.__init__(self)
438
class BadOptionValue(BzrError):
440
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
442
def __init__(self, name, value):
443
BzrError.__init__(self, name=name, value=value)
446
class StrictCommitFailed(BzrError):
448
_fmt = "Commit refused because there are unknown files in the tree"
451
# XXX: Should be unified with TransportError; they seem to represent the
453
# RBC 20060929: I think that unifiying with TransportError would be a mistake
454
# - this is finer than a TransportError - and more useful as such. It
455
# differentiates between 'transport has failed' and 'operation on a transport
457
class PathError(BzrError):
459
_fmt = "Generic path error: %(path)r%(extra)s)"
461
def __init__(self, path, extra=None):
462
BzrError.__init__(self)
465
self.extra = ': ' + str(extra)
470
class NoSuchFile(PathError):
472
_fmt = "No such file: %(path)r%(extra)s"
475
class FileExists(PathError):
477
_fmt = "File exists: %(path)r%(extra)s"
480
class RenameFailedFilesExist(BzrError):
481
"""Used when renaming and both source and dest exist."""
483
_fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
484
" (Use --after to tell bzr about a rename that has already"
485
" happened)%(extra)s")
487
def __init__(self, source, dest, extra=None):
488
BzrError.__init__(self)
489
self.source = str(source)
490
self.dest = str(dest)
492
self.extra = ' ' + str(extra)
497
class NotADirectory(PathError):
499
_fmt = '"%(path)s" is not a directory %(extra)s'
502
class NotInWorkingDirectory(PathError):
504
_fmt = '"%(path)s" is not in the working directory %(extra)s'
507
class DirectoryNotEmpty(PathError):
509
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
512
class HardLinkNotSupported(PathError):
514
_fmt = 'Hard-linking "%(path)s" is not supported'
517
class ReadingCompleted(InternalBzrError):
519
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
520
"called upon it - the request has been completed and no more "
523
def __init__(self, request):
524
self.request = request
527
class ResourceBusy(PathError):
529
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
532
class PermissionDenied(PathError):
534
_fmt = 'Permission denied: "%(path)s"%(extra)s'
537
class InvalidURL(PathError):
539
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
542
class InvalidURLJoin(PathError):
544
_fmt = 'Invalid URL join request: "%(args)s"%(extra)s'
546
def __init__(self, msg, base, args):
547
PathError.__init__(self, base, msg)
548
self.args = [base] + list(args)
551
class UnknownHook(BzrError):
553
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
555
def __init__(self, hook_type, hook_name):
556
BzrError.__init__(self)
557
self.type = hook_type
558
self.hook = hook_name
561
class UnsupportedProtocol(PathError):
563
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
565
def __init__(self, url, extra):
566
PathError.__init__(self, url, extra=extra)
569
class ReadError(PathError):
571
_fmt = """Error reading from %(path)r."""
574
class ShortReadvError(PathError):
576
_fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
577
' at %(offset)s for "%(path)s"%(extra)s')
579
internal_error = True
581
def __init__(self, path, offset, length, actual, extra=None):
582
PathError.__init__(self, path, extra=extra)
588
class PathNotChild(PathError):
590
_fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
592
internal_error = True
594
def __init__(self, path, base, extra=None):
595
BzrError.__init__(self)
599
self.extra = ': ' + str(extra)
604
class InvalidNormalization(PathError):
606
_fmt = 'Path "%(path)s" is not unicode normalized'
609
# TODO: This is given a URL; we try to unescape it but doing that from inside
610
# the exception object is a bit undesirable.
611
# TODO: Probably this behavior of should be a common superclass
612
class NotBranchError(PathError):
614
_fmt = 'Not a branch: "%(path)s".'
616
def __init__(self, path):
617
import bzrlib.urlutils as urlutils
618
self.path = urlutils.unescape_for_display(path, 'ascii')
621
class NoSubmitBranch(PathError):
623
_fmt = 'No submit branch available for branch "%(path)s"'
625
def __init__(self, branch):
626
import bzrlib.urlutils as urlutils
627
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
630
class AlreadyBranchError(PathError):
632
_fmt = 'Already a branch: "%(path)s".'
635
class BranchExistsWithoutWorkingTree(PathError):
637
_fmt = 'Directory contains a branch, but no working tree \
638
(use bzr checkout if you wish to build a working tree): "%(path)s"'
641
class AtomicFileAlreadyClosed(PathError):
643
_fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
646
def __init__(self, path, function):
647
PathError.__init__(self, path=path, extra=None)
648
self.function = function
651
class InaccessibleParent(PathError):
653
_fmt = ('Parent not accessible given base "%(base)s" and'
654
' relative path "%(path)s"')
656
def __init__(self, path, base):
657
PathError.__init__(self, path)
661
class NoRepositoryPresent(BzrError):
663
_fmt = 'No repository present: "%(path)s"'
664
def __init__(self, bzrdir):
665
BzrError.__init__(self)
666
self.path = bzrdir.transport.clone('..').base
669
class FileInWrongBranch(BzrError):
671
_fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
673
def __init__(self, branch, path):
674
BzrError.__init__(self)
676
self.branch_base = branch.base
680
class UnsupportedFormatError(BzrError):
682
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
685
class UnknownFormatError(BzrError):
687
_fmt = "Unknown branch format: %(format)r"
690
class IncompatibleFormat(BzrError):
692
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
694
def __init__(self, format, bzrdir_format):
695
BzrError.__init__(self)
697
self.bzrdir = bzrdir_format
700
class IncompatibleRepositories(BzrError):
702
_fmt = "Repository %(target)s is not compatible with repository"\
705
def __init__(self, source, target):
706
BzrError.__init__(self, target=target, source=source)
709
class IncompatibleRevision(BzrError):
711
_fmt = "Revision is not compatible with %(repo_format)s"
713
def __init__(self, repo_format):
714
BzrError.__init__(self)
715
self.repo_format = repo_format
718
class AlreadyVersionedError(BzrError):
719
"""Used when a path is expected not to be versioned, but it is."""
721
_fmt = "%(context_info)s%(path)s is already versioned."
723
def __init__(self, path, context_info=None):
724
"""Construct a new AlreadyVersionedError.
726
:param path: This is the path which is versioned,
727
which should be in a user friendly form.
728
:param context_info: If given, this is information about the context,
729
which could explain why this is expected to not be versioned.
731
BzrError.__init__(self)
733
if context_info is None:
734
self.context_info = ''
736
self.context_info = context_info + ". "
42
739
class NotVersionedError(BzrError):
43
"""Specified object is not versioned."""
740
"""Used when a path is expected to be versioned, but it is not."""
742
_fmt = "%(context_info)s%(path)s is not versioned."
744
def __init__(self, path, context_info=None):
745
"""Construct a new NotVersionedError.
747
:param path: This is the path which is not versioned,
748
which should be in a user friendly form.
749
:param context_info: If given, this is information about the context,
750
which could explain why this is expected to be versioned.
752
BzrError.__init__(self)
754
if context_info is None:
755
self.context_info = ''
757
self.context_info = context_info + ". "
760
class PathsNotVersionedError(BzrError):
761
"""Used when reporting several paths which are not versioned"""
763
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
765
def __init__(self, paths):
766
from bzrlib.osutils import quotefn
767
BzrError.__init__(self)
769
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
772
class PathsDoNotExist(BzrError):
774
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
776
# used when reporting that paths are neither versioned nor in the working
779
def __init__(self, paths, extra=None):
781
from bzrlib.osutils import quotefn
782
BzrError.__init__(self)
784
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
786
self.extra = ': ' + str(extra)
46
791
class BadFileKindError(BzrError):
47
"""Specified file is of a kind that cannot be added.
49
(For example a symlink or device file.)"""
53
class ForbiddenFileError(BzrError):
54
"""Cannot operate on a file because it is a control file."""
58
class LockError(Exception):
59
"""All exceptions from the lock/unlock functions should be from
60
this exception class. They will be translated as necessary. The
61
original exception is available as e.original_error
63
def __init__(self, e=None):
64
self.original_error = e
66
Exception.__init__(self, e)
68
Exception.__init__(self)
71
class PointlessCommit(Exception):
72
"""Commit failed because nothing was changed."""
793
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
795
def __init__(self, filename, kind):
796
BzrError.__init__(self, filename=filename, kind=kind)
799
class ForbiddenControlFileError(BzrError):
801
_fmt = 'Cannot operate on "%(filename)s" because it is a control file'
804
class LockError(InternalBzrError):
806
_fmt = "Lock error: %(msg)s"
808
# All exceptions from the lock/unlock functions should be from
809
# this exception class. They will be translated as necessary. The
810
# original exception is available as e.original_error
812
# New code should prefer to raise specific subclasses
813
def __init__(self, message):
814
# Python 2.5 uses a slot for StandardError.message,
815
# so use a different variable name. We now work around this in
816
# BzrError.__str__, but this member name is kept for compatability.
820
class LockActive(LockError):
822
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
824
internal_error = False
826
def __init__(self, lock_description):
827
self.lock_description = lock_description
830
class CommitNotPossible(LockError):
832
_fmt = "A commit was attempted but we do not have a write lock open."
838
class AlreadyCommitted(LockError):
840
_fmt = "A rollback was requested, but is not able to be accomplished."
846
class ReadOnlyError(LockError):
848
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
850
# TODO: There should also be an error indicating that you need a write
851
# lock and don't have any lock at all... mbp 20070226
853
def __init__(self, obj):
857
class ReadOnlyLockError(LockError):
859
_fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
861
@symbol_versioning.deprecated_method(symbol_versioning.zero_ninetytwo)
862
def __init__(self, fname, msg):
863
LockError.__init__(self, '')
868
class LockFailed(LockError):
870
internal_error = False
872
_fmt = "Cannot lock %(lock)s: %(why)s"
874
def __init__(self, lock, why):
875
LockError.__init__(self, '')
880
class OutSideTransaction(BzrError):
882
_fmt = ("A transaction related operation was attempted after"
883
" the transaction finished.")
886
class ObjectNotLocked(LockError):
888
_fmt = "%(obj)r is not locked"
890
# this can indicate that any particular object is not locked; see also
891
# LockNotHeld which means that a particular *lock* object is not held by
892
# the caller -- perhaps they should be unified.
893
def __init__(self, obj):
897
class ReadOnlyObjectDirtiedError(ReadOnlyError):
899
_fmt = "Cannot change object %(obj)r in read only transaction"
901
def __init__(self, obj):
905
class UnlockableTransport(LockError):
907
internal_error = False
909
_fmt = "Cannot lock: transport is read only: %(transport)s"
911
def __init__(self, transport):
912
self.transport = transport
915
class LockContention(LockError):
917
_fmt = 'Could not acquire lock "%(lock)s"'
918
# TODO: show full url for lock, combining the transport and relative
921
internal_error = False
923
def __init__(self, lock):
927
class LockBroken(LockError):
929
_fmt = ("Lock was broken while still open: %(lock)s"
930
" - check storage consistency!")
932
internal_error = False
934
def __init__(self, lock):
938
class LockBreakMismatch(LockError):
940
_fmt = ("Lock was released and re-acquired before being broken:"
941
" %(lock)s: held by %(holder)r, wanted to break %(target)r")
943
internal_error = False
945
def __init__(self, lock, holder, target):
951
class LockNotHeld(LockError):
953
_fmt = "Lock not held: %(lock)s"
955
internal_error = False
957
def __init__(self, lock):
961
class TokenLockingNotSupported(LockError):
963
_fmt = "The object %(obj)s does not support token specifying a token when locking."
965
def __init__(self, obj):
969
class TokenMismatch(LockBroken):
971
_fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
973
internal_error = True
975
def __init__(self, given_token, lock_token):
976
self.given_token = given_token
977
self.lock_token = lock_token
980
class PointlessCommit(BzrError):
982
_fmt = "No changes to commit"
985
class CannotCommitSelectedFileMerge(BzrError):
987
_fmt = 'Selected-file commit of merges is not supported yet:'\
988
' files %(files_str)s'
990
def __init__(self, files):
991
files_str = ', '.join(files)
992
BzrError.__init__(self, files=files, files_str=files_str)
995
class BadCommitMessageEncoding(BzrError):
997
_fmt = 'The specified commit message contains characters unsupported by '\
998
'the current encoding.'
1001
class UpgradeReadonly(BzrError):
1003
_fmt = "Upgrade URL cannot work with readonly URLs."
1006
class UpToDateFormat(BzrError):
1008
_fmt = "The branch format %(format)s is already at the most recent format."
1010
def __init__(self, format):
1011
BzrError.__init__(self)
1012
self.format = format
1015
class StrictCommitFailed(Exception):
1017
_fmt = "Commit refused because there are unknowns in the tree."
1020
class NoSuchRevision(InternalBzrError):
1022
_fmt = "%(branch)s has no revision %(revision)s"
1024
def __init__(self, branch, revision):
1025
# 'branch' may sometimes be an internal object like a KnitRevisionStore
1026
BzrError.__init__(self, branch=branch, revision=revision)
1029
# zero_ninetyone: this exception is no longer raised and should be removed
1030
class NotLeftParentDescendant(InternalBzrError):
1032
_fmt = ("Revision %(old_revision)s is not the left parent of"
1033
" %(new_revision)s, but branch %(branch_location)s expects this")
1035
def __init__(self, branch, old_revision, new_revision):
1036
BzrError.__init__(self, branch_location=branch.base,
1037
old_revision=old_revision,
1038
new_revision=new_revision)
1041
class RangeInChangeOption(BzrError):
1043
_fmt = "Option --change does not accept revision ranges"
1046
class NoSuchRevisionSpec(BzrError):
1048
_fmt = "No namespace registered for string: %(spec)r"
1050
def __init__(self, spec):
1051
BzrError.__init__(self, spec=spec)
1054
class NoSuchRevisionInTree(NoSuchRevision):
1055
"""When using Tree.revision_tree, and the revision is not accessible."""
1057
_fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
1059
def __init__(self, tree, revision_id):
1060
BzrError.__init__(self)
1062
self.revision_id = revision_id
1065
class InvalidRevisionSpec(BzrError):
1067
_fmt = ("Requested revision: %(spec)r does not exist in branch:"
1068
" %(branch)s%(extra)s")
1070
def __init__(self, spec, branch, extra=None):
1071
BzrError.__init__(self, branch=branch, spec=spec)
1073
self.extra = '\n' + str(extra)
1078
class HistoryMissing(BzrError):
1080
_fmt = "%(branch)s is missing %(object_type)s {%(object_id)s}"
1083
class AppendRevisionsOnlyViolation(BzrError):
1085
_fmt = ('Operation denied because it would change the main history,'
1086
' which is not permitted by the append_revisions_only setting on'
1087
' branch "%(location)s".')
1089
def __init__(self, location):
1090
import bzrlib.urlutils as urlutils
1091
location = urlutils.unescape_for_display(location, 'ascii')
1092
BzrError.__init__(self, location=location)
1095
class DivergedBranches(BzrError):
1097
_fmt = ("These branches have diverged."
1098
" Use the merge command to reconcile them.")
1100
def __init__(self, branch1, branch2):
1101
self.branch1 = branch1
1102
self.branch2 = branch2
1105
class NotLefthandHistory(InternalBzrError):
1107
_fmt = "Supplied history does not follow left-hand parents"
1109
def __init__(self, history):
1110
BzrError.__init__(self, history=history)
1113
class UnrelatedBranches(BzrError):
1115
_fmt = ("Branches have no common ancestor, and"
1116
" no merge base revision was specified.")
1119
class CannotReverseCherrypick(BzrError):
1121
_fmt = ('Selected merge cannot perform reverse cherrypicks. Try merge3'
1125
class NoCommonAncestor(BzrError):
1127
_fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1129
def __init__(self, revision_a, revision_b):
1130
self.revision_a = revision_a
1131
self.revision_b = revision_b
1134
class NoCommonRoot(BzrError):
1136
_fmt = ("Revisions are not derived from the same root: "
1137
"%(revision_a)s %(revision_b)s.")
1139
def __init__(self, revision_a, revision_b):
1140
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
1143
class NotAncestor(BzrError):
1145
_fmt = "Revision %(rev_id)s is not an ancestor of %(not_ancestor_id)s"
1147
def __init__(self, rev_id, not_ancestor_id):
1148
BzrError.__init__(self, rev_id=rev_id,
1149
not_ancestor_id=not_ancestor_id)
1152
class InstallFailed(BzrError):
1154
def __init__(self, revisions):
1155
revision_str = ", ".join(str(r) for r in revisions)
1156
msg = "Could not install revisions:\n%s" % revision_str
1157
BzrError.__init__(self, msg)
1158
self.revisions = revisions
1161
class AmbiguousBase(BzrError):
1163
def __init__(self, bases):
1164
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
1166
msg = ("The correct base is unclear, because %s are all equally close"
1168
BzrError.__init__(self, msg)
1172
class NoCommits(BzrError):
1174
_fmt = "Branch %(branch)s has no commits."
1176
def __init__(self, branch):
1177
BzrError.__init__(self, branch=branch)
1180
class UnlistableStore(BzrError):
1182
def __init__(self, store):
1183
BzrError.__init__(self, "Store %s is not listable" % store)
1187
class UnlistableBranch(BzrError):
1189
def __init__(self, br):
1190
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
1193
class BoundBranchOutOfDate(BzrError):
1195
_fmt = ("Bound branch %(branch)s is out of date with master branch"
1198
def __init__(self, branch, master):
1199
BzrError.__init__(self)
1200
self.branch = branch
1201
self.master = master
1204
class CommitToDoubleBoundBranch(BzrError):
1206
_fmt = ("Cannot commit to branch %(branch)s."
1207
" It is bound to %(master)s, which is bound to %(remote)s.")
1209
def __init__(self, branch, master, remote):
1210
BzrError.__init__(self)
1211
self.branch = branch
1212
self.master = master
1213
self.remote = remote
1216
class OverwriteBoundBranch(BzrError):
1218
_fmt = "Cannot pull --overwrite to a branch which is bound %(branch)s"
1220
def __init__(self, branch):
1221
BzrError.__init__(self)
1222
self.branch = branch
1225
class BoundBranchConnectionFailure(BzrError):
1227
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1228
" => %(target)s: %(error)s")
1230
def __init__(self, branch, target, error):
1231
BzrError.__init__(self)
1232
self.branch = branch
1233
self.target = target
1237
class WeaveError(BzrError):
1239
_fmt = "Error in processing weave: %(message)s"
1241
def __init__(self, message=None):
1242
BzrError.__init__(self)
1243
self.message = message
1246
class WeaveRevisionAlreadyPresent(WeaveError):
1248
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1250
def __init__(self, revision_id, weave):
1252
WeaveError.__init__(self)
1253
self.revision_id = revision_id
1257
class WeaveRevisionNotPresent(WeaveError):
1259
_fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1261
def __init__(self, revision_id, weave):
1262
WeaveError.__init__(self)
1263
self.revision_id = revision_id
1267
class WeaveFormatError(WeaveError):
1269
_fmt = "Weave invariant violated: %(what)s"
1271
def __init__(self, what):
1272
WeaveError.__init__(self)
1276
class WeaveParentMismatch(WeaveError):
1278
_fmt = "Parents are mismatched between two revisions. %(message)s"
1281
class WeaveInvalidChecksum(WeaveError):
1283
_fmt = "Text did not match it's checksum: %(message)s"
1286
class WeaveTextDiffers(WeaveError):
1288
_fmt = ("Weaves differ on text content. Revision:"
1289
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1291
def __init__(self, revision_id, weave_a, weave_b):
1292
WeaveError.__init__(self)
1293
self.revision_id = revision_id
1294
self.weave_a = weave_a
1295
self.weave_b = weave_b
1298
class WeaveTextDiffers(WeaveError):
1300
_fmt = ("Weaves differ on text content. Revision:"
1301
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1303
def __init__(self, revision_id, weave_a, weave_b):
1304
WeaveError.__init__(self)
1305
self.revision_id = revision_id
1306
self.weave_a = weave_a
1307
self.weave_b = weave_b
1310
class VersionedFileError(BzrError):
1312
_fmt = "Versioned file error"
1315
class RevisionNotPresent(VersionedFileError):
1317
_fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1319
def __init__(self, revision_id, file_id):
1320
VersionedFileError.__init__(self)
1321
self.revision_id = revision_id
1322
self.file_id = file_id
1325
class RevisionAlreadyPresent(VersionedFileError):
1327
_fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1329
def __init__(self, revision_id, file_id):
1330
VersionedFileError.__init__(self)
1331
self.revision_id = revision_id
1332
self.file_id = file_id
1335
class VersionedFileInvalidChecksum(VersionedFileError):
1337
_fmt = "Text did not match its checksum: %(message)s"
1340
class KnitError(InternalBzrError):
1345
class KnitCorrupt(KnitError):
1347
_fmt = "Knit %(filename)s corrupt: %(how)s"
1349
def __init__(self, filename, how):
1350
KnitError.__init__(self)
1351
self.filename = filename
1355
class KnitDataStreamIncompatible(KnitError):
1356
# Not raised anymore, as we can convert data streams. In future we may
1357
# need it again for more exotic cases, so we're keeping it around for now.
1359
_fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
1361
def __init__(self, stream_format, target_format):
1362
self.stream_format = stream_format
1363
self.target_format = target_format
1366
class KnitDataStreamUnknown(KnitError):
1367
# Indicates a data stream we don't know how to handle.
1369
_fmt = "Cannot parse knit data stream of format \"%(stream_format)s\"."
1371
def __init__(self, stream_format):
1372
self.stream_format = stream_format
1375
class KnitHeaderError(KnitError):
1377
_fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
1379
def __init__(self, badline, filename):
1380
KnitError.__init__(self)
1381
self.badline = badline
1382
self.filename = filename
1384
class KnitIndexUnknownMethod(KnitError):
1385
"""Raised when we don't understand the storage method.
1387
Currently only 'fulltext' and 'line-delta' are supported.
1390
_fmt = ("Knit index %(filename)s does not have a known method"
1391
" in options: %(options)r")
1393
def __init__(self, filename, options):
1394
KnitError.__init__(self)
1395
self.filename = filename
1396
self.options = options
1399
class NoSuchExportFormat(BzrError):
1401
_fmt = "Export format %(format)r not supported"
1403
def __init__(self, format):
1404
BzrError.__init__(self)
1405
self.format = format
1408
class TransportError(BzrError):
1410
_fmt = "Transport error: %(msg)s %(orig_error)s"
1412
def __init__(self, msg=None, orig_error=None):
1413
if msg is None and orig_error is not None:
1414
msg = str(orig_error)
1415
if orig_error is None:
1420
self.orig_error = orig_error
1421
BzrError.__init__(self)
1424
class TooManyConcurrentRequests(InternalBzrError):
1426
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1427
" Be sure to finish_writing and finish_reading on the"
1428
" currently open request.")
1430
def __init__(self, medium):
1431
self.medium = medium
1434
class SmartProtocolError(TransportError):
1436
_fmt = "Generic bzr smart protocol error: %(details)s"
1438
def __init__(self, details):
1439
self.details = details
1442
# A set of semi-meaningful errors which can be thrown
1443
class TransportNotPossible(TransportError):
1445
_fmt = "Transport operation not possible: %(msg)s %(orig_error)s"
1448
class ConnectionError(TransportError):
1450
_fmt = "Connection error: %(msg)s %(orig_error)s"
1453
class SocketConnectionError(ConnectionError):
1455
_fmt = "%(msg)s %(host)s%(port)s%(orig_error)s"
1457
def __init__(self, host, port=None, msg=None, orig_error=None):
1459
msg = 'Failed to connect to'
1460
if orig_error is None:
1463
orig_error = '; ' + str(orig_error)
1464
ConnectionError.__init__(self, msg=msg, orig_error=orig_error)
1469
self.port = ':%s' % port
1472
class ConnectionReset(TransportError):
1474
_fmt = "Connection closed: %(msg)s %(orig_error)s"
1477
class InvalidRange(TransportError):
1479
_fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1481
def __init__(self, path, offset, msg=None):
1482
TransportError.__init__(self, msg)
1484
self.offset = offset
1487
class InvalidHttpResponse(TransportError):
1489
_fmt = "Invalid http response for %(path)s: %(msg)s"
1491
def __init__(self, path, msg, orig_error=None):
1493
TransportError.__init__(self, msg, orig_error=orig_error)
1496
class InvalidHttpRange(InvalidHttpResponse):
1498
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1500
def __init__(self, path, range, msg):
1502
InvalidHttpResponse.__init__(self, path, msg)
1505
class InvalidHttpContentType(InvalidHttpResponse):
1507
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1509
def __init__(self, path, ctype, msg):
1511
InvalidHttpResponse.__init__(self, path, msg)
1514
class RedirectRequested(TransportError):
1516
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1518
def __init__(self, source, target, is_permanent=False, qual_proto=None):
1519
self.source = source
1520
self.target = target
1522
self.permanently = ' permanently'
1524
self.permanently = ''
1525
self._qualified_proto = qual_proto
1526
TransportError.__init__(self)
1528
def _requalify_url(self, url):
1529
"""Restore the qualified proto in front of the url"""
1530
# When this exception is raised, source and target are in
1531
# user readable format. But some transports may use a
1532
# different proto (http+urllib:// will present http:// to
1533
# the user. If a qualified proto is specified, the code
1534
# trapping the exception can get the qualified urls to
1535
# properly handle the redirection themself (creating a
1536
# new transport object from the target url for example).
1537
# But checking that the scheme of the original and
1538
# redirected urls are the same can be tricky. (see the
1539
# FIXME in BzrDir.open_from_transport for the unique use
1541
if self._qualified_proto is None:
1544
# The TODO related to NotBranchError mention that doing
1545
# that kind of manipulation on the urls may not be the
1546
# exception object job. On the other hand, this object is
1547
# the interface between the code and the user so
1548
# presenting the urls in different ways is indeed its
1551
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1552
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1555
def get_source_url(self):
1556
return self._requalify_url(self.source)
1558
def get_target_url(self):
1559
return self._requalify_url(self.target)
1562
class TooManyRedirections(TransportError):
1564
_fmt = "Too many redirections"
1567
class ConflictsInTree(BzrError):
1569
_fmt = "Working tree has conflicts."
1572
class ParseConfigError(BzrError):
1574
def __init__(self, errors, filename):
1575
if filename is None:
1577
message = "Error(s) parsing config file %s:\n%s" % \
1578
(filename, ('\n'.join(e.message for e in errors)))
1579
BzrError.__init__(self, message)
1582
class NoEmailInUsername(BzrError):
1584
_fmt = "%(username)r does not seem to contain a reasonable email address"
1586
def __init__(self, username):
1587
BzrError.__init__(self)
1588
self.username = username
1591
class SigningFailed(BzrError):
1593
_fmt = 'Failed to gpg sign data with command "%(command_line)s"'
1595
def __init__(self, command_line):
1596
BzrError.__init__(self, command_line=command_line)
1599
class WorkingTreeNotRevision(BzrError):
1601
_fmt = ("The working tree for %(basedir)s has changed since"
1602
" the last commit, but weave merge requires that it be"
1605
def __init__(self, tree):
1606
BzrError.__init__(self, basedir=tree.basedir)
1609
class CantReprocessAndShowBase(BzrError):
1611
_fmt = ("Can't reprocess and show base, because reprocessing obscures "
1612
"the relationship of conflicting lines to the base")
1615
class GraphCycleError(BzrError):
1617
_fmt = "Cycle in graph %(graph)r"
1619
def __init__(self, graph):
1620
BzrError.__init__(self)
1624
class WritingCompleted(InternalBzrError):
1626
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1627
"called upon it - accept bytes may not be called anymore.")
1629
def __init__(self, request):
1630
self.request = request
1633
class WritingNotComplete(InternalBzrError):
1635
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1636
"called upon it - until the write phase is complete no "
1637
"data may be read.")
1639
def __init__(self, request):
1640
self.request = request
1643
class NotConflicted(BzrError):
1645
_fmt = "File %(filename)s is not conflicted."
1647
def __init__(self, filename):
1648
BzrError.__init__(self)
1649
self.filename = filename
1652
class MediumNotConnected(InternalBzrError):
1654
_fmt = """The medium '%(medium)s' is not connected."""
1656
def __init__(self, medium):
1657
self.medium = medium
1660
class MustUseDecorated(Exception):
1662
_fmt = "A decorating function has requested its original command be used."
1665
class NoBundleFound(BzrError):
1667
_fmt = 'No bundle was found in "%(filename)s".'
1669
def __init__(self, filename):
1670
BzrError.__init__(self)
1671
self.filename = filename
1674
class BundleNotSupported(BzrError):
1676
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
1678
def __init__(self, version, msg):
1679
BzrError.__init__(self)
1680
self.version = version
1684
class MissingText(BzrError):
1686
_fmt = ("Branch %(base)s is missing revision"
1687
" %(text_revision)s of %(file_id)s")
1689
def __init__(self, branch, text_revision, file_id):
1690
BzrError.__init__(self)
1691
self.branch = branch
1692
self.base = branch.base
1693
self.text_revision = text_revision
1694
self.file_id = file_id
1697
class DuplicateFileId(BzrError):
1699
_fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1701
def __init__(self, file_id, entry):
1702
BzrError.__init__(self)
1703
self.file_id = file_id
1707
class DuplicateKey(BzrError):
1709
_fmt = "Key %(key)s is already present in map"
1712
class DuplicateHelpPrefix(BzrError):
1714
_fmt = "The prefix %(prefix)s is in the help search path twice."
1716
def __init__(self, prefix):
1717
self.prefix = prefix
1720
class MalformedTransform(BzrError):
1722
_fmt = "Tree transform is malformed %(conflicts)r"
1725
class NoFinalPath(BzrError):
1727
_fmt = ("No final name for trans_id %(trans_id)r\n"
1728
"file-id: %(file_id)r\n"
1729
"root trans-id: %(root_trans_id)r\n")
1731
def __init__(self, trans_id, transform):
1732
self.trans_id = trans_id
1733
self.file_id = transform.final_file_id(trans_id)
1734
self.root_trans_id = transform.root
1737
class BzrBadParameter(InternalBzrError):
1739
_fmt = "Bad parameter: %(param)r"
1741
# This exception should never be thrown, but it is a base class for all
1742
# parameter-to-function errors.
1744
def __init__(self, param):
1745
BzrError.__init__(self)
1749
class BzrBadParameterNotUnicode(BzrBadParameter):
1751
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1754
class ReusingTransform(BzrError):
1756
_fmt = "Attempt to reuse a transform that has already been applied."
1759
class CantMoveRoot(BzrError):
1761
_fmt = "Moving the root directory is not supported at this time"
1764
class BzrMoveFailedError(BzrError):
1766
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1768
def __init__(self, from_path='', to_path='', extra=None):
1769
BzrError.__init__(self)
1771
self.extra = ': ' + str(extra)
1775
has_from = len(from_path) > 0
1776
has_to = len(to_path) > 0
1778
self.from_path = osutils.splitpath(from_path)[-1]
1783
self.to_path = osutils.splitpath(to_path)[-1]
1788
if has_from and has_to:
1789
self.operator = " =>"
1791
self.from_path = "from " + from_path
1793
self.operator = "to"
1795
self.operator = "file"
1798
class BzrRenameFailedError(BzrMoveFailedError):
1800
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1802
def __init__(self, from_path, to_path, extra=None):
1803
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1805
class BzrRemoveChangedFilesError(BzrError):
1806
"""Used when user is trying to remove changed files."""
1808
_fmt = ("Can't safely remove modified or unknown files:\n"
1809
"%(changes_as_text)s"
1810
"Use --keep to not delete them, or --force to delete them regardless.")
1812
def __init__(self, tree_delta):
1813
BzrError.__init__(self)
1814
self.changes_as_text = tree_delta.get_changes_as_text()
1815
#self.paths_as_string = '\n'.join(changed_files)
1816
#self.paths_as_string = '\n'.join([quotefn(p) for p in changed_files])
1819
class BzrBadParameterNotString(BzrBadParameter):
1821
_fmt = "Parameter %(param)s is not a string or unicode string."
1824
class BzrBadParameterMissing(BzrBadParameter):
1826
_fmt = "Parameter $(param)s is required but not present."
1829
class BzrBadParameterUnicode(BzrBadParameter):
1831
_fmt = ("Parameter %(param)s is unicode but"
1832
" only byte-strings are permitted.")
1835
class BzrBadParameterContainsNewline(BzrBadParameter):
1837
_fmt = "Parameter %(param)s contains a newline."
1840
class DependencyNotPresent(BzrError):
1842
_fmt = 'Unable to import library "%(library)s": %(error)s'
1844
def __init__(self, library, error):
1845
BzrError.__init__(self, library=library, error=error)
1848
class ParamikoNotPresent(DependencyNotPresent):
1850
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1852
def __init__(self, error):
1853
DependencyNotPresent.__init__(self, 'paramiko', error)
1856
class PointlessMerge(BzrError):
1858
_fmt = "Nothing to merge."
1861
class UninitializableFormat(BzrError):
1863
_fmt = "Format %(format)s cannot be initialised by this version of bzr."
1865
def __init__(self, format):
1866
BzrError.__init__(self)
1867
self.format = format
1870
class BadConversionTarget(BzrError):
1872
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1874
def __init__(self, problem, format):
1875
BzrError.__init__(self)
1876
self.problem = problem
1877
self.format = format
1880
class NoDiffFound(BzrError):
1882
_fmt = 'Could not find an appropriate Differ for file "%(path)s"'
1884
def __init__(self, path):
1885
BzrError.__init__(self, path)
1888
class ExecutableMissing(BzrError):
1890
_fmt = "%(exe_name)s could not be found on this machine"
1892
def __init__(self, exe_name):
1893
BzrError.__init__(self, exe_name=exe_name)
1896
class NoDiff(BzrError):
1898
_fmt = "Diff is not installed on this machine: %(msg)s"
1900
def __init__(self, msg):
1901
BzrError.__init__(self, msg=msg)
1904
class NoDiff3(BzrError):
1906
_fmt = "Diff3 is not installed on this machine."
1909
class ExistingContent(BzrError):
1910
# Added in bzrlib 0.92, used by VersionedFile.add_lines.
1912
_fmt = "The content being inserted is already present."
1915
class ExistingLimbo(BzrError):
1917
_fmt = """This tree contains left-over files from a failed operation.
1918
Please examine %(limbo_dir)s to see if it contains any files you wish to
1919
keep, and delete it when you are done."""
1921
def __init__(self, limbo_dir):
1922
BzrError.__init__(self)
1923
self.limbo_dir = limbo_dir
1926
class ExistingPendingDeletion(BzrError):
1928
_fmt = """This tree contains left-over files from a failed operation.
1929
Please examine %(pending_deletion)s to see if it contains any files you
1930
wish to keep, and delete it when you are done."""
1932
def __init__(self, pending_deletion):
1933
BzrError.__init__(self, pending_deletion=pending_deletion)
1936
class ImmortalLimbo(BzrError):
1938
_fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1939
Please examine %(limbo_dir)s to see if it contains any files you wish to
1940
keep, and delete it when you are done."""
1942
def __init__(self, limbo_dir):
1943
BzrError.__init__(self)
1944
self.limbo_dir = limbo_dir
1947
class ImmortalPendingDeletion(BzrError):
1949
_fmt = ("Unable to delete transform temporary directory "
1950
"%(pending_deletion)s. Please examine %(pending_deletion)s to see if it "
1951
"contains any files you wish to keep, and delete it when you are done.")
1953
def __init__(self, pending_deletion):
1954
BzrError.__init__(self, pending_deletion=pending_deletion)
1957
class OutOfDateTree(BzrError):
1959
_fmt = "Working tree is out of date, please run 'bzr update'."
1961
def __init__(self, tree):
1962
BzrError.__init__(self)
1966
class PublicBranchOutOfDate(BzrError):
1968
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1971
def __init__(self, public_location, revstring):
1972
import bzrlib.urlutils as urlutils
1973
public_location = urlutils.unescape_for_display(public_location,
1975
BzrError.__init__(self, public_location=public_location,
1976
revstring=revstring)
1979
class MergeModifiedFormatError(BzrError):
1981
_fmt = "Error in merge modified format"
1984
class ConflictFormatError(BzrError):
1986
_fmt = "Format error in conflict listings"
1989
class CorruptDirstate(BzrError):
1991
_fmt = ("Inconsistency in dirstate file %(dirstate_path)s.\n"
1992
"Error: %(description)s")
1994
def __init__(self, dirstate_path, description):
1995
BzrError.__init__(self)
1996
self.dirstate_path = dirstate_path
1997
self.description = description
2000
class CorruptRepository(BzrError):
2002
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
2003
"Please run bzr reconcile on this repository.")
2005
def __init__(self, repo):
2006
BzrError.__init__(self)
2007
self.repo_path = repo.bzrdir.root_transport.base
2010
class InconsistentDelta(BzrError):
2011
"""Used when we get a delta that is not valid."""
2013
_fmt = ("An inconsistent delta was supplied involving %(path)r,"
2014
" %(file_id)r\nreason: %(reason)s")
2016
def __init__(self, path, file_id, reason):
2017
BzrError.__init__(self)
2019
self.file_id = file_id
2020
self.reason = reason
2023
class UpgradeRequired(BzrError):
2025
_fmt = "To use this feature you must upgrade your branch at %(path)s."
2027
def __init__(self, path):
2028
BzrError.__init__(self)
2032
class LocalRequiresBoundBranch(BzrError):
2034
_fmt = "Cannot perform local-only commits on unbound branches."
2037
class MissingProgressBarFinish(BzrError):
2039
_fmt = "A nested progress bar was not 'finished' correctly."
2042
class InvalidProgressBarType(BzrError):
2044
_fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
2045
" is not a supported type Select one of: %(valid_types)s")
2047
def __init__(self, bar_type, valid_types):
2048
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
2051
class UnsupportedOperation(BzrError):
2053
_fmt = ("The method %(mname)s is not supported on"
2054
" objects of type %(tname)s.")
2056
def __init__(self, method, method_self):
2057
self.method = method
2058
self.mname = method.__name__
2059
self.tname = type(method_self).__name__
2062
class CannotSetRevisionId(UnsupportedOperation):
2063
"""Raised when a commit is attempting to set a revision id but cant."""
2066
class NonAsciiRevisionId(UnsupportedOperation):
2067
"""Raised when a commit is attempting to set a non-ascii revision id
2072
class BinaryFile(BzrError):
2074
_fmt = "File is binary but should be text."
2077
class IllegalPath(BzrError):
2079
_fmt = "The path %(path)s is not permitted on this platform"
2081
def __init__(self, path):
2082
BzrError.__init__(self)
2086
class TestamentMismatch(BzrError):
2088
_fmt = """Testament did not match expected value.
2089
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
2092
def __init__(self, revision_id, expected, measured):
2093
self.revision_id = revision_id
2094
self.expected = expected
2095
self.measured = measured
2098
class NotABundle(BzrError):
2100
_fmt = "Not a bzr revision-bundle: %(text)r"
2102
def __init__(self, text):
2103
BzrError.__init__(self)
2107
class BadBundle(BzrError):
2109
_fmt = "Bad bzr revision-bundle: %(text)r"
2111
def __init__(self, text):
2112
BzrError.__init__(self)
2116
class MalformedHeader(BadBundle):
2118
_fmt = "Malformed bzr revision-bundle header: %(text)r"
2121
class MalformedPatches(BadBundle):
2123
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
2126
class MalformedFooter(BadBundle):
2128
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
2131
class UnsupportedEOLMarker(BadBundle):
2133
_fmt = "End of line marker was not \\n in bzr revision-bundle"
2136
# XXX: BadBundle's constructor assumes there's explanatory text,
2137
# but for this there is not
2138
BzrError.__init__(self)
2141
class IncompatibleBundleFormat(BzrError):
2143
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
2145
def __init__(self, bundle_format, other):
2146
BzrError.__init__(self)
2147
self.bundle_format = bundle_format
2151
class BadInventoryFormat(BzrError):
2153
_fmt = "Root class for inventory serialization errors"
2156
class UnexpectedInventoryFormat(BadInventoryFormat):
2158
_fmt = "The inventory was not in the expected format:\n %(msg)s"
2160
def __init__(self, msg):
2161
BadInventoryFormat.__init__(self, msg=msg)
2164
class RootNotRich(BzrError):
2166
_fmt = """This operation requires rich root data storage"""
2169
class NoSmartMedium(InternalBzrError):
2171
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
2173
def __init__(self, transport):
2174
self.transport = transport
2177
class NoSmartServer(NotBranchError):
2179
_fmt = "No smart server available at %(url)s"
2181
def __init__(self, url):
2185
class UnknownSSH(BzrError):
2187
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
2189
def __init__(self, vendor):
2190
BzrError.__init__(self)
2191
self.vendor = vendor
2194
class SSHVendorNotFound(BzrError):
2196
_fmt = ("Don't know how to handle SSH connections."
2197
" Please set BZR_SSH environment variable.")
2200
class GhostRevisionUnusableHere(BzrError):
2202
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2204
def __init__(self, revision_id):
2205
BzrError.__init__(self)
2206
self.revision_id = revision_id
2209
class IllegalUseOfScopeReplacer(InternalBzrError):
2211
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2212
" %(msg)s%(extra)s")
2214
def __init__(self, name, msg, extra=None):
2215
BzrError.__init__(self)
2219
self.extra = ': ' + str(extra)
2224
class InvalidImportLine(InternalBzrError):
2226
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
2228
def __init__(self, text, msg):
2229
BzrError.__init__(self)
2234
class ImportNameCollision(InternalBzrError):
2236
_fmt = ("Tried to import an object to the same name as"
2237
" an existing object. %(name)s")
2239
def __init__(self, name):
2240
BzrError.__init__(self)
2244
class NotAMergeDirective(BzrError):
2245
"""File starting with %(firstline)r is not a merge directive"""
2246
def __init__(self, firstline):
2247
BzrError.__init__(self, firstline=firstline)
2250
class NoMergeSource(BzrError):
2251
"""Raise if no merge source was specified for a merge directive"""
2253
_fmt = "A merge directive must provide either a bundle or a public"\
2257
class IllegalMergeDirectivePayload(BzrError):
2258
"""A merge directive contained something other than a patch or bundle"""
2260
_fmt = "Bad merge directive payload %(start)r"
2262
def __init__(self, start):
2267
class PatchVerificationFailed(BzrError):
2268
"""A patch from a merge directive could not be verified"""
2270
_fmt = "Preview patch does not match requested changes."
2273
class PatchMissing(BzrError):
2274
"""Raise a patch type was specified but no patch supplied"""
2276
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2278
def __init__(self, patch_type):
2279
BzrError.__init__(self)
2280
self.patch_type = patch_type
2283
class UnsupportedInventoryKind(BzrError):
2285
_fmt = """Unsupported entry kind %(kind)s"""
2287
def __init__(self, kind):
2291
class BadSubsumeSource(BzrError):
2293
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2295
def __init__(self, tree, other_tree, reason):
2297
self.other_tree = other_tree
2298
self.reason = reason
2301
class SubsumeTargetNeedsUpgrade(BzrError):
2303
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2305
def __init__(self, other_tree):
2306
self.other_tree = other_tree
2309
class BadReferenceTarget(InternalBzrError):
2311
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2314
def __init__(self, tree, other_tree, reason):
2316
self.other_tree = other_tree
2317
self.reason = reason
2320
class NoSuchTag(BzrError):
2322
_fmt = "No such tag: %(tag_name)s"
2324
def __init__(self, tag_name):
2325
self.tag_name = tag_name
2328
class TagsNotSupported(BzrError):
2330
_fmt = ("Tags not supported by %(branch)s;"
2331
" you may be able to use bzr upgrade --dirstate-tags.")
2333
def __init__(self, branch):
2334
self.branch = branch
2337
class TagAlreadyExists(BzrError):
2339
_fmt = "Tag %(tag_name)s already exists."
2341
def __init__(self, tag_name):
2342
self.tag_name = tag_name
2345
class MalformedBugIdentifier(BzrError):
2347
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2349
def __init__(self, bug_id, reason):
2350
self.bug_id = bug_id
2351
self.reason = reason
2354
class InvalidBugTrackerURL(BzrError):
2356
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2357
"contain {id}: %(url)s")
2359
def __init__(self, abbreviation, url):
2360
self.abbreviation = abbreviation
2364
class UnknownBugTrackerAbbreviation(BzrError):
2366
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2369
def __init__(self, abbreviation, branch):
2370
self.abbreviation = abbreviation
2371
self.branch = branch
2374
class UnexpectedSmartServerResponse(BzrError):
2376
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2378
def __init__(self, response_tuple):
2379
self.response_tuple = response_tuple
2382
class ContainerError(BzrError):
2383
"""Base class of container errors."""
2386
class UnknownContainerFormatError(ContainerError):
2388
_fmt = "Unrecognised container format: %(container_format)r"
2390
def __init__(self, container_format):
2391
self.container_format = container_format
2394
class UnexpectedEndOfContainerError(ContainerError):
2396
_fmt = "Unexpected end of container stream"
2399
class UnknownRecordTypeError(ContainerError):
2401
_fmt = "Unknown record type: %(record_type)r"
2403
def __init__(self, record_type):
2404
self.record_type = record_type
2407
class InvalidRecordError(ContainerError):
2409
_fmt = "Invalid record: %(reason)s"
2411
def __init__(self, reason):
2412
self.reason = reason
2415
class ContainerHasExcessDataError(ContainerError):
2417
_fmt = "Container has data after end marker: %(excess)r"
2419
def __init__(self, excess):
2420
self.excess = excess
2423
class DuplicateRecordNameError(ContainerError):
2425
_fmt = "Container has multiple records with the same name: %(name)s"
2427
def __init__(self, name):
2431
class NoDestinationAddress(InternalBzrError):
2433
_fmt = "Message does not have a destination address."
2436
class RepositoryDataStreamError(BzrError):
2438
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2440
def __init__(self, reason):
2441
self.reason = reason
2444
class SMTPError(BzrError):
2446
_fmt = "SMTP error: %(error)s"
2448
def __init__(self, error):
2452
class NoMessageSupplied(BzrError):
2454
_fmt = "No message supplied."
2457
class NoMailAddressSpecified(BzrError):
2459
_fmt = "No mail-to address specified."
2462
class UnknownMailClient(BzrError):
2464
_fmt = "Unknown mail client: %(mail_client)s"
2466
def __init__(self, mail_client):
2467
BzrError.__init__(self, mail_client=mail_client)
2470
class MailClientNotFound(BzrError):
2472
_fmt = "Unable to find mail client with the following names:"\
2473
" %(mail_command_list_string)s"
2475
def __init__(self, mail_command_list):
2476
mail_command_list_string = ', '.join(mail_command_list)
2477
BzrError.__init__(self, mail_command_list=mail_command_list,
2478
mail_command_list_string=mail_command_list_string)
2480
class SMTPConnectionRefused(SMTPError):
2482
_fmt = "SMTP connection to %(host)s refused"
2484
def __init__(self, error, host):
2489
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2491
_fmt = "Please specify smtp_server. No server at default %(host)s."
2494
class BzrDirError(BzrError):
2496
def __init__(self, bzrdir):
2497
import bzrlib.urlutils as urlutils
2498
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2500
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2503
class AlreadyBranch(BzrDirError):
2505
_fmt = "'%(display_url)s' is already a branch."
2508
class AlreadyTree(BzrDirError):
2510
_fmt = "'%(display_url)s' is already a tree."
2513
class AlreadyCheckout(BzrDirError):
2515
_fmt = "'%(display_url)s' is already a checkout."
2518
class AlreadyLightweightCheckout(BzrDirError):
2520
_fmt = "'%(display_url)s' is already a lightweight checkout."
2523
class ReconfigurationNotSupported(BzrDirError):
2525
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2528
class NoBindLocation(BzrDirError):
2530
_fmt = "No location could be found to bind to at %(display_url)s."
2533
class UncommittedChanges(BzrError):
2535
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2537
def __init__(self, tree):
2538
import bzrlib.urlutils as urlutils
2539
display_url = urlutils.unescape_for_display(
2540
tree.bzrdir.root_transport.base, 'ascii')
2541
BzrError.__init__(self, tree=tree, display_url=display_url)
2544
class MissingTemplateVariable(BzrError):
2546
_fmt = 'Variable {%(name)s} is not available.'
2548
def __init__(self, name):
2552
class NoTemplate(BzrError):
2554
_fmt = 'No template specified.'
2557
class UnableCreateSymlink(BzrError):
2559
_fmt = 'Unable to create symlink %(path_str)son this platform'
2561
def __init__(self, path=None):
2565
path_str = repr(str(path))
2566
except UnicodeEncodeError:
2567
path_str = repr(path)
2569
self.path_str = path_str
2572
class UnsupportedTimezoneFormat(BzrError):
2574
_fmt = ('Unsupported timezone format "%(timezone)s", '
2575
'options are "utc", "original", "local".')
2577
def __init__(self, timezone):
2578
self.timezone = timezone