1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# 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
47
# return codes from the bzr program
49
EXIT_INTERNAL_ERROR = 4
52
class BzrError(StandardError):
54
Base class for errors raised by bzrlib.
56
:cvar internal_error: if True this was probably caused by a bzr bug and
57
should be displayed with a traceback; if False (or absent) this was
58
probably a user or environment error and they don't need the gory details.
59
(That can be overridden by -Derror on the command line.)
61
:cvar _fmt: Format string to display the error; this is expanded
62
by the instance's dict.
65
internal_error = False
67
def __init__(self, msg=None, **kwds):
68
"""Construct a new BzrError.
70
There are two alternative forms for constructing these objects.
71
Either a preformatted string may be passed, or a set of named
72
arguments can be given. The first is for generic "user" errors which
73
are not intended to be caught and so do not need a specific subclass.
74
The second case is for use with subclasses that provide a _fmt format
75
string to print the arguments.
77
Keyword arguments are taken as parameters to the error, which can
78
be inserted into the format string template. It's recommended
79
that subclasses override the __init__ method to require specific
82
:param msg: If given, this is the literal complete text for the error,
83
not subject to expansion.
85
StandardError.__init__(self)
87
# I was going to deprecate this, but it actually turns out to be
88
# quite handy - mbp 20061103.
89
self._preformatted_string = msg
91
self._preformatted_string = None
92
for key, value in kwds.items():
93
setattr(self, key, value)
96
s = getattr(self, '_preformatted_string', None)
98
# contains a preformatted message; must be cast to plain str
101
fmt = self._get_format_string()
103
s = fmt % self.__dict__
104
# __str__() should always return a 'str' object
105
# never a 'unicode' object.
106
if isinstance(s, unicode):
107
return s.encode('utf8')
109
except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
110
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
111
% (self.__class__.__name__,
113
getattr(self, '_fmt', None),
116
def _get_format_string(self):
117
"""Return format string for this exception or None"""
118
fmt = getattr(self, '_fmt', None)
121
fmt = getattr(self, '__doc__', None)
123
symbol_versioning.warn("%s uses its docstring as a format, "
124
"it should use _fmt instead" % self.__class__.__name__,
127
return 'Unprintable exception %s: dict=%r, fmt=%r' \
128
% (self.__class__.__name__,
130
getattr(self, '_fmt', None),
134
class BzrNewError(BzrError):
135
"""Deprecated error base class."""
136
# base classes should override the docstring with their human-
137
# readable explanation
139
def __init__(self, *args, **kwds):
140
# XXX: Use the underlying BzrError to always generate the args
141
# attribute if it doesn't exist. We can't use super here, because
142
# exceptions are old-style classes in python2.4 (but new in 2.5).
144
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
145
'please convert %s to use BzrError instead'
146
% self.__class__.__name__,
149
BzrError.__init__(self, *args)
150
for key, value in kwds.items():
151
setattr(self, key, value)
155
# __str__() should always return a 'str' object
156
# never a 'unicode' object.
157
s = self.__doc__ % self.__dict__
158
if isinstance(s, unicode):
159
return s.encode('utf8')
161
except (TypeError, NameError, ValueError, KeyError), e:
162
return 'Unprintable exception %s(%r): %r' \
163
% (self.__class__.__name__,
167
class AlreadyBuilding(BzrError):
169
_fmt = "The tree builder is already building a tree."
172
class BzrCheckError(BzrError):
174
_fmt = "Internal check failed: %(message)s"
176
internal_error = True
178
def __init__(self, message):
179
BzrError.__init__(self)
180
self.message = message
183
class DisabledMethod(BzrError):
185
_fmt = "The smart server method '%(class_name)s' is disabled."
187
internal_error = True
189
def __init__(self, class_name):
190
BzrError.__init__(self)
191
self.class_name = class_name
194
class IncompatibleAPI(BzrError):
196
_fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
197
'It supports versions "%(minimum)s" to "%(current)s".'
199
def __init__(self, api, wanted, minimum, current):
202
self.minimum = minimum
203
self.current = current
206
class InProcessTransport(BzrError):
208
_fmt = "The transport '%(transport)s' is only accessible within this " \
211
def __init__(self, transport):
212
self.transport = transport
215
class InvalidEntryName(BzrError):
217
_fmt = "Invalid entry name: %(name)s"
219
internal_error = True
221
def __init__(self, name):
222
BzrError.__init__(self)
226
class InvalidRevisionNumber(BzrError):
228
_fmt = "Invalid revision number %(revno)s"
230
def __init__(self, revno):
231
BzrError.__init__(self)
235
class InvalidRevisionId(BzrError):
237
_fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
239
def __init__(self, revision_id, branch):
240
# branch can be any string or object with __str__ defined
241
BzrError.__init__(self)
242
self.revision_id = revision_id
245
class ReservedId(BzrError):
247
_fmt = "Reserved revision-id {%(revision_id)s}"
249
def __init__(self, revision_id):
250
self.revision_id = revision_id
253
class NoHelpTopic(BzrError):
255
_fmt = ("No help could be found for '%(topic)s'. "
256
"Please use 'bzr help topics' to obtain a list of topics.")
258
def __init__(self, topic):
262
class NoSuchId(BzrError):
264
_fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
266
def __init__(self, tree, file_id):
267
BzrError.__init__(self)
268
self.file_id = file_id
272
class NoSuchIdInRepository(NoSuchId):
274
_fmt = ('The file id "%(file_id)s" is not present in the repository'
277
def __init__(self, repository, file_id):
278
BzrError.__init__(self, repository=repository, file_id=file_id)
281
class InventoryModified(BzrError):
283
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
284
" so a clean inventory cannot be read without data loss.")
286
internal_error = True
288
def __init__(self, tree):
292
class NoWorkingTree(BzrError):
294
_fmt = 'No WorkingTree exists for "%(base)s".'
296
def __init__(self, base):
297
BzrError.__init__(self)
301
class NotBuilding(BzrError):
303
_fmt = "Not currently building a tree."
306
class NotLocalUrl(BzrError):
308
_fmt = "%(url)s is not a local path."
310
def __init__(self, url):
314
class WorkingTreeAlreadyPopulated(BzrError):
316
_fmt = 'Working tree already populated in "%(base)s"'
318
internal_error = True
320
def __init__(self, base):
323
class BzrCommandError(BzrError):
324
"""Error from user command"""
326
internal_error = False
328
# Error from malformed user command; please avoid raising this as a
329
# generic exception not caused by user input.
331
# I think it's a waste of effort to differentiate between errors that
332
# are not intended to be caught anyway. UI code need not subclass
333
# BzrCommandError, and non-UI code should not throw a subclass of
334
# BzrCommandError. ADHB 20051211
335
def __init__(self, msg):
336
# Object.__str__() must return a real string
337
# returning a Unicode string is a python error.
338
if isinstance(msg, unicode):
339
self.msg = msg.encode('utf8')
347
class NotWriteLocked(BzrError):
349
_fmt = """%(not_locked)r is not write locked but needs to be."""
351
def __init__(self, not_locked):
352
self.not_locked = not_locked
355
class BzrOptionError(BzrCommandError):
357
_fmt = "Error in command line options"
360
class BadIndexFormatSignature(BzrError):
362
_fmt = "%(value)s is not an index of type %(_type)s."
364
def __init__(self, value, _type):
365
BzrError.__init__(self)
370
class BadIndexData(BzrError):
372
_fmt = "Error in data for index %(value)s."
374
def __init__(self, value):
375
BzrError.__init__(self)
379
class BadIndexDuplicateKey(BzrError):
381
_fmt = "The key '%(key)s' is already in index '%(index)s'."
383
def __init__(self, key, index):
384
BzrError.__init__(self)
389
class BadIndexKey(BzrError):
391
_fmt = "The key '%(key)s' is not a valid key."
393
def __init__(self, key):
394
BzrError.__init__(self)
398
class BadIndexOptions(BzrError):
400
_fmt = "Could not parse options for index %(value)s."
402
def __init__(self, value):
403
BzrError.__init__(self)
407
class BadIndexValue(BzrError):
409
_fmt = "The value '%(value)s' is not a valid value."
411
def __init__(self, value):
412
BzrError.__init__(self)
416
class BadOptionValue(BzrError):
418
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
420
def __init__(self, name, value):
421
BzrError.__init__(self, name=name, value=value)
424
class StrictCommitFailed(BzrError):
426
_fmt = "Commit refused because there are unknown files in the tree"
429
# XXX: Should be unified with TransportError; they seem to represent the
431
# RBC 20060929: I think that unifiying with TransportError would be a mistake
432
# - this is finer than a TransportError - and more useful as such. It
433
# differentiates between 'transport has failed' and 'operation on a transport
435
class PathError(BzrError):
437
_fmt = "Generic path error: %(path)r%(extra)s)"
439
def __init__(self, path, extra=None):
440
BzrError.__init__(self)
443
self.extra = ': ' + str(extra)
448
class NoSuchFile(PathError):
450
_fmt = "No such file: %(path)r%(extra)s"
453
class FileExists(PathError):
455
_fmt = "File exists: %(path)r%(extra)s"
458
class RenameFailedFilesExist(BzrError):
459
"""Used when renaming and both source and dest exist."""
461
_fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
464
def __init__(self, source, dest, extra=None):
465
BzrError.__init__(self)
466
self.source = str(source)
467
self.dest = str(dest)
469
self.extra = ' ' + str(extra)
474
class NotADirectory(PathError):
476
_fmt = '"%(path)s" is not a directory %(extra)s'
479
class NotInWorkingDirectory(PathError):
481
_fmt = '"%(path)s" is not in the working directory %(extra)s'
484
class DirectoryNotEmpty(PathError):
486
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
489
class ReadingCompleted(BzrError):
491
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
492
"called upon it - the request has been completed and no more "
495
internal_error = True
497
def __init__(self, request):
498
self.request = request
501
class ResourceBusy(PathError):
503
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
506
class PermissionDenied(PathError):
508
_fmt = 'Permission denied: "%(path)s"%(extra)s'
511
class InvalidURL(PathError):
513
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
516
class InvalidURLJoin(PathError):
518
_fmt = 'Invalid URL join request: "%(args)s"%(extra)s'
520
def __init__(self, msg, base, args):
521
PathError.__init__(self, base, msg)
522
self.args = [base] + list(args)
525
class UnknownHook(BzrError):
527
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
529
def __init__(self, hook_type, hook_name):
530
BzrError.__init__(self)
531
self.type = hook_type
532
self.hook = hook_name
535
class UnsupportedProtocol(PathError):
537
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
539
def __init__(self, url, extra):
540
PathError.__init__(self, url, extra=extra)
543
class ReadError(PathError):
545
_fmt = """Error reading from %(path)r."""
548
class ShortReadvError(PathError):
550
_fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
551
' at %(offset)s for "%(path)s"%(extra)s')
553
internal_error = True
555
def __init__(self, path, offset, length, actual, extra=None):
556
PathError.__init__(self, path, extra=extra)
562
class PathNotChild(PathError):
564
_fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
566
internal_error = True
568
def __init__(self, path, base, extra=None):
569
BzrError.__init__(self)
573
self.extra = ': ' + str(extra)
578
class InvalidNormalization(PathError):
580
_fmt = 'Path "%(path)s" is not unicode normalized'
583
# TODO: This is given a URL; we try to unescape it but doing that from inside
584
# the exception object is a bit undesirable.
585
# TODO: Probably this behavior of should be a common superclass
586
class NotBranchError(PathError):
588
_fmt = 'Not a branch: "%(path)s".'
590
def __init__(self, path):
591
import bzrlib.urlutils as urlutils
592
self.path = urlutils.unescape_for_display(path, 'ascii')
595
class NoSubmitBranch(PathError):
597
_fmt = 'No submit branch available for branch "%(path)s"'
599
def __init__(self, branch):
600
import bzrlib.urlutils as urlutils
601
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
604
class AlreadyBranchError(PathError):
606
_fmt = 'Already a branch: "%(path)s".'
609
class BranchExistsWithoutWorkingTree(PathError):
611
_fmt = 'Directory contains a branch, but no working tree \
612
(use bzr checkout if you wish to build a working tree): "%(path)s"'
615
class AtomicFileAlreadyClosed(PathError):
617
_fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
620
def __init__(self, path, function):
621
PathError.__init__(self, path=path, extra=None)
622
self.function = function
625
class InaccessibleParent(PathError):
627
_fmt = ('Parent not accessible given base "%(base)s" and'
628
' relative path "%(path)s"')
630
def __init__(self, path, base):
631
PathError.__init__(self, path)
635
class NoRepositoryPresent(BzrError):
637
_fmt = 'No repository present: "%(path)s"'
638
def __init__(self, bzrdir):
639
BzrError.__init__(self)
640
self.path = bzrdir.transport.clone('..').base
643
class FileInWrongBranch(BzrError):
645
_fmt = 'File "%(path)s" in not in branch %(branch_base)s.'
647
def __init__(self, branch, path):
648
BzrError.__init__(self)
650
self.branch_base = branch.base
654
class UnsupportedFormatError(BzrError):
656
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
659
class UnknownFormatError(BzrError):
661
_fmt = "Unknown branch format: %(format)r"
664
class IncompatibleFormat(BzrError):
666
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
668
def __init__(self, format, bzrdir_format):
669
BzrError.__init__(self)
671
self.bzrdir = bzrdir_format
674
class IncompatibleRepositories(BzrError):
676
_fmt = "Repository %(target)s is not compatible with repository"\
679
def __init__(self, source, target):
680
BzrError.__init__(self, target=target, source=source)
683
class IncompatibleRevision(BzrError):
685
_fmt = "Revision is not compatible with %(repo_format)s"
687
def __init__(self, repo_format):
688
BzrError.__init__(self)
689
self.repo_format = repo_format
692
class AlreadyVersionedError(BzrError):
693
"""Used when a path is expected not to be versioned, but it is."""
695
_fmt = "%(context_info)s%(path)s is already versioned."
697
def __init__(self, path, context_info=None):
698
"""Construct a new AlreadyVersionedError.
700
:param path: This is the path which is versioned,
701
which should be in a user friendly form.
702
:param context_info: If given, this is information about the context,
703
which could explain why this is expected to not be versioned.
705
BzrError.__init__(self)
707
if context_info is None:
708
self.context_info = ''
710
self.context_info = context_info + ". "
713
class NotVersionedError(BzrError):
714
"""Used when a path is expected to be versioned, but it is not."""
716
_fmt = "%(context_info)s%(path)s is not versioned."
718
def __init__(self, path, context_info=None):
719
"""Construct a new NotVersionedError.
721
:param path: This is the path which is not versioned,
722
which should be in a user friendly form.
723
:param context_info: If given, this is information about the context,
724
which could explain why this is expected to be versioned.
726
BzrError.__init__(self)
728
if context_info is None:
729
self.context_info = ''
731
self.context_info = context_info + ". "
734
class PathsNotVersionedError(BzrError):
735
"""Used when reporting several paths which are not versioned"""
737
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
739
def __init__(self, paths):
740
from bzrlib.osutils import quotefn
741
BzrError.__init__(self)
743
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
746
class PathsDoNotExist(BzrError):
748
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
750
# used when reporting that paths are neither versioned nor in the working
753
def __init__(self, paths, extra=None):
755
from bzrlib.osutils import quotefn
756
BzrError.__init__(self)
758
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
760
self.extra = ': ' + str(extra)
765
class BadFileKindError(BzrError):
767
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
769
def __init__(self, filename, kind):
770
BzrError.__init__(self, filename=filename, kind=kind)
773
class ForbiddenControlFileError(BzrError):
775
_fmt = 'Cannot operate on "%(filename)s" because it is a control file'
778
class LockError(BzrError):
780
_fmt = "Lock error: %(msg)s"
782
internal_error = True
784
# All exceptions from the lock/unlock functions should be from
785
# this exception class. They will be translated as necessary. The
786
# original exception is available as e.original_error
788
# New code should prefer to raise specific subclasses
789
def __init__(self, message):
790
# Python 2.5 uses a slot for StandardError.message,
791
# so use a different variable name
792
# so it is exposed in self.__dict__
796
class LockActive(LockError):
798
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
800
internal_error = False
802
def __init__(self, lock_description):
803
self.lock_description = lock_description
806
class CommitNotPossible(LockError):
808
_fmt = "A commit was attempted but we do not have a write lock open."
814
class AlreadyCommitted(LockError):
816
_fmt = "A rollback was requested, but is not able to be accomplished."
822
class ReadOnlyError(LockError):
824
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
826
# TODO: There should also be an error indicating that you need a write
827
# lock and don't have any lock at all... mbp 20070226
829
def __init__(self, obj):
833
class ReadOnlyLockError(LockError):
835
_fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
837
def __init__(self, fname, msg):
838
LockError.__init__(self, '')
843
class OutSideTransaction(BzrError):
845
_fmt = ("A transaction related operation was attempted after"
846
" the transaction finished.")
849
class ObjectNotLocked(LockError):
851
_fmt = "%(obj)r is not locked"
853
# this can indicate that any particular object is not locked; see also
854
# LockNotHeld which means that a particular *lock* object is not held by
855
# the caller -- perhaps they should be unified.
856
def __init__(self, obj):
860
class ReadOnlyObjectDirtiedError(ReadOnlyError):
862
_fmt = "Cannot change object %(obj)r in read only transaction"
864
def __init__(self, obj):
868
class UnlockableTransport(LockError):
870
_fmt = "Cannot lock: transport is read only: %(transport)s"
872
def __init__(self, transport):
873
self.transport = transport
876
class LockContention(LockError):
878
_fmt = 'Could not acquire lock "%(lock)s"'
879
# TODO: show full url for lock, combining the transport and relative
882
internal_error = False
884
def __init__(self, lock):
888
class LockBroken(LockError):
890
_fmt = ("Lock was broken while still open: %(lock)s"
891
" - check storage consistency!")
893
internal_error = False
895
def __init__(self, lock):
899
class LockBreakMismatch(LockError):
901
_fmt = ("Lock was released and re-acquired before being broken:"
902
" %(lock)s: held by %(holder)r, wanted to break %(target)r")
904
internal_error = False
906
def __init__(self, lock, holder, target):
912
class LockNotHeld(LockError):
914
_fmt = "Lock not held: %(lock)s"
916
internal_error = False
918
def __init__(self, lock):
922
class TokenLockingNotSupported(LockError):
924
_fmt = "The object %(obj)s does not support token specifying a token when locking."
926
internal_error = True
928
def __init__(self, obj):
932
class TokenMismatch(LockBroken):
934
_fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
936
internal_error = True
938
def __init__(self, given_token, lock_token):
939
self.given_token = given_token
940
self.lock_token = lock_token
943
class PointlessCommit(BzrError):
945
_fmt = "No changes to commit"
948
class CannotCommitSelectedFileMerge(BzrError):
950
_fmt = 'Selected-file commit of merges is not supported yet:'\
951
' files %(files_str)s'
953
def __init__(self, files):
954
files_str = ', '.join(files)
955
BzrError.__init__(self, files=files, files_str=files_str)
958
class BadCommitMessageEncoding(BzrError):
960
_fmt = 'The specified commit message contains characters unsupported by '\
961
'the current encoding.'
964
class UpgradeReadonly(BzrError):
966
_fmt = "Upgrade URL cannot work with readonly URLs."
969
class UpToDateFormat(BzrError):
971
_fmt = "The branch format %(format)s is already at the most recent format."
973
def __init__(self, format):
974
BzrError.__init__(self)
978
class StrictCommitFailed(Exception):
980
_fmt = "Commit refused because there are unknowns in the tree."
983
class NoSuchRevision(BzrError):
985
_fmt = "%(branch)s has no revision %(revision)s"
987
internal_error = True
989
def __init__(self, branch, revision):
990
# 'branch' may sometimes be an internal object like a KnitRevisionStore
991
BzrError.__init__(self, branch=branch, revision=revision)
994
# zero_ninetyone: this exception is no longer raised and should be removed
995
class NotLeftParentDescendant(BzrError):
997
_fmt = ("Revision %(old_revision)s is not the left parent of"
998
" %(new_revision)s, but branch %(branch_location)s expects this")
1000
internal_error = True
1002
def __init__(self, branch, old_revision, new_revision):
1003
BzrError.__init__(self, branch_location=branch.base,
1004
old_revision=old_revision,
1005
new_revision=new_revision)
1008
class RangeInChangeOption(BzrError):
1010
_fmt = "Option --change does not accept revision ranges"
1013
class NoSuchRevisionSpec(BzrError):
1015
_fmt = "No namespace registered for string: %(spec)r"
1017
def __init__(self, spec):
1018
BzrError.__init__(self, spec=spec)
1021
class NoSuchRevisionInTree(NoSuchRevision):
1022
"""When using Tree.revision_tree, and the revision is not accessible."""
1024
_fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
1026
def __init__(self, tree, revision_id):
1027
BzrError.__init__(self)
1029
self.revision_id = revision_id
1032
class InvalidRevisionSpec(BzrError):
1034
_fmt = ("Requested revision: %(spec)r does not exist in branch:"
1035
" %(branch)s%(extra)s")
1037
def __init__(self, spec, branch, extra=None):
1038
BzrError.__init__(self, branch=branch, spec=spec)
1040
self.extra = '\n' + str(extra)
1045
class HistoryMissing(BzrError):
1047
_fmt = "%(branch)s is missing %(object_type)s {%(object_id)s}"
1050
class AppendRevisionsOnlyViolation(BzrError):
1052
_fmt = ('Operation denied because it would change the main history,'
1053
' which is not permitted by the append_revisions_only setting on'
1054
' branch "%(location)s".')
1056
def __init__(self, location):
1057
import bzrlib.urlutils as urlutils
1058
location = urlutils.unescape_for_display(location, 'ascii')
1059
BzrError.__init__(self, location=location)
1062
class DivergedBranches(BzrError):
1064
_fmt = ("These branches have diverged."
1065
" Use the merge command to reconcile them.")
1067
internal_error = False
1069
def __init__(self, branch1, branch2):
1070
self.branch1 = branch1
1071
self.branch2 = branch2
1074
class NotLefthandHistory(BzrError):
1076
_fmt = "Supplied history does not follow left-hand parents"
1078
internal_error = True
1080
def __init__(self, history):
1081
BzrError.__init__(self, history=history)
1084
class UnrelatedBranches(BzrError):
1086
_fmt = ("Branches have no common ancestor, and"
1087
" no merge base revision was specified.")
1089
internal_error = False
1092
class NoCommonAncestor(BzrError):
1094
_fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1096
def __init__(self, revision_a, revision_b):
1097
self.revision_a = revision_a
1098
self.revision_b = revision_b
1101
class NoCommonRoot(BzrError):
1103
_fmt = ("Revisions are not derived from the same root: "
1104
"%(revision_a)s %(revision_b)s.")
1106
def __init__(self, revision_a, revision_b):
1107
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
1110
class NotAncestor(BzrError):
1112
_fmt = "Revision %(rev_id)s is not an ancestor of %(not_ancestor_id)s"
1114
def __init__(self, rev_id, not_ancestor_id):
1115
BzrError.__init__(self, rev_id=rev_id,
1116
not_ancestor_id=not_ancestor_id)
1119
class InstallFailed(BzrError):
1121
def __init__(self, revisions):
1122
revision_str = ", ".join(str(r) for r in revisions)
1123
msg = "Could not install revisions:\n%s" % revision_str
1124
BzrError.__init__(self, msg)
1125
self.revisions = revisions
1128
class AmbiguousBase(BzrError):
1130
def __init__(self, bases):
1131
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
1133
msg = ("The correct base is unclear, because %s are all equally close"
1135
BzrError.__init__(self, msg)
1139
class NoCommits(BzrError):
1141
_fmt = "Branch %(branch)s has no commits."
1143
def __init__(self, branch):
1144
BzrError.__init__(self, branch=branch)
1147
class UnlistableStore(BzrError):
1149
def __init__(self, store):
1150
BzrError.__init__(self, "Store %s is not listable" % store)
1154
class UnlistableBranch(BzrError):
1156
def __init__(self, br):
1157
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
1160
class BoundBranchOutOfDate(BzrError):
1162
_fmt = ("Bound branch %(branch)s is out of date with master branch"
1165
def __init__(self, branch, master):
1166
BzrError.__init__(self)
1167
self.branch = branch
1168
self.master = master
1171
class CommitToDoubleBoundBranch(BzrError):
1173
_fmt = ("Cannot commit to branch %(branch)s."
1174
" It is bound to %(master)s, which is bound to %(remote)s.")
1176
def __init__(self, branch, master, remote):
1177
BzrError.__init__(self)
1178
self.branch = branch
1179
self.master = master
1180
self.remote = remote
1183
class OverwriteBoundBranch(BzrError):
1185
_fmt = "Cannot pull --overwrite to a branch which is bound %(branch)s"
1187
def __init__(self, branch):
1188
BzrError.__init__(self)
1189
self.branch = branch
1192
class BoundBranchConnectionFailure(BzrError):
1194
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1195
" => %(target)s: %(error)s")
1197
def __init__(self, branch, target, error):
1198
BzrError.__init__(self)
1199
self.branch = branch
1200
self.target = target
1204
class WeaveError(BzrError):
1206
_fmt = "Error in processing weave: %(message)s"
1208
def __init__(self, message=None):
1209
BzrError.__init__(self)
1210
self.message = message
1213
class WeaveRevisionAlreadyPresent(WeaveError):
1215
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1217
def __init__(self, revision_id, weave):
1219
WeaveError.__init__(self)
1220
self.revision_id = revision_id
1224
class WeaveRevisionNotPresent(WeaveError):
1226
_fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1228
def __init__(self, revision_id, weave):
1229
WeaveError.__init__(self)
1230
self.revision_id = revision_id
1234
class WeaveFormatError(WeaveError):
1236
_fmt = "Weave invariant violated: %(what)s"
1238
def __init__(self, what):
1239
WeaveError.__init__(self)
1243
class WeaveParentMismatch(WeaveError):
1245
_fmt = "Parents are mismatched between two revisions."
1248
class WeaveInvalidChecksum(WeaveError):
1250
_fmt = "Text did not match it's checksum: %(message)s"
1253
class WeaveTextDiffers(WeaveError):
1255
_fmt = ("Weaves differ on text content. Revision:"
1256
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1258
def __init__(self, revision_id, weave_a, weave_b):
1259
WeaveError.__init__(self)
1260
self.revision_id = revision_id
1261
self.weave_a = weave_a
1262
self.weave_b = weave_b
1265
class WeaveTextDiffers(WeaveError):
1267
_fmt = ("Weaves differ on text content. Revision:"
1268
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1270
def __init__(self, revision_id, weave_a, weave_b):
1271
WeaveError.__init__(self)
1272
self.revision_id = revision_id
1273
self.weave_a = weave_a
1274
self.weave_b = weave_b
1277
class VersionedFileError(BzrError):
1279
_fmt = "Versioned file error"
1282
class RevisionNotPresent(VersionedFileError):
1284
_fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1286
def __init__(self, revision_id, file_id):
1287
VersionedFileError.__init__(self)
1288
self.revision_id = revision_id
1289
self.file_id = file_id
1292
class RevisionAlreadyPresent(VersionedFileError):
1294
_fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1296
def __init__(self, revision_id, file_id):
1297
VersionedFileError.__init__(self)
1298
self.revision_id = revision_id
1299
self.file_id = file_id
1302
class VersionedFileInvalidChecksum(VersionedFileError):
1304
_fmt = "Text did not match its checksum: %(message)s"
1307
class KnitError(BzrError):
1311
internal_error = True
1314
class KnitCorrupt(KnitError):
1316
_fmt = "Knit %(filename)s corrupt: %(how)s"
1318
def __init__(self, filename, how):
1319
KnitError.__init__(self)
1320
self.filename = filename
1324
class KnitDataStreamIncompatible(KnitError):
1326
_fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
1328
def __init__(self, stream_format, target_format):
1329
self.stream_format = stream_format
1330
self.target_format = target_format
1333
class KnitHeaderError(KnitError):
1335
_fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
1337
def __init__(self, badline, filename):
1338
KnitError.__init__(self)
1339
self.badline = badline
1340
self.filename = filename
1342
class KnitIndexUnknownMethod(KnitError):
1343
"""Raised when we don't understand the storage method.
1345
Currently only 'fulltext' and 'line-delta' are supported.
1348
_fmt = ("Knit index %(filename)s does not have a known method"
1349
" in options: %(options)r")
1351
def __init__(self, filename, options):
1352
KnitError.__init__(self)
1353
self.filename = filename
1354
self.options = options
1357
class NoSuchExportFormat(BzrError):
1359
_fmt = "Export format %(format)r not supported"
1361
def __init__(self, format):
1362
BzrError.__init__(self)
1363
self.format = format
1366
class TransportError(BzrError):
1368
_fmt = "Transport error: %(msg)s %(orig_error)s"
1370
def __init__(self, msg=None, orig_error=None):
1371
if msg is None and orig_error is not None:
1372
msg = str(orig_error)
1373
if orig_error is None:
1378
self.orig_error = orig_error
1379
BzrError.__init__(self)
1382
class TooManyConcurrentRequests(BzrError):
1384
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1385
" Be sure to finish_writing and finish_reading on the"
1386
" currently open request.")
1388
internal_error = True
1390
def __init__(self, medium):
1391
self.medium = medium
1394
class SmartProtocolError(TransportError):
1396
_fmt = "Generic bzr smart protocol error: %(details)s"
1398
def __init__(self, details):
1399
self.details = details
1402
# A set of semi-meaningful errors which can be thrown
1403
class TransportNotPossible(TransportError):
1405
_fmt = "Transport operation not possible: %(msg)s %(orig_error)s"
1408
class ConnectionError(TransportError):
1410
_fmt = "Connection error: %(msg)s %(orig_error)s"
1413
class SocketConnectionError(ConnectionError):
1415
_fmt = "%(msg)s %(host)s%(port)s%(orig_error)s"
1417
def __init__(self, host, port=None, msg=None, orig_error=None):
1419
msg = 'Failed to connect to'
1420
if orig_error is None:
1423
orig_error = '; ' + str(orig_error)
1424
ConnectionError.__init__(self, msg=msg, orig_error=orig_error)
1429
self.port = ':%s' % port
1432
class ConnectionReset(TransportError):
1434
_fmt = "Connection closed: %(msg)s %(orig_error)s"
1437
class InvalidRange(TransportError):
1439
_fmt = "Invalid range access in %(path)s at %(offset)s."
1441
def __init__(self, path, offset):
1442
TransportError.__init__(self, ("Invalid range access in %s at %d"
1445
self.offset = offset
1448
class InvalidHttpResponse(TransportError):
1450
_fmt = "Invalid http response for %(path)s: %(msg)s"
1452
def __init__(self, path, msg, orig_error=None):
1454
TransportError.__init__(self, msg, orig_error=orig_error)
1457
class InvalidHttpRange(InvalidHttpResponse):
1459
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1461
def __init__(self, path, range, msg):
1463
InvalidHttpResponse.__init__(self, path, msg)
1466
class InvalidHttpContentType(InvalidHttpResponse):
1468
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1470
def __init__(self, path, ctype, msg):
1472
InvalidHttpResponse.__init__(self, path, msg)
1475
class RedirectRequested(TransportError):
1477
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1479
def __init__(self, source, target, is_permament=False, qual_proto=None):
1480
self.source = source
1481
self.target = target
1483
self.permanently = ' permanently'
1485
self.permanently = ''
1486
self.is_permament = is_permament
1487
self._qualified_proto = qual_proto
1488
TransportError.__init__(self)
1490
def _requalify_url(self, url):
1491
"""Restore the qualified proto in front of the url"""
1492
# When this exception is raised, source and target are in
1493
# user readable format. But some transports may use a
1494
# different proto (http+urllib:// will present http:// to
1495
# the user. If a qualified proto is specified, the code
1496
# trapping the exception can get the qualified urls to
1497
# properly handle the redirection themself (creating a
1498
# new transport object from the target url for example).
1499
# But checking that the scheme of the original and
1500
# redirected urls are the same can be tricky. (see the
1501
# FIXME in BzrDir.open_from_transport for the unique use
1503
if self._qualified_proto is None:
1506
# The TODO related to NotBranchError mention that doing
1507
# that kind of manipulation on the urls may not be the
1508
# exception object job. On the other hand, this object is
1509
# the interface between the code and the user so
1510
# presenting the urls in different ways is indeed its
1513
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1514
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1517
def get_source_url(self):
1518
return self._requalify_url(self.source)
1520
def get_target_url(self):
1521
return self._requalify_url(self.target)
1524
class TooManyRedirections(TransportError):
1526
_fmt = "Too many redirections"
1528
class ConflictsInTree(BzrError):
1530
_fmt = "Working tree has conflicts."
1533
class ParseConfigError(BzrError):
1535
def __init__(self, errors, filename):
1536
if filename is None:
1538
message = "Error(s) parsing config file %s:\n%s" % \
1539
(filename, ('\n'.join(e.message for e in errors)))
1540
BzrError.__init__(self, message)
1543
class NoEmailInUsername(BzrError):
1545
_fmt = "%(username)r does not seem to contain a reasonable email address"
1547
def __init__(self, username):
1548
BzrError.__init__(self)
1549
self.username = username
1552
class SigningFailed(BzrError):
1554
_fmt = 'Failed to gpg sign data with command "%(command_line)s"'
1556
def __init__(self, command_line):
1557
BzrError.__init__(self, command_line=command_line)
1560
class WorkingTreeNotRevision(BzrError):
1562
_fmt = ("The working tree for %(basedir)s has changed since"
1563
" the last commit, but weave merge requires that it be"
1566
def __init__(self, tree):
1567
BzrError.__init__(self, basedir=tree.basedir)
1570
class CantReprocessAndShowBase(BzrError):
1572
_fmt = ("Can't reprocess and show base, because reprocessing obscures "
1573
"the relationship of conflicting lines to the base")
1576
class GraphCycleError(BzrError):
1578
_fmt = "Cycle in graph %(graph)r"
1580
def __init__(self, graph):
1581
BzrError.__init__(self)
1585
class WritingCompleted(BzrError):
1587
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1588
"called upon it - accept bytes may not be called anymore.")
1590
internal_error = True
1592
def __init__(self, request):
1593
self.request = request
1596
class WritingNotComplete(BzrError):
1598
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1599
"called upon it - until the write phase is complete no "
1600
"data may be read.")
1602
internal_error = True
1604
def __init__(self, request):
1605
self.request = request
1608
class NotConflicted(BzrError):
1610
_fmt = "File %(filename)s is not conflicted."
1612
def __init__(self, filename):
1613
BzrError.__init__(self)
1614
self.filename = filename
1617
class MediumNotConnected(BzrError):
1619
_fmt = """The medium '%(medium)s' is not connected."""
1621
internal_error = True
1623
def __init__(self, medium):
1624
self.medium = medium
1627
class MustUseDecorated(Exception):
1629
_fmt = "A decorating function has requested its original command be used."
1632
class NoBundleFound(BzrError):
1634
_fmt = 'No bundle was found in "%(filename)s".'
1636
def __init__(self, filename):
1637
BzrError.__init__(self)
1638
self.filename = filename
1641
class BundleNotSupported(BzrError):
1643
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
1645
def __init__(self, version, msg):
1646
BzrError.__init__(self)
1647
self.version = version
1651
class MissingText(BzrError):
1653
_fmt = ("Branch %(base)s is missing revision"
1654
" %(text_revision)s of %(file_id)s")
1656
def __init__(self, branch, text_revision, file_id):
1657
BzrError.__init__(self)
1658
self.branch = branch
1659
self.base = branch.base
1660
self.text_revision = text_revision
1661
self.file_id = file_id
1664
class DuplicateFileId(BzrError):
1666
_fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1668
def __init__(self, file_id, entry):
1669
BzrError.__init__(self)
1670
self.file_id = file_id
1674
class DuplicateKey(BzrError):
1676
_fmt = "Key %(key)s is already present in map"
1679
class DuplicateHelpPrefix(BzrError):
1681
_fmt = "The prefix %(prefix)s is in the help search path twice."
1683
def __init__(self, prefix):
1684
self.prefix = prefix
1687
class MalformedTransform(BzrError):
1689
_fmt = "Tree transform is malformed %(conflicts)r"
1692
class NoFinalPath(BzrError):
1694
_fmt = ("No final name for trans_id %(trans_id)r\n"
1695
"file-id: %(file_id)r\n"
1696
"root trans-id: %(root_trans_id)r\n")
1698
def __init__(self, trans_id, transform):
1699
self.trans_id = trans_id
1700
self.file_id = transform.final_file_id(trans_id)
1701
self.root_trans_id = transform.root
1704
class BzrBadParameter(BzrError):
1706
_fmt = "Bad parameter: %(param)r"
1708
internal_error = True
1710
# This exception should never be thrown, but it is a base class for all
1711
# parameter-to-function errors.
1713
def __init__(self, param):
1714
BzrError.__init__(self)
1718
class BzrBadParameterNotUnicode(BzrBadParameter):
1720
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1723
class ReusingTransform(BzrError):
1725
_fmt = "Attempt to reuse a transform that has already been applied."
1728
class CantMoveRoot(BzrError):
1730
_fmt = "Moving the root directory is not supported at this time"
1733
class BzrMoveFailedError(BzrError):
1735
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1737
def __init__(self, from_path='', to_path='', extra=None):
1738
BzrError.__init__(self)
1740
self.extra = ': ' + str(extra)
1744
has_from = len(from_path) > 0
1745
has_to = len(to_path) > 0
1747
self.from_path = osutils.splitpath(from_path)[-1]
1752
self.to_path = osutils.splitpath(to_path)[-1]
1757
if has_from and has_to:
1758
self.operator = " =>"
1760
self.from_path = "from " + from_path
1762
self.operator = "to"
1764
self.operator = "file"
1767
class BzrRenameFailedError(BzrMoveFailedError):
1769
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1771
def __init__(self, from_path, to_path, extra=None):
1772
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1774
class BzrRemoveChangedFilesError(BzrError):
1775
"""Used when user is trying to remove changed files."""
1777
_fmt = ("Can't safely remove modified or unknown files:\n"
1778
"%(changes_as_text)s"
1779
"Use --keep to not delete them, or --force to delete them regardless.")
1781
def __init__(self, tree_delta):
1782
BzrError.__init__(self)
1783
self.changes_as_text = tree_delta.get_changes_as_text()
1784
#self.paths_as_string = '\n'.join(changed_files)
1785
#self.paths_as_string = '\n'.join([quotefn(p) for p in changed_files])
1788
class BzrBadParameterNotString(BzrBadParameter):
1790
_fmt = "Parameter %(param)s is not a string or unicode string."
1793
class BzrBadParameterMissing(BzrBadParameter):
1795
_fmt = "Parameter $(param)s is required but not present."
1798
class BzrBadParameterUnicode(BzrBadParameter):
1800
_fmt = ("Parameter %(param)s is unicode but"
1801
" only byte-strings are permitted.")
1804
class BzrBadParameterContainsNewline(BzrBadParameter):
1806
_fmt = "Parameter %(param)s contains a newline."
1809
class DependencyNotPresent(BzrError):
1811
_fmt = 'Unable to import library "%(library)s": %(error)s'
1813
def __init__(self, library, error):
1814
BzrError.__init__(self, library=library, error=error)
1817
class ParamikoNotPresent(DependencyNotPresent):
1819
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1821
def __init__(self, error):
1822
DependencyNotPresent.__init__(self, 'paramiko', error)
1825
class PointlessMerge(BzrError):
1827
_fmt = "Nothing to merge."
1830
class UninitializableFormat(BzrError):
1832
_fmt = "Format %(format)s cannot be initialised by this version of bzr."
1834
def __init__(self, format):
1835
BzrError.__init__(self)
1836
self.format = format
1839
class BadConversionTarget(BzrError):
1841
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1843
def __init__(self, problem, format):
1844
BzrError.__init__(self)
1845
self.problem = problem
1846
self.format = format
1849
class NoDiff(BzrError):
1851
_fmt = "Diff is not installed on this machine: %(msg)s"
1853
def __init__(self, msg):
1854
BzrError.__init__(self, msg=msg)
1857
class NoDiff3(BzrError):
1859
_fmt = "Diff3 is not installed on this machine."
1862
class ExistingContent(BzrError):
1863
# Added in bzrlib 0.92, used by VersionedFile.add_lines.
1865
_fmt = "The content being inserted is already present."
1868
class ExistingLimbo(BzrError):
1870
_fmt = """This tree contains left-over files from a failed operation.
1871
Please examine %(limbo_dir)s to see if it contains any files you wish to
1872
keep, and delete it when you are done."""
1874
def __init__(self, limbo_dir):
1875
BzrError.__init__(self)
1876
self.limbo_dir = limbo_dir
1879
class ExistingPendingDeletion(BzrError):
1881
_fmt = """This tree contains left-over files from a failed operation.
1882
Please examine %(pending_deletion)s to see if it contains any files you
1883
wish to keep, and delete it when you are done."""
1885
def __init__(self, pending_deletion):
1886
BzrError.__init__(self, pending_deletion=pending_deletion)
1889
class ImmortalLimbo(BzrError):
1891
_fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1892
Please examine %(limbo_dir)s to see if it contains any files you wish to
1893
keep, and delete it when you are done."""
1895
def __init__(self, limbo_dir):
1896
BzrError.__init__(self)
1897
self.limbo_dir = limbo_dir
1900
class ImmortalPendingDeletion(BzrError):
1902
_fmt = """Unable to delete transform temporary directory
1903
%(pending_deletion)s. Please examine %(pending_deletions)s to see if it
1904
contains any files you wish to keep, and delete it when you are done."""
1906
def __init__(self, pending_deletion):
1907
BzrError.__init__(self, pending_deletion=pending_deletion)
1910
class OutOfDateTree(BzrError):
1912
_fmt = "Working tree is out of date, please run 'bzr update'."
1914
def __init__(self, tree):
1915
BzrError.__init__(self)
1919
class PublicBranchOutOfDate(BzrError):
1921
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1924
def __init__(self, public_location, revstring):
1925
import bzrlib.urlutils as urlutils
1926
public_location = urlutils.unescape_for_display(public_location,
1928
BzrError.__init__(self, public_location=public_location,
1929
revstring=revstring)
1932
class MergeModifiedFormatError(BzrError):
1934
_fmt = "Error in merge modified format"
1937
class ConflictFormatError(BzrError):
1939
_fmt = "Format error in conflict listings"
1942
class CorruptRepository(BzrError):
1944
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1945
"Please run bzr reconcile on this repository.")
1947
def __init__(self, repo):
1948
BzrError.__init__(self)
1949
self.repo_path = repo.bzrdir.root_transport.base
1952
class UpgradeRequired(BzrError):
1954
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1956
def __init__(self, path):
1957
BzrError.__init__(self)
1961
class LocalRequiresBoundBranch(BzrError):
1963
_fmt = "Cannot perform local-only commits on unbound branches."
1966
class MissingProgressBarFinish(BzrError):
1968
_fmt = "A nested progress bar was not 'finished' correctly."
1971
class InvalidProgressBarType(BzrError):
1973
_fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
1974
" is not a supported type Select one of: %(valid_types)s")
1976
def __init__(self, bar_type, valid_types):
1977
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1980
class UnsupportedOperation(BzrError):
1982
_fmt = ("The method %(mname)s is not supported on"
1983
" objects of type %(tname)s.")
1985
def __init__(self, method, method_self):
1986
self.method = method
1987
self.mname = method.__name__
1988
self.tname = type(method_self).__name__
1991
class CannotSetRevisionId(UnsupportedOperation):
1992
"""Raised when a commit is attempting to set a revision id but cant."""
1995
class NonAsciiRevisionId(UnsupportedOperation):
1996
"""Raised when a commit is attempting to set a non-ascii revision id
2001
class BinaryFile(BzrError):
2003
_fmt = "File is binary but should be text."
2006
class IllegalPath(BzrError):
2008
_fmt = "The path %(path)s is not permitted on this platform"
2010
def __init__(self, path):
2011
BzrError.__init__(self)
2015
class TestamentMismatch(BzrError):
2017
_fmt = """Testament did not match expected value.
2018
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
2021
def __init__(self, revision_id, expected, measured):
2022
self.revision_id = revision_id
2023
self.expected = expected
2024
self.measured = measured
2027
class NotABundle(BzrError):
2029
_fmt = "Not a bzr revision-bundle: %(text)r"
2031
def __init__(self, text):
2032
BzrError.__init__(self)
2036
class BadBundle(BzrError):
2038
_fmt = "Bad bzr revision-bundle: %(text)r"
2040
def __init__(self, text):
2041
BzrError.__init__(self)
2045
class MalformedHeader(BadBundle):
2047
_fmt = "Malformed bzr revision-bundle header: %(text)r"
2050
class MalformedPatches(BadBundle):
2052
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
2055
class MalformedFooter(BadBundle):
2057
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
2060
class UnsupportedEOLMarker(BadBundle):
2062
_fmt = "End of line marker was not \\n in bzr revision-bundle"
2065
# XXX: BadBundle's constructor assumes there's explanatory text,
2066
# but for this there is not
2067
BzrError.__init__(self)
2070
class IncompatibleBundleFormat(BzrError):
2072
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
2074
def __init__(self, bundle_format, other):
2075
BzrError.__init__(self)
2076
self.bundle_format = bundle_format
2080
class BadInventoryFormat(BzrError):
2082
_fmt = "Root class for inventory serialization errors"
2085
class UnexpectedInventoryFormat(BadInventoryFormat):
2087
_fmt = "The inventory was not in the expected format:\n %(msg)s"
2089
def __init__(self, msg):
2090
BadInventoryFormat.__init__(self, msg=msg)
2093
class RootNotRich(BzrError):
2095
_fmt = """This operation requires rich root data storage"""
2098
class NoSmartMedium(BzrError):
2100
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
2102
internal_error = True
2104
def __init__(self, transport):
2105
self.transport = transport
2108
class NoSmartServer(NotBranchError):
2110
_fmt = "No smart server available at %(url)s"
2112
def __init__(self, url):
2116
class UnknownSSH(BzrError):
2118
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
2120
def __init__(self, vendor):
2121
BzrError.__init__(self)
2122
self.vendor = vendor
2125
class SSHVendorNotFound(BzrError):
2127
_fmt = ("Don't know how to handle SSH connections."
2128
" Please set BZR_SSH environment variable.")
2131
class GhostRevisionUnusableHere(BzrError):
2133
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2135
def __init__(self, revision_id):
2136
BzrError.__init__(self)
2137
self.revision_id = revision_id
2140
class IllegalUseOfScopeReplacer(BzrError):
2142
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2143
" %(msg)s%(extra)s")
2145
internal_error = True
2147
def __init__(self, name, msg, extra=None):
2148
BzrError.__init__(self)
2152
self.extra = ': ' + str(extra)
2157
class InvalidImportLine(BzrError):
2159
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
2161
internal_error = True
2163
def __init__(self, text, msg):
2164
BzrError.__init__(self)
2169
class ImportNameCollision(BzrError):
2171
_fmt = ("Tried to import an object to the same name as"
2172
" an existing object. %(name)s")
2174
internal_error = True
2176
def __init__(self, name):
2177
BzrError.__init__(self)
2181
class NotAMergeDirective(BzrError):
2182
"""File starting with %(firstline)r is not a merge directive"""
2183
def __init__(self, firstline):
2184
BzrError.__init__(self, firstline=firstline)
2187
class NoMergeSource(BzrError):
2188
"""Raise if no merge source was specified for a merge directive"""
2190
_fmt = "A merge directive must provide either a bundle or a public"\
2194
class IllegalMergeDirectivePayload(BzrError):
2195
"""A merge directive contained something other than a patch or bundle"""
2197
_fmt = "Bad merge directive payload %(start)r"
2199
def __init__(self, start):
2204
class PatchVerificationFailed(BzrError):
2205
"""A patch from a merge directive could not be verified"""
2207
_fmt = "Preview patch does not match requested changes."
2210
class PatchMissing(BzrError):
2211
"""Raise a patch type was specified but no patch supplied"""
2213
_fmt = "patch_type was %(patch_type)s, but no patch was supplied."
2215
def __init__(self, patch_type):
2216
BzrError.__init__(self)
2217
self.patch_type = patch_type
2220
class UnsupportedInventoryKind(BzrError):
2222
_fmt = """Unsupported entry kind %(kind)s"""
2224
def __init__(self, kind):
2228
class BadSubsumeSource(BzrError):
2230
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2232
def __init__(self, tree, other_tree, reason):
2234
self.other_tree = other_tree
2235
self.reason = reason
2238
class SubsumeTargetNeedsUpgrade(BzrError):
2240
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2242
def __init__(self, other_tree):
2243
self.other_tree = other_tree
2246
class BadReferenceTarget(BzrError):
2248
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2251
internal_error = True
2253
def __init__(self, tree, other_tree, reason):
2255
self.other_tree = other_tree
2256
self.reason = reason
2259
class NoSuchTag(BzrError):
2261
_fmt = "No such tag: %(tag_name)s"
2263
def __init__(self, tag_name):
2264
self.tag_name = tag_name
2267
class TagsNotSupported(BzrError):
2269
_fmt = ("Tags not supported by %(branch)s;"
2270
" you may be able to use bzr upgrade --dirstate-tags.")
2272
def __init__(self, branch):
2273
self.branch = branch
2276
class TagAlreadyExists(BzrError):
2278
_fmt = "Tag %(tag_name)s already exists."
2280
def __init__(self, tag_name):
2281
self.tag_name = tag_name
2284
class MalformedBugIdentifier(BzrError):
2286
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2288
def __init__(self, bug_id, reason):
2289
self.bug_id = bug_id
2290
self.reason = reason
2293
class UnknownBugTrackerAbbreviation(BzrError):
2295
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2298
def __init__(self, abbreviation, branch):
2299
self.abbreviation = abbreviation
2300
self.branch = branch
2303
class UnexpectedSmartServerResponse(BzrError):
2305
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2307
def __init__(self, response_tuple):
2308
self.response_tuple = response_tuple
2311
class ContainerError(BzrError):
2312
"""Base class of container errors."""
2315
class UnknownContainerFormatError(ContainerError):
2317
_fmt = "Unrecognised container format: %(container_format)r"
2319
def __init__(self, container_format):
2320
self.container_format = container_format
2323
class UnexpectedEndOfContainerError(ContainerError):
2325
_fmt = "Unexpected end of container stream"
2327
internal_error = False
2330
class UnknownRecordTypeError(ContainerError):
2332
_fmt = "Unknown record type: %(record_type)r"
2334
def __init__(self, record_type):
2335
self.record_type = record_type
2338
class InvalidRecordError(ContainerError):
2340
_fmt = "Invalid record: %(reason)s"
2342
def __init__(self, reason):
2343
self.reason = reason
2346
class ContainerHasExcessDataError(ContainerError):
2348
_fmt = "Container has data after end marker: %(excess)r"
2350
def __init__(self, excess):
2351
self.excess = excess
2354
class DuplicateRecordNameError(ContainerError):
2356
_fmt = "Container has multiple records with the same name: %(name)s"
2358
def __init__(self, name):
2362
class NoDestinationAddress(BzrError):
2364
_fmt = "Message does not have a destination address."
2366
internal_error = True
2369
class SMTPError(BzrError):
2371
_fmt = "SMTP error: %(error)s"
2373
def __init__(self, error):
2377
class NoMessageSupplied(BzrError):
2379
_fmt = "No message supplied."
2382
class UnknownMailClient(BzrError):
2384
_fmt = "Unknown mail client: %(mail_client)s"
2386
def __init__(self, mail_client):
2387
BzrError.__init__(self, mail_client=mail_client)
2390
class MailClientNotFound(BzrError):
2392
_fmt = "Unable to find mail client with the following names:"\
2393
" %(mail_command_list_string)s"
2395
def __init__(self, mail_command_list):
2396
mail_command_list_string = ', '.join(mail_command_list)
2397
BzrError.__init__(self, mail_command_list=mail_command_list,
2398
mail_command_list_string=mail_command_list_string)
2400
class SMTPConnectionRefused(SMTPError):
2402
_fmt = "SMTP connection to %(host)s refused"
2404
def __init__(self, error, host):
2409
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2411
_fmt = "Please specify smtp_server. No server at default %(host)s."
2414
class BzrDirError(BzrError):
2416
def __init__(self, bzrdir):
2417
import bzrlib.urlutils as urlutils
2418
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2420
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2423
class AlreadyBranch(BzrDirError):
2425
_fmt = "'%(display_url)s' is already a branch."
2428
class AlreadyTree(BzrDirError):
2430
_fmt = "'%(display_url)s' is already a tree."
2433
class AlreadyCheckout(BzrDirError):
2435
_fmt = "'%(display_url)s' is already a checkout."
2438
class ReconfigurationNotSupported(BzrDirError):
2440
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2443
class NoBindLocation(BzrDirError):
2445
_fmt = "No location could be found to bind to at %(display_url)s."
2448
class UncommittedChanges(BzrError):
2450
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2452
def __init__(self, tree):
2453
import bzrlib.urlutils as urlutils
2454
display_url = urlutils.unescape_for_display(
2455
tree.bzrdir.root_transport.base, 'ascii')
2456
BzrError.__init__(self, tree=tree, display_url=display_url)