1
# Copyright (C) 2005-2013, 2016 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Exceptions for bzr, and reporting of them.
20
from __future__ import absolute_import
23
# TODO: is there any value in providing the .args field used by standard
24
# python exceptions? A list of values with no names seems less useful
27
# TODO: Perhaps convert the exception to a string at the moment it's
28
# constructed to make sure it will succeed. But that says nothing about
29
# exceptions that are never raised.
31
# TODO: selftest assertRaises should probably also check that every error
32
# raised can be formatted as a string successfully, and without giving
36
# return codes from the brz program
39
EXIT_INTERNAL_ERROR = 4
42
class BzrError(Exception):
44
Base class for errors raised by breezy.
46
:cvar internal_error: if True this was probably caused by a brz bug and
47
should be displayed with a traceback; if False (or absent) this was
48
probably a user or environment error and they don't need the gory
49
details. (That can be overridden by -Derror on the command line.)
51
:cvar _fmt: Format string to display the error; this is expanded
52
by the instance's dict.
55
internal_error = False
57
def __init__(self, msg=None, **kwds):
58
"""Construct a new BzrError.
60
There are two alternative forms for constructing these objects.
61
Either a preformatted string may be passed, or a set of named
62
arguments can be given. The first is for generic "user" errors which
63
are not intended to be caught and so do not need a specific subclass.
64
The second case is for use with subclasses that provide a _fmt format
65
string to print the arguments.
67
Keyword arguments are taken as parameters to the error, which can
68
be inserted into the format string template. It's recommended
69
that subclasses override the __init__ method to require specific
72
:param msg: If given, this is the literal complete text for the error,
73
not subject to expansion. 'msg' is used instead of 'message' because
74
python evolved and, in 2.6, forbids the use of 'message'.
76
Exception.__init__(self)
78
# I was going to deprecate this, but it actually turns out to be
79
# quite handy - mbp 20061103.
80
self._preformatted_string = msg
82
self._preformatted_string = None
83
for key, value in kwds.items():
84
setattr(self, key, value)
87
s = getattr(self, '_preformatted_string', None)
89
# contains a preformatted message
93
fmt = self._get_format_string()
95
d = dict(self.__dict__)
97
# __str__() should always return a 'str' object
98
# never a 'unicode' object.
100
except Exception as e:
102
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
103
% (self.__class__.__name__,
105
getattr(self, '_fmt', None),
111
return '%s(%s)' % (self.__class__.__name__, str(self))
113
def _get_format_string(self):
114
"""Return format string for this exception or None"""
115
fmt = getattr(self, '_fmt', None)
117
from breezy.i18n import gettext
118
return gettext(fmt) # _fmt strings should be ascii
120
def __eq__(self, other):
121
if self.__class__ is not other.__class__:
122
return NotImplemented
123
return self.__dict__ == other.__dict__
129
class InternalBzrError(BzrError):
130
"""Base class for errors that are internal in nature.
132
This is a convenience class for errors that are internal. The
133
internal_error attribute can still be altered in subclasses, if needed.
134
Using this class is simply an easy way to get internal errors.
137
internal_error = True
140
class BranchError(BzrError):
141
"""Base class for concrete 'errors about a branch'."""
143
def __init__(self, branch):
144
BzrError.__init__(self, branch=branch)
147
class BzrCheckError(InternalBzrError):
149
_fmt = "Internal check failed: %(msg)s"
151
def __init__(self, msg):
152
BzrError.__init__(self)
156
class IncompatibleVersion(BzrError):
158
_fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\
159
'is required, but current version is %(current)r.'
161
def __init__(self, api, wanted, current):
164
self.current = current
167
class InProcessTransport(BzrError):
169
_fmt = "The transport '%(transport)s' is only accessible within this " \
172
def __init__(self, transport):
173
self.transport = transport
176
class InvalidRevisionNumber(BzrError):
178
_fmt = "Invalid revision number %(revno)s"
180
def __init__(self, revno):
181
BzrError.__init__(self)
185
class InvalidRevisionId(BzrError):
187
_fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
189
def __init__(self, revision_id, branch):
190
# branch can be any string or object with __str__ defined
191
BzrError.__init__(self)
192
self.revision_id = revision_id
196
class ReservedId(BzrError):
198
_fmt = "Reserved revision-id {%(revision_id)s}"
200
def __init__(self, revision_id):
201
self.revision_id = revision_id
204
class RootMissing(InternalBzrError):
206
_fmt = ("The root entry of a tree must be the first entry supplied to "
207
"the commit builder.")
210
class NoPublicBranch(BzrError):
212
_fmt = 'There is no public branch set for "%(branch_url)s".'
214
def __init__(self, branch):
215
from . import urlutils
216
public_location = urlutils.unescape_for_display(branch.base, 'ascii')
217
BzrError.__init__(self, branch_url=public_location)
220
class NoSuchId(BzrError):
222
_fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
224
def __init__(self, tree, file_id):
225
BzrError.__init__(self)
226
self.file_id = file_id
230
class NotStacked(BranchError):
232
_fmt = "The branch '%(branch)s' is not stacked."
235
class InventoryModified(InternalBzrError):
237
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
238
" so a clean inventory cannot be read without data loss.")
240
def __init__(self, tree):
244
class NoWorkingTree(BzrError):
246
_fmt = 'No WorkingTree exists for "%(base)s".'
248
def __init__(self, base):
249
BzrError.__init__(self)
253
class NotLocalUrl(BzrError):
255
_fmt = "%(url)s is not a local path."
257
def __init__(self, url):
261
class WorkingTreeAlreadyPopulated(InternalBzrError):
263
_fmt = 'Working tree already populated in "%(base)s"'
265
def __init__(self, base):
269
class NoWhoami(BzrError):
271
_fmt = ('Unable to determine your name.\n'
272
"Please, set your name with the 'whoami' command.\n"
273
'E.g. brz whoami "Your Name <name@example.com>"')
276
class BzrCommandError(BzrError):
277
"""Error from user command"""
279
# Error from malformed user command; please avoid raising this as a
280
# generic exception not caused by user input.
282
# I think it's a waste of effort to differentiate between errors that
283
# are not intended to be caught anyway. UI code need not subclass
284
# BzrCommandError, and non-UI code should not throw a subclass of
285
# BzrCommandError. ADHB 20051211
288
class NotWriteLocked(BzrError):
290
_fmt = """%(not_locked)r is not write locked but needs to be."""
292
def __init__(self, not_locked):
293
self.not_locked = not_locked
296
class StrictCommitFailed(BzrError):
298
_fmt = "Commit refused because there are unknown files in the tree"
301
# XXX: Should be unified with TransportError; they seem to represent the
303
# RBC 20060929: I think that unifiying with TransportError would be a mistake
304
# - this is finer than a TransportError - and more useful as such. It
305
# differentiates between 'transport has failed' and 'operation on a transport
307
class PathError(BzrError):
309
_fmt = "Generic path error: %(path)r%(extra)s)"
311
def __init__(self, path, extra=None):
312
BzrError.__init__(self)
315
self.extra = ': ' + str(extra)
320
class NoSuchFile(PathError):
322
_fmt = "No such file: %(path)r%(extra)s"
325
class FileExists(PathError):
327
_fmt = "File exists: %(path)r%(extra)s"
330
class RenameFailedFilesExist(BzrError):
331
"""Used when renaming and both source and dest exist."""
333
_fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
334
" (Use --after to tell brz about a rename that has already"
335
" happened)%(extra)s")
337
def __init__(self, source, dest, extra=None):
338
BzrError.__init__(self)
339
self.source = str(source)
340
self.dest = str(dest)
342
self.extra = ' ' + str(extra)
347
class NotADirectory(PathError):
349
_fmt = '"%(path)s" is not a directory %(extra)s'
352
class NotInWorkingDirectory(PathError):
354
_fmt = '"%(path)s" is not in the working directory %(extra)s'
357
class DirectoryNotEmpty(PathError):
359
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
362
class HardLinkNotSupported(PathError):
364
_fmt = 'Hard-linking "%(path)s" is not supported'
367
class ReadingCompleted(InternalBzrError):
369
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
370
"called upon it - the request has been completed and no more "
373
def __init__(self, request):
374
self.request = request
377
class ResourceBusy(PathError):
379
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
382
class PermissionDenied(PathError):
384
_fmt = 'Permission denied: "%(path)s"%(extra)s'
387
class UnavailableRepresentation(InternalBzrError):
389
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
390
"is encoded as '%(native)s'.")
392
def __init__(self, key, wanted, native):
393
InternalBzrError.__init__(self)
399
class UnsupportedProtocol(PathError):
401
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
403
def __init__(self, url, extra=""):
404
PathError.__init__(self, url, extra=extra)
407
class UnstackableLocationError(BzrError):
409
_fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
411
def __init__(self, branch_url, target_url):
412
BzrError.__init__(self)
413
self.branch_url = branch_url
414
self.target_url = target_url
417
class UnstackableRepositoryFormat(BzrError):
419
_fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
420
"You will need to upgrade the repository to permit branch stacking.")
422
def __init__(self, format, url):
423
BzrError.__init__(self)
428
class ReadError(PathError):
430
_fmt = """Error reading from %(path)r."""
433
class ShortReadvError(PathError):
435
_fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
436
' at %(offset)s for "%(path)s"%(extra)s')
438
internal_error = True
440
def __init__(self, path, offset, length, actual, extra=None):
441
PathError.__init__(self, path, extra=extra)
447
class PathNotChild(PathError):
449
_fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
451
internal_error = False
453
def __init__(self, path, base, extra=None):
454
BzrError.__init__(self)
458
self.extra = ': ' + str(extra)
463
class InvalidNormalization(PathError):
465
_fmt = 'Path "%(path)s" is not unicode normalized'
468
# TODO: This is given a URL; we try to unescape it but doing that from inside
469
# the exception object is a bit undesirable.
470
# TODO: Probably this behavior of should be a common superclass
471
class NotBranchError(PathError):
473
_fmt = 'Not a branch: "%(path)s"%(detail)s.'
475
def __init__(self, path, detail=None, controldir=None):
476
from . import urlutils
477
path = urlutils.unescape_for_display(path, 'ascii')
478
if detail is not None:
479
detail = ': ' + detail
481
self.controldir = controldir
482
PathError.__init__(self, path=path)
485
return '<%s %r>' % (self.__class__.__name__, self.__dict__)
487
def _get_format_string(self):
488
# GZ 2017-06-08: Not the best place to lazy fill detail in.
489
if self.detail is None:
490
self.detail = self._get_detail()
491
return super(NotBranchError, self)._get_format_string()
493
def _get_detail(self):
494
if self.controldir is not None:
496
self.controldir.open_repository()
497
except NoRepositoryPresent:
499
except Exception as e:
500
# Just ignore unexpected errors. Raising arbitrary errors
501
# during str(err) can provoke strange bugs. Concretely
502
# Launchpad's codehosting managed to raise NotBranchError
503
# here, and then get stuck in an infinite loop/recursion
504
# trying to str() that error. All this error really cares
505
# about that there's no working repository there, and if
506
# open_repository() fails, there probably isn't.
507
return ': ' + e.__class__.__name__
509
return ': location is a repository'
513
class NoSubmitBranch(PathError):
515
_fmt = 'No submit branch available for branch "%(path)s"'
517
def __init__(self, branch):
518
from . import urlutils
519
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
522
class AlreadyControlDirError(PathError):
524
_fmt = 'A control directory already exists: "%(path)s".'
527
class AlreadyBranchError(PathError):
529
_fmt = 'Already a branch: "%(path)s".'
532
class InvalidBranchName(PathError):
534
_fmt = "Invalid branch name: %(name)s"
536
def __init__(self, name):
537
BzrError.__init__(self)
541
class ParentBranchExists(AlreadyBranchError):
543
_fmt = 'Parent branch already exists: "%(path)s".'
546
class BranchExistsWithoutWorkingTree(PathError):
548
_fmt = 'Directory contains a branch, but no working tree \
549
(use brz checkout if you wish to build a working tree): "%(path)s"'
552
class InaccessibleParent(PathError):
554
_fmt = ('Parent not accessible given base "%(base)s" and'
555
' relative path "%(path)s"')
557
def __init__(self, path, base):
558
PathError.__init__(self, path)
562
class NoRepositoryPresent(BzrError):
564
_fmt = 'No repository present: "%(path)s"'
566
def __init__(self, controldir):
567
BzrError.__init__(self)
568
self.path = controldir.transport.clone('..').base
571
class UnsupportedFormatError(BzrError):
573
_fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
576
class UnknownFormatError(BzrError):
578
_fmt = "Unknown %(kind)s format: %(format)r"
580
def __init__(self, format, kind='branch'):
585
class LineEndingError(BzrError):
587
_fmt = ("Line ending corrupted for file: %(file)s; "
588
"Maybe your files got corrupted in transport?")
590
def __init__(self, file):
594
class IncompatibleFormat(BzrError):
596
_fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
598
def __init__(self, format, controldir_format):
599
BzrError.__init__(self)
601
self.controldir = controldir_format
604
class ParseFormatError(BzrError):
606
_fmt = "Parse error on line %(lineno)d of %(format)s format: %(line)s"
608
def __init__(self, format, lineno, line, text):
609
BzrError.__init__(self)
616
class IncompatibleRepositories(BzrError):
617
"""Report an error that two repositories are not compatible.
619
Note that the source and target repositories are permitted to be strings:
620
this exception is thrown from the smart server and may refer to a
621
repository the client hasn't opened.
624
_fmt = "%(target)s\n" \
625
"is not compatible with\n" \
629
def __init__(self, source, target, details=None):
631
details = "(no details)"
632
BzrError.__init__(self, target=target, source=source, details=details)
635
class IncompatibleRevision(BzrError):
637
_fmt = "Revision is not compatible with %(repo_format)s"
639
def __init__(self, repo_format):
640
BzrError.__init__(self)
641
self.repo_format = repo_format
644
class AlreadyVersionedError(BzrError):
645
"""Used when a path is expected not to be versioned, but it is."""
647
_fmt = "%(context_info)s%(path)s is already versioned."
649
def __init__(self, path, context_info=None):
650
"""Construct a new AlreadyVersionedError.
652
:param path: This is the path which is versioned,
653
which should be in a user friendly form.
654
:param context_info: If given, this is information about the context,
655
which could explain why this is expected to not be versioned.
657
BzrError.__init__(self)
659
if context_info is None:
660
self.context_info = ''
662
self.context_info = context_info + ". "
665
class NotVersionedError(BzrError):
666
"""Used when a path is expected to be versioned, but it is not."""
668
_fmt = "%(context_info)s%(path)s is not versioned."
670
def __init__(self, path, context_info=None):
671
"""Construct a new NotVersionedError.
673
:param path: This is the path which is not versioned,
674
which should be in a user friendly form.
675
:param context_info: If given, this is information about the context,
676
which could explain why this is expected to be versioned.
678
BzrError.__init__(self)
680
if context_info is None:
681
self.context_info = ''
683
self.context_info = context_info + ". "
686
class PathsNotVersionedError(BzrError):
687
"""Used when reporting several paths which are not versioned"""
689
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
691
def __init__(self, paths):
692
from breezy.osutils import quotefn
693
BzrError.__init__(self)
695
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
698
class PathsDoNotExist(BzrError):
700
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
702
# used when reporting that paths are neither versioned nor in the working
705
def __init__(self, paths, extra=None):
707
from breezy.osutils import quotefn
708
BzrError.__init__(self)
710
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
712
self.extra = ': ' + str(extra)
717
class BadFileKindError(BzrError):
719
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
721
def __init__(self, filename, kind):
722
BzrError.__init__(self, filename=filename, kind=kind)
725
class BadFilenameEncoding(BzrError):
727
_fmt = ('Filename %(filename)r is not valid in your current filesystem'
728
' encoding %(fs_encoding)s')
730
def __init__(self, filename, fs_encoding):
731
BzrError.__init__(self)
732
self.filename = filename
733
self.fs_encoding = fs_encoding
736
class ForbiddenControlFileError(BzrError):
738
_fmt = 'Cannot operate on "%(filename)s" because it is a control file'
741
class LockError(InternalBzrError):
743
_fmt = "Lock error: %(msg)s"
745
# All exceptions from the lock/unlock functions should be from
746
# this exception class. They will be translated as necessary. The
747
# original exception is available as e.original_error
749
# New code should prefer to raise specific subclasses
750
def __init__(self, msg):
754
class LockActive(LockError):
756
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
758
internal_error = False
760
def __init__(self, lock_description):
761
self.lock_description = lock_description
764
class CommitNotPossible(LockError):
766
_fmt = "A commit was attempted but we do not have a write lock open."
772
class AlreadyCommitted(LockError):
774
_fmt = "A rollback was requested, but is not able to be accomplished."
780
class ReadOnlyError(LockError):
782
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
784
# TODO: There should also be an error indicating that you need a write
785
# lock and don't have any lock at all... mbp 20070226
787
def __init__(self, obj):
791
class LockFailed(LockError):
793
internal_error = False
795
_fmt = "Cannot lock %(lock)s: %(why)s"
797
def __init__(self, lock, why):
798
LockError.__init__(self, '')
803
class OutSideTransaction(BzrError):
805
_fmt = ("A transaction related operation was attempted after"
806
" the transaction finished.")
809
class ObjectNotLocked(LockError):
811
_fmt = "%(obj)r is not locked"
813
# this can indicate that any particular object is not locked; see also
814
# LockNotHeld which means that a particular *lock* object is not held by
815
# the caller -- perhaps they should be unified.
816
def __init__(self, obj):
820
class ReadOnlyObjectDirtiedError(ReadOnlyError):
822
_fmt = "Cannot change object %(obj)r in read only transaction"
824
def __init__(self, obj):
828
class UnlockableTransport(LockError):
830
internal_error = False
832
_fmt = "Cannot lock: transport is read only: %(transport)s"
834
def __init__(self, transport):
835
self.transport = transport
838
class LockContention(LockError):
840
_fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
842
internal_error = False
844
def __init__(self, lock, msg=''):
849
class LockBroken(LockError):
851
_fmt = ("Lock was broken while still open: %(lock)s"
852
" - check storage consistency!")
854
internal_error = False
856
def __init__(self, lock):
860
class LockBreakMismatch(LockError):
862
_fmt = ("Lock was released and re-acquired before being broken:"
863
" %(lock)s: held by %(holder)r, wanted to break %(target)r")
865
internal_error = False
867
def __init__(self, lock, holder, target):
873
class LockCorrupt(LockError):
875
_fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
876
"Use 'brz break-lock' to clear it")
878
internal_error = False
880
def __init__(self, corruption_info, file_data=None):
881
self.corruption_info = corruption_info
882
self.file_data = file_data
885
class LockNotHeld(LockError):
887
_fmt = "Lock not held: %(lock)s"
889
internal_error = False
891
def __init__(self, lock):
895
class TokenLockingNotSupported(LockError):
897
_fmt = "The object %(obj)s does not support token specifying a token when locking."
899
def __init__(self, obj):
903
class TokenMismatch(LockBroken):
905
_fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
907
internal_error = True
909
def __init__(self, given_token, lock_token):
910
self.given_token = given_token
911
self.lock_token = lock_token
914
class UpgradeReadonly(BzrError):
916
_fmt = "Upgrade URL cannot work with readonly URLs."
919
class UpToDateFormat(BzrError):
921
_fmt = "The branch format %(format)s is already at the most recent format."
923
def __init__(self, format):
924
BzrError.__init__(self)
928
class NoSuchRevision(InternalBzrError):
930
_fmt = "%(branch)s has no revision %(revision)s"
932
def __init__(self, branch, revision):
933
# 'branch' may sometimes be an internal object like a KnitRevisionStore
934
BzrError.__init__(self, branch=branch, revision=revision)
937
class RangeInChangeOption(BzrError):
939
_fmt = "Option --change does not accept revision ranges"
942
class NoSuchRevisionSpec(BzrError):
944
_fmt = "No namespace registered for string: %(spec)r"
946
def __init__(self, spec):
947
BzrError.__init__(self, spec=spec)
950
class NoSuchRevisionInTree(NoSuchRevision):
951
"""When using Tree.revision_tree, and the revision is not accessible."""
953
_fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
955
def __init__(self, tree, revision_id):
956
BzrError.__init__(self)
958
self.revision_id = revision_id
961
class InvalidRevisionSpec(BzrError):
963
_fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
964
" %(branch_url)s%(extra)s")
966
def __init__(self, spec, branch, extra=None):
967
BzrError.__init__(self, branch=branch, spec=spec)
968
self.branch_url = getattr(branch, 'user_url', str(branch))
970
self.extra = '\n' + str(extra)
975
class AppendRevisionsOnlyViolation(BzrError):
977
_fmt = ('Operation denied because it would change the main history,'
978
' which is not permitted by the append_revisions_only setting on'
979
' branch "%(location)s".')
981
def __init__(self, location):
982
import breezy.urlutils as urlutils
983
location = urlutils.unescape_for_display(location, 'ascii')
984
BzrError.__init__(self, location=location)
987
class DivergedBranches(BzrError):
989
_fmt = ("These branches have diverged."
990
" Use the missing command to see how.\n"
991
"Use the merge command to reconcile them.")
993
def __init__(self, branch1, branch2):
994
self.branch1 = branch1
995
self.branch2 = branch2
998
class NotLefthandHistory(InternalBzrError):
1000
_fmt = "Supplied history does not follow left-hand parents"
1002
def __init__(self, history):
1003
BzrError.__init__(self, history=history)
1006
class UnrelatedBranches(BzrError):
1008
_fmt = ("Branches have no common ancestor, and"
1009
" no merge base revision was specified.")
1012
class CannotReverseCherrypick(BzrError):
1014
_fmt = ('Selected merge cannot perform reverse cherrypicks. Try merge3'
1018
class NoCommonAncestor(BzrError):
1020
_fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1022
def __init__(self, revision_a, revision_b):
1023
self.revision_a = revision_a
1024
self.revision_b = revision_b
1027
class NoCommonRoot(BzrError):
1029
_fmt = ("Revisions are not derived from the same root: "
1030
"%(revision_a)s %(revision_b)s.")
1032
def __init__(self, revision_a, revision_b):
1033
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
1036
class NotAncestor(BzrError):
1038
_fmt = "Revision %(rev_id)s is not an ancestor of %(not_ancestor_id)s"
1040
def __init__(self, rev_id, not_ancestor_id):
1041
BzrError.__init__(self, rev_id=rev_id,
1042
not_ancestor_id=not_ancestor_id)
1045
class NoCommits(BranchError):
1047
_fmt = "Branch %(branch)s has no commits."
1050
class UnlistableStore(BzrError):
1052
def __init__(self, store):
1053
BzrError.__init__(self, "Store %s is not listable" % store)
1056
class UnlistableBranch(BzrError):
1058
def __init__(self, br):
1059
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
1062
class BoundBranchOutOfDate(BzrError):
1064
_fmt = ("Bound branch %(branch)s is out of date with master branch"
1065
" %(master)s.%(extra_help)s")
1067
def __init__(self, branch, master):
1068
BzrError.__init__(self)
1069
self.branch = branch
1070
self.master = master
1071
self.extra_help = ''
1074
class CommitToDoubleBoundBranch(BzrError):
1076
_fmt = ("Cannot commit to branch %(branch)s."
1077
" It is bound to %(master)s, which is bound to %(remote)s.")
1079
def __init__(self, branch, master, remote):
1080
BzrError.__init__(self)
1081
self.branch = branch
1082
self.master = master
1083
self.remote = remote
1086
class OverwriteBoundBranch(BzrError):
1088
_fmt = "Cannot pull --overwrite to a branch which is bound %(branch)s"
1090
def __init__(self, branch):
1091
BzrError.__init__(self)
1092
self.branch = branch
1095
class BoundBranchConnectionFailure(BzrError):
1097
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1098
" => %(target)s: %(error)s")
1100
def __init__(self, branch, target, error):
1101
BzrError.__init__(self)
1102
self.branch = branch
1103
self.target = target
1107
class VersionedFileError(BzrError):
1109
_fmt = "Versioned file error"
1112
class RevisionNotPresent(VersionedFileError):
1114
_fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1116
def __init__(self, revision_id, file_id):
1117
VersionedFileError.__init__(self)
1118
self.revision_id = revision_id
1119
self.file_id = file_id
1122
class RevisionAlreadyPresent(VersionedFileError):
1124
_fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1126
def __init__(self, revision_id, file_id):
1127
VersionedFileError.__init__(self)
1128
self.revision_id = revision_id
1129
self.file_id = file_id
1132
class VersionedFileInvalidChecksum(VersionedFileError):
1134
_fmt = "Text did not match its checksum: %(msg)s"
1137
class RetryWithNewPacks(BzrError):
1138
"""Raised when we realize that the packs on disk have changed.
1140
This is meant as more of a signaling exception, to trap between where a
1141
local error occurred and the code that can actually handle the error and
1142
code that can retry appropriately.
1145
internal_error = True
1147
_fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1150
def __init__(self, context, reload_occurred, exc_info):
1151
"""create a new RetryWithNewPacks error.
1153
:param reload_occurred: Set to True if we know that the packs have
1154
already been reloaded, and we are failing because of an in-memory
1155
cache miss. If set to True then we will ignore if a reload says
1156
nothing has changed, because we assume it has already reloaded. If
1157
False, then a reload with nothing changed will force an error.
1158
:param exc_info: The original exception traceback, so if there is a
1159
problem we can raise the original error (value from sys.exc_info())
1161
BzrError.__init__(self)
1162
self.context = context
1163
self.reload_occurred = reload_occurred
1164
self.exc_info = exc_info
1165
self.orig_error = exc_info[1]
1166
# TODO: The global error handler should probably treat this by
1167
# raising/printing the original exception with a bit about
1168
# RetryWithNewPacks also not being caught
1171
class RetryAutopack(RetryWithNewPacks):
1172
"""Raised when we are autopacking and we find a missing file.
1174
Meant as a signaling exception, to tell the autopack code it should try
1178
internal_error = True
1180
_fmt = ("Pack files have changed, reload and try autopack again."
1181
" context: %(context)s %(orig_error)s")
1184
class NoSuchExportFormat(BzrError):
1186
_fmt = "Export format %(format)r not supported"
1188
def __init__(self, format):
1189
BzrError.__init__(self)
1190
self.format = format
1193
class TransportError(BzrError):
1195
_fmt = "Transport error: %(msg)s %(orig_error)s"
1197
def __init__(self, msg=None, orig_error=None):
1198
if msg is None and orig_error is not None:
1199
msg = str(orig_error)
1200
if orig_error is None:
1205
self.orig_error = orig_error
1206
BzrError.__init__(self)
1209
class TooManyConcurrentRequests(InternalBzrError):
1211
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1212
" Be sure to finish_writing and finish_reading on the"
1213
" currently open request.")
1215
def __init__(self, medium):
1216
self.medium = medium
1219
class SmartProtocolError(TransportError):
1221
_fmt = "Generic bzr smart protocol error: %(details)s"
1223
def __init__(self, details):
1224
self.details = details
1227
class UnexpectedProtocolVersionMarker(TransportError):
1229
_fmt = "Received bad protocol version marker: %(marker)r"
1231
def __init__(self, marker):
1232
self.marker = marker
1235
class UnknownSmartMethod(InternalBzrError):
1237
_fmt = "The server does not recognise the '%(verb)s' request."
1239
def __init__(self, verb):
1243
class SmartMessageHandlerError(InternalBzrError):
1245
_fmt = ("The message handler raised an exception:\n"
1246
"%(traceback_text)s")
1248
def __init__(self, exc_info):
1250
# GZ 2010-08-10: Cycle with exc_tb/exc_info affects at least one test
1251
self.exc_type, self.exc_value, self.exc_tb = exc_info
1252
self.exc_info = exc_info
1253
traceback_strings = traceback.format_exception(
1254
self.exc_type, self.exc_value, self.exc_tb)
1255
self.traceback_text = ''.join(traceback_strings)
1258
# A set of semi-meaningful errors which can be thrown
1259
class TransportNotPossible(TransportError):
1261
_fmt = "Transport operation not possible: %(msg)s %(orig_error)s"
1264
class ConnectionError(TransportError):
1266
_fmt = "Connection error: %(msg)s %(orig_error)s"
1269
class SocketConnectionError(ConnectionError):
1271
_fmt = "%(msg)s %(host)s%(port)s%(orig_error)s"
1273
def __init__(self, host, port=None, msg=None, orig_error=None):
1275
msg = 'Failed to connect to'
1276
if orig_error is None:
1279
orig_error = '; ' + str(orig_error)
1280
ConnectionError.__init__(self, msg=msg, orig_error=orig_error)
1285
self.port = ':%s' % port
1288
# XXX: This is also used for unexpected end of file, which is different at the
1289
# TCP level from "connection reset".
1290
class ConnectionReset(TransportError):
1292
_fmt = "Connection closed: %(msg)s %(orig_error)s"
1295
class ConnectionTimeout(ConnectionError):
1297
_fmt = "Connection Timeout: %(msg)s%(orig_error)s"
1300
class InvalidRange(TransportError):
1302
_fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1304
def __init__(self, path, offset, msg=None):
1305
TransportError.__init__(self, msg)
1307
self.offset = offset
1310
class InvalidHttpResponse(TransportError):
1312
_fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1314
def __init__(self, path, msg, orig_error=None):
1316
if orig_error is None:
1319
# This is reached for obscure and unusual errors so we want to
1320
# preserve as much info as possible to ease debug.
1321
orig_error = ': %r' % (orig_error,)
1322
TransportError.__init__(self, msg, orig_error=orig_error)
1325
class InvalidHttpRange(InvalidHttpResponse):
1327
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1329
def __init__(self, path, range, msg):
1331
InvalidHttpResponse.__init__(self, path, msg)
1334
class HttpBoundaryMissing(InvalidHttpResponse):
1335
"""A multipart response ends with no boundary marker.
1337
This is a special case caused by buggy proxies, described in
1338
<https://bugs.launchpad.net/bzr/+bug/198646>.
1341
_fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1343
def __init__(self, path, msg):
1344
InvalidHttpResponse.__init__(self, path, msg)
1347
class InvalidHttpContentType(InvalidHttpResponse):
1349
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1351
def __init__(self, path, ctype, msg):
1353
InvalidHttpResponse.__init__(self, path, msg)
1356
class RedirectRequested(TransportError):
1358
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1360
def __init__(self, source, target, is_permanent=False):
1361
self.source = source
1362
self.target = target
1364
self.permanently = ' permanently'
1366
self.permanently = ''
1367
TransportError.__init__(self)
1370
class TooManyRedirections(TransportError):
1372
_fmt = "Too many redirections"
1375
class ConflictsInTree(BzrError):
1377
_fmt = "Working tree has conflicts."
1380
class DependencyNotPresent(BzrError):
1382
_fmt = 'Unable to import library "%(library)s": %(error)s'
1384
def __init__(self, library, error):
1385
BzrError.__init__(self, library=library, error=error)
1388
class WorkingTreeNotRevision(BzrError):
1390
_fmt = ("The working tree for %(basedir)s has changed since"
1391
" the last commit, but weave merge requires that it be"
1394
def __init__(self, tree):
1395
BzrError.__init__(self, basedir=tree.basedir)
1398
class GraphCycleError(BzrError):
1400
_fmt = "Cycle in graph %(graph)r"
1402
def __init__(self, graph):
1403
BzrError.__init__(self)
1407
class WritingCompleted(InternalBzrError):
1409
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1410
"called upon it - accept bytes may not be called anymore.")
1412
def __init__(self, request):
1413
self.request = request
1416
class WritingNotComplete(InternalBzrError):
1418
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1419
"called upon it - until the write phase is complete no "
1420
"data may be read.")
1422
def __init__(self, request):
1423
self.request = request
1426
class NotConflicted(BzrError):
1428
_fmt = "File %(filename)s is not conflicted."
1430
def __init__(self, filename):
1431
BzrError.__init__(self)
1432
self.filename = filename
1435
class MediumNotConnected(InternalBzrError):
1437
_fmt = """The medium '%(medium)s' is not connected."""
1439
def __init__(self, medium):
1440
self.medium = medium
1443
class MustUseDecorated(Exception):
1445
_fmt = "A decorating function has requested its original command be used."
1448
class NoBundleFound(BzrError):
1450
_fmt = 'No bundle was found in "%(filename)s".'
1452
def __init__(self, filename):
1453
BzrError.__init__(self)
1454
self.filename = filename
1457
class BundleNotSupported(BzrError):
1459
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
1461
def __init__(self, version, msg):
1462
BzrError.__init__(self)
1463
self.version = version
1467
class MissingText(BzrError):
1469
_fmt = ("Branch %(base)s is missing revision"
1470
" %(text_revision)s of %(file_id)s")
1472
def __init__(self, branch, text_revision, file_id):
1473
BzrError.__init__(self)
1474
self.branch = branch
1475
self.base = branch.base
1476
self.text_revision = text_revision
1477
self.file_id = file_id
1480
class DuplicateFileId(BzrError):
1482
_fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1484
def __init__(self, file_id, entry):
1485
BzrError.__init__(self)
1486
self.file_id = file_id
1490
class DuplicateKey(BzrError):
1492
_fmt = "Key %(key)s is already present in map"
1495
class DuplicateHelpPrefix(BzrError):
1497
_fmt = "The prefix %(prefix)s is in the help search path twice."
1499
def __init__(self, prefix):
1500
self.prefix = prefix
1503
class MalformedTransform(InternalBzrError):
1505
_fmt = "Tree transform is malformed %(conflicts)r"
1508
class NoFinalPath(BzrError):
1510
_fmt = ("No final name for trans_id %(trans_id)r\n"
1511
"file-id: %(file_id)r\n"
1512
"root trans-id: %(root_trans_id)r\n")
1514
def __init__(self, trans_id, transform):
1515
self.trans_id = trans_id
1516
self.file_id = transform.final_file_id(trans_id)
1517
self.root_trans_id = transform.root
1520
class BzrBadParameter(InternalBzrError):
1522
_fmt = "Bad parameter: %(param)r"
1524
# This exception should never be thrown, but it is a base class for all
1525
# parameter-to-function errors.
1527
def __init__(self, param):
1528
BzrError.__init__(self)
1532
class BzrBadParameterNotUnicode(BzrBadParameter):
1534
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1537
class ReusingTransform(BzrError):
1539
_fmt = "Attempt to reuse a transform that has already been applied."
1542
class CantMoveRoot(BzrError):
1544
_fmt = "Moving the root directory is not supported at this time"
1547
class TransformRenameFailed(BzrError):
1549
_fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
1551
def __init__(self, from_path, to_path, why, errno):
1552
self.from_path = from_path
1553
self.to_path = to_path
1558
class BzrMoveFailedError(BzrError):
1560
_fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1561
"%(_has_extra)s%(extra)s")
1563
def __init__(self, from_path='', to_path='', extra=None):
1564
from breezy.osutils import splitpath
1565
BzrError.__init__(self)
1567
self.extra, self._has_extra = extra, ': '
1569
self.extra = self._has_extra = ''
1571
has_from = len(from_path) > 0
1572
has_to = len(to_path) > 0
1574
self.from_path = splitpath(from_path)[-1]
1579
self.to_path = splitpath(to_path)[-1]
1584
if has_from and has_to:
1585
self.operator = " =>"
1587
self.from_path = "from " + from_path
1589
self.operator = "to"
1591
self.operator = "file"
1594
class BzrRenameFailedError(BzrMoveFailedError):
1596
_fmt = ("Could not rename %(from_path)s%(operator)s %(to_path)s"
1597
"%(_has_extra)s%(extra)s")
1599
def __init__(self, from_path, to_path, extra=None):
1600
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1603
class BzrBadParameterNotString(BzrBadParameter):
1605
_fmt = "Parameter %(param)s is not a string or unicode string."
1608
class BzrBadParameterMissing(BzrBadParameter):
1610
_fmt = "Parameter %(param)s is required but not present."
1613
class BzrBadParameterUnicode(BzrBadParameter):
1615
_fmt = ("Parameter %(param)s is unicode but"
1616
" only byte-strings are permitted.")
1619
class BzrBadParameterContainsNewline(BzrBadParameter):
1621
_fmt = "Parameter %(param)s contains a newline."
1624
class ParamikoNotPresent(DependencyNotPresent):
1626
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1628
def __init__(self, error):
1629
DependencyNotPresent.__init__(self, 'paramiko', error)
1632
class PointlessMerge(BzrError):
1634
_fmt = "Nothing to merge."
1637
class UninitializableFormat(BzrError):
1639
_fmt = "Format %(format)s cannot be initialised by this version of brz."
1641
def __init__(self, format):
1642
BzrError.__init__(self)
1643
self.format = format
1646
class BadConversionTarget(BzrError):
1648
_fmt = "Cannot convert from format %(from_format)s to format %(format)s." \
1651
def __init__(self, problem, format, from_format=None):
1652
BzrError.__init__(self)
1653
self.problem = problem
1654
self.format = format
1655
self.from_format = from_format or '(unspecified)'
1658
class NoDiffFound(BzrError):
1660
_fmt = 'Could not find an appropriate Differ for file "%(path)s"'
1662
def __init__(self, path):
1663
BzrError.__init__(self, path)
1666
class ExecutableMissing(BzrError):
1668
_fmt = "%(exe_name)s could not be found on this machine"
1670
def __init__(self, exe_name):
1671
BzrError.__init__(self, exe_name=exe_name)
1674
class NoDiff(BzrError):
1676
_fmt = "Diff is not installed on this machine: %(msg)s"
1678
def __init__(self, msg):
1679
BzrError.__init__(self, msg=msg)
1682
class NoDiff3(BzrError):
1684
_fmt = "Diff3 is not installed on this machine."
1687
class ExistingContent(BzrError):
1688
# Added in breezy 0.92, used by VersionedFile.add_lines.
1690
_fmt = "The content being inserted is already present."
1693
class ExistingLimbo(BzrError):
1695
_fmt = """This tree contains left-over files from a failed operation.
1696
Please examine %(limbo_dir)s to see if it contains any files you wish to
1697
keep, and delete it when you are done."""
1699
def __init__(self, limbo_dir):
1700
BzrError.__init__(self)
1701
self.limbo_dir = limbo_dir
1704
class ExistingPendingDeletion(BzrError):
1706
_fmt = """This tree contains left-over files from a failed operation.
1707
Please examine %(pending_deletion)s to see if it contains any files you
1708
wish to keep, and delete it when you are done."""
1710
def __init__(self, pending_deletion):
1711
BzrError.__init__(self, pending_deletion=pending_deletion)
1714
class ImmortalLimbo(BzrError):
1716
_fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1717
Please examine %(limbo_dir)s to see if it contains any files you wish to
1718
keep, and delete it when you are done."""
1720
def __init__(self, limbo_dir):
1721
BzrError.__init__(self)
1722
self.limbo_dir = limbo_dir
1725
class ImmortalPendingDeletion(BzrError):
1727
_fmt = ("Unable to delete transform temporary directory "
1728
"%(pending_deletion)s. Please examine %(pending_deletion)s to see if it "
1729
"contains any files you wish to keep, and delete it when you are done.")
1731
def __init__(self, pending_deletion):
1732
BzrError.__init__(self, pending_deletion=pending_deletion)
1735
class OutOfDateTree(BzrError):
1737
_fmt = "Working tree is out of date, please run 'brz update'.%(more)s"
1739
def __init__(self, tree, more=None):
1744
BzrError.__init__(self)
1749
class PublicBranchOutOfDate(BzrError):
1751
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1754
def __init__(self, public_location, revstring):
1755
import breezy.urlutils as urlutils
1756
public_location = urlutils.unescape_for_display(public_location,
1758
BzrError.__init__(self, public_location=public_location,
1759
revstring=revstring)
1762
class MergeModifiedFormatError(BzrError):
1764
_fmt = "Error in merge modified format"
1767
class ConflictFormatError(BzrError):
1769
_fmt = "Format error in conflict listings"
1772
class CorruptRepository(BzrError):
1774
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1775
"Please run brz reconcile on this repository.")
1777
def __init__(self, repo):
1778
BzrError.__init__(self)
1779
self.repo_path = repo.user_url
1782
class InconsistentDelta(BzrError):
1783
"""Used when we get a delta that is not valid."""
1785
_fmt = ("An inconsistent delta was supplied involving %(path)r,"
1786
" %(file_id)r\nreason: %(reason)s")
1788
def __init__(self, path, file_id, reason):
1789
BzrError.__init__(self)
1791
self.file_id = file_id
1792
self.reason = reason
1795
class InconsistentDeltaDelta(InconsistentDelta):
1796
"""Used when we get a delta that is not valid."""
1798
_fmt = ("An inconsistent delta was supplied: %(delta)r"
1799
"\nreason: %(reason)s")
1801
def __init__(self, delta, reason):
1802
BzrError.__init__(self)
1804
self.reason = reason
1807
class UpgradeRequired(BzrError):
1809
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1811
def __init__(self, path):
1812
BzrError.__init__(self)
1816
class RepositoryUpgradeRequired(UpgradeRequired):
1818
_fmt = "To use this feature you must upgrade your repository at %(path)s."
1821
class RichRootUpgradeRequired(UpgradeRequired):
1823
_fmt = ("To use this feature you must upgrade your branch at %(path)s to"
1824
" a format which supports rich roots.")
1827
class LocalRequiresBoundBranch(BzrError):
1829
_fmt = "Cannot perform local-only commits on unbound branches."
1832
class UnsupportedOperation(BzrError):
1834
_fmt = ("The method %(mname)s is not supported on"
1835
" objects of type %(tname)s.")
1837
def __init__(self, method, method_self):
1838
self.method = method
1839
self.mname = method.__name__
1840
self.tname = type(method_self).__name__
1843
class FetchLimitUnsupported(UnsupportedOperation):
1845
fmt = ("InterBranch %(interbranch)r does not support fetching limits.")
1847
def __init__(self, interbranch):
1848
BzrError.__init__(self, interbranch=interbranch)
1851
class NonAsciiRevisionId(UnsupportedOperation):
1852
"""Raised when a commit is attempting to set a non-ascii revision id
1857
class SharedRepositoriesUnsupported(UnsupportedOperation):
1858
_fmt = "Shared repositories are not supported by %(format)r."
1860
def __init__(self, format):
1861
BzrError.__init__(self, format=format)
1864
class GhostTagsNotSupported(BzrError):
1866
_fmt = "Ghost tags not supported by format %(format)r."
1868
def __init__(self, format):
1869
self.format = format
1872
class BinaryFile(BzrError):
1874
_fmt = "File is binary but should be text."
1877
class IllegalPath(BzrError):
1879
_fmt = "The path %(path)s is not permitted on this platform"
1881
def __init__(self, path):
1882
BzrError.__init__(self)
1886
class TestamentMismatch(BzrError):
1888
_fmt = """Testament did not match expected value.
1889
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1892
def __init__(self, revision_id, expected, measured):
1893
self.revision_id = revision_id
1894
self.expected = expected
1895
self.measured = measured
1898
class NotABundle(BzrError):
1900
_fmt = "Not a bzr revision-bundle: %(text)r"
1902
def __init__(self, text):
1903
BzrError.__init__(self)
1907
class BadBundle(BzrError):
1909
_fmt = "Bad bzr revision-bundle: %(text)r"
1911
def __init__(self, text):
1912
BzrError.__init__(self)
1916
class MalformedHeader(BadBundle):
1918
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1921
class MalformedPatches(BadBundle):
1923
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1926
class MalformedFooter(BadBundle):
1928
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1931
class UnsupportedEOLMarker(BadBundle):
1933
_fmt = "End of line marker was not \\n in bzr revision-bundle"
1936
# XXX: BadBundle's constructor assumes there's explanatory text,
1937
# but for this there is not
1938
BzrError.__init__(self)
1941
class IncompatibleBundleFormat(BzrError):
1943
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1945
def __init__(self, bundle_format, other):
1946
BzrError.__init__(self)
1947
self.bundle_format = bundle_format
1951
class BadInventoryFormat(BzrError):
1953
_fmt = "Root class for inventory serialization errors"
1956
class UnexpectedInventoryFormat(BadInventoryFormat):
1958
_fmt = "The inventory was not in the expected format:\n %(msg)s"
1960
def __init__(self, msg):
1961
BadInventoryFormat.__init__(self, msg=msg)
1964
class RootNotRich(BzrError):
1966
_fmt = """This operation requires rich root data storage"""
1969
class NoSmartMedium(InternalBzrError):
1971
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1973
def __init__(self, transport):
1974
self.transport = transport
1977
class UnknownSSH(BzrError):
1979
_fmt = "Unrecognised value for BRZ_SSH environment variable: %(vendor)s"
1981
def __init__(self, vendor):
1982
BzrError.__init__(self)
1983
self.vendor = vendor
1986
class SSHVendorNotFound(BzrError):
1988
_fmt = ("Don't know how to handle SSH connections."
1989
" Please set BRZ_SSH environment variable.")
1992
class GhostRevisionsHaveNoRevno(BzrError):
1993
"""When searching for revnos, if we encounter a ghost, we are stuck"""
1995
_fmt = ("Could not determine revno for {%(revision_id)s} because"
1996
" its ancestry shows a ghost at {%(ghost_revision_id)s}")
1998
def __init__(self, revision_id, ghost_revision_id):
1999
self.revision_id = revision_id
2000
self.ghost_revision_id = ghost_revision_id
2003
class GhostRevisionUnusableHere(BzrError):
2005
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2007
def __init__(self, revision_id):
2008
BzrError.__init__(self)
2009
self.revision_id = revision_id
2012
class NotAMergeDirective(BzrError):
2013
"""File starting with %(firstline)r is not a merge directive"""
2015
def __init__(self, firstline):
2016
BzrError.__init__(self, firstline=firstline)
2019
class NoMergeSource(BzrError):
2020
"""Raise if no merge source was specified for a merge directive"""
2022
_fmt = "A merge directive must provide either a bundle or a public"\
2026
class IllegalMergeDirectivePayload(BzrError):
2027
"""A merge directive contained something other than a patch or bundle"""
2029
_fmt = "Bad merge directive payload %(start)r"
2031
def __init__(self, start):
2036
class PatchVerificationFailed(BzrError):
2037
"""A patch from a merge directive could not be verified"""
2039
_fmt = "Preview patch does not match requested changes."
2042
class PatchMissing(BzrError):
2043
"""Raise a patch type was specified but no patch supplied"""
2045
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2047
def __init__(self, patch_type):
2048
BzrError.__init__(self)
2049
self.patch_type = patch_type
2052
class TargetNotBranch(BzrError):
2053
"""A merge directive's target branch is required, but isn't a branch"""
2055
_fmt = ("Your branch does not have all of the revisions required in "
2056
"order to merge this merge directive and the target "
2057
"location specified in the merge directive is not a branch: "
2060
def __init__(self, location):
2061
BzrError.__init__(self)
2062
self.location = location
2065
class UnsupportedInventoryKind(BzrError):
2067
_fmt = """Unsupported entry kind %(kind)s"""
2069
def __init__(self, kind):
2073
class BadSubsumeSource(BzrError):
2075
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2077
def __init__(self, tree, other_tree, reason):
2079
self.other_tree = other_tree
2080
self.reason = reason
2083
class SubsumeTargetNeedsUpgrade(BzrError):
2085
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2087
def __init__(self, other_tree):
2088
self.other_tree = other_tree
2091
class NoSuchTag(BzrError):
2093
_fmt = "No such tag: %(tag_name)s"
2095
def __init__(self, tag_name):
2096
self.tag_name = tag_name
2099
class TagsNotSupported(BzrError):
2101
_fmt = ("Tags not supported by %(branch)s;"
2102
" you may be able to use 'brz upgrade %(branch_url)s'.")
2104
def __init__(self, branch):
2105
self.branch = branch
2106
self.branch_url = branch.user_url
2109
class TagAlreadyExists(BzrError):
2111
_fmt = "Tag %(tag_name)s already exists."
2113
def __init__(self, tag_name):
2114
self.tag_name = tag_name
2117
class UnexpectedSmartServerResponse(BzrError):
2119
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2121
def __init__(self, response_tuple):
2122
self.response_tuple = response_tuple
2125
class ErrorFromSmartServer(BzrError):
2126
"""An error was received from a smart server.
2128
:seealso: UnknownErrorFromSmartServer
2131
_fmt = "Error received from smart server: %(error_tuple)r"
2133
internal_error = True
2135
def __init__(self, error_tuple):
2136
self.error_tuple = error_tuple
2138
self.error_verb = error_tuple[0]
2140
self.error_verb = None
2141
self.error_args = error_tuple[1:]
2144
class UnknownErrorFromSmartServer(BzrError):
2145
"""An ErrorFromSmartServer could not be translated into a typical breezy
2148
This is distinct from ErrorFromSmartServer so that it is possible to
2149
distinguish between the following two cases:
2151
- ErrorFromSmartServer was uncaught. This is logic error in the client
2152
and so should provoke a traceback to the user.
2153
- ErrorFromSmartServer was caught but its error_tuple could not be
2154
translated. This is probably because the server sent us garbage, and
2155
should not provoke a traceback.
2158
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2160
internal_error = False
2162
def __init__(self, error_from_smart_server):
2165
:param error_from_smart_server: An ErrorFromSmartServer instance.
2167
self.error_from_smart_server = error_from_smart_server
2168
self.error_tuple = error_from_smart_server.error_tuple
2171
class ContainerError(BzrError):
2172
"""Base class of container errors."""
2175
class UnknownContainerFormatError(ContainerError):
2177
_fmt = "Unrecognised container format: %(container_format)r"
2179
def __init__(self, container_format):
2180
self.container_format = container_format
2183
class UnexpectedEndOfContainerError(ContainerError):
2185
_fmt = "Unexpected end of container stream"
2188
class UnknownRecordTypeError(ContainerError):
2190
_fmt = "Unknown record type: %(record_type)r"
2192
def __init__(self, record_type):
2193
self.record_type = record_type
2196
class InvalidRecordError(ContainerError):
2198
_fmt = "Invalid record: %(reason)s"
2200
def __init__(self, reason):
2201
self.reason = reason
2204
class ContainerHasExcessDataError(ContainerError):
2206
_fmt = "Container has data after end marker: %(excess)r"
2208
def __init__(self, excess):
2209
self.excess = excess
2212
class DuplicateRecordNameError(ContainerError):
2214
_fmt = "Container has multiple records with the same name: %(name)s"
2216
def __init__(self, name):
2217
self.name = name.decode("utf-8")
2220
class RepositoryDataStreamError(BzrError):
2222
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2224
def __init__(self, reason):
2225
self.reason = reason
2228
class UncommittedChanges(BzrError):
2230
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2231
' (See brz status).%(more)s')
2233
def __init__(self, tree, more=None):
2238
import breezy.urlutils as urlutils
2239
user_url = getattr(tree, "user_url", None)
2240
if user_url is None:
2241
display_url = str(tree)
2243
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2244
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2247
class StoringUncommittedNotSupported(BzrError):
2249
_fmt = ('Branch "%(display_url)s" does not support storing uncommitted'
2252
def __init__(self, branch):
2253
import breezy.urlutils as urlutils
2254
user_url = getattr(branch, "user_url", None)
2255
if user_url is None:
2256
display_url = str(branch)
2258
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2259
BzrError.__init__(self, branch=branch, display_url=display_url)
2262
class ShelvedChanges(UncommittedChanges):
2264
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2265
' (See brz shelve --list).%(more)s')
2268
class UnableEncodePath(BzrError):
2270
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2271
'user encoding %(user_encoding)s')
2273
def __init__(self, path, kind):
2274
from breezy.osutils import get_user_encoding
2277
self.user_encoding = get_user_encoding()
2280
class NoSuchAlias(BzrError):
2282
_fmt = ('The alias "%(alias_name)s" does not exist.')
2284
def __init__(self, alias_name):
2285
BzrError.__init__(self, alias_name=alias_name)
2288
class CannotBindAddress(BzrError):
2290
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2292
def __init__(self, host, port, orig_error):
2293
# nb: in python2.4 socket.error doesn't have a useful repr
2294
BzrError.__init__(self, host=host, port=port,
2295
orig_error=repr(orig_error.args))
2298
class TipChangeRejected(BzrError):
2299
"""A pre_change_branch_tip hook function may raise this to cleanly and
2300
explicitly abort a change to a branch tip.
2303
_fmt = u"Tip change rejected: %(msg)s"
2305
def __init__(self, msg):
2309
class JailBreak(BzrError):
2311
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2313
def __init__(self, url):
2314
BzrError.__init__(self, url=url)
2317
class UserAbort(BzrError):
2319
_fmt = 'The user aborted the operation.'
2322
class UnresumableWriteGroup(BzrError):
2324
_fmt = ("Repository %(repository)s cannot resume write group "
2325
"%(write_groups)r: %(reason)s")
2327
internal_error = True
2329
def __init__(self, repository, write_groups, reason):
2330
self.repository = repository
2331
self.write_groups = write_groups
2332
self.reason = reason
2335
class UnsuspendableWriteGroup(BzrError):
2337
_fmt = ("Repository %(repository)s cannot suspend a write group.")
2339
internal_error = True
2341
def __init__(self, repository):
2342
self.repository = repository
2345
class LossyPushToSameVCS(BzrError):
2347
_fmt = ("Lossy push not possible between %(source_branch)r and "
2348
"%(target_branch)r that are in the same VCS.")
2350
internal_error = True
2352
def __init__(self, source_branch, target_branch):
2353
self.source_branch = source_branch
2354
self.target_branch = target_branch
2357
class NoRoundtrippingSupport(BzrError):
2359
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
2360
"%(target_branch)r.")
2362
internal_error = True
2364
def __init__(self, source_branch, target_branch):
2365
self.source_branch = source_branch
2366
self.target_branch = target_branch
2369
class NoColocatedBranchSupport(BzrError):
2371
_fmt = ("%(controldir)r does not support co-located branches.")
2373
def __init__(self, controldir):
2374
self.controldir = controldir
2377
class RecursiveBind(BzrError):
2379
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2380
'Please use `brz unbind` to fix.')
2382
def __init__(self, branch_url):
2383
self.branch_url = branch_url
2386
class UnsupportedKindChange(BzrError):
2388
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2389
"%(path)s not supported by format %(format)r")
2391
def __init__(self, path, from_kind, to_kind, format):
2393
self.from_kind = from_kind
2394
self.to_kind = to_kind
2395
self.format = format
2398
class ChangesAlreadyStored(BzrCommandError):
2400
_fmt = ('Cannot store uncommitted changes because this branch already'
2401
' stores uncommitted changes.')
2404
class RevnoOutOfBounds(InternalBzrError):
2406
_fmt = ("The requested revision number %(revno)d is outside of the "
2407
"expected boundaries (%(minimum)d <= %(maximum)d).")
2409
def __init__(self, revno, bounds):
2410
InternalBzrError.__init__(
2411
self, revno=revno, minimum=bounds[0], maximum=bounds[1])