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.
21
# TODO: is there any value in providing the .args field used by standard
22
# python exceptions? A list of values with no names seems less useful
25
# TODO: Perhaps convert the exception to a string at the moment it's
26
# constructed to make sure it will succeed. But that says nothing about
27
# exceptions that are never raised.
29
# TODO: selftest assertRaises should probably also check that every error
30
# raised can be formatted as a string successfully, and without giving
34
# return codes from the brz program
37
EXIT_INTERNAL_ERROR = 4
40
class BzrError(Exception):
42
Base class for errors raised by breezy.
44
:cvar internal_error: if True this was probably caused by a brz bug and
45
should be displayed with a traceback; if False (or absent) this was
46
probably a user or environment error and they don't need the gory
47
details. (That can be overridden by -Derror on the command line.)
49
:cvar _fmt: Format string to display the error; this is expanded
50
by the instance's dict.
53
internal_error = False
55
def __init__(self, msg=None, **kwds):
56
"""Construct a new BzrError.
58
There are two alternative forms for constructing these objects.
59
Either a preformatted string may be passed, or a set of named
60
arguments can be given. The first is for generic "user" errors which
61
are not intended to be caught and so do not need a specific subclass.
62
The second case is for use with subclasses that provide a _fmt format
63
string to print the arguments.
65
Keyword arguments are taken as parameters to the error, which can
66
be inserted into the format string template. It's recommended
67
that subclasses override the __init__ method to require specific
70
:param msg: If given, this is the literal complete text for the error,
71
not subject to expansion. 'msg' is used instead of 'message' because
72
python evolved and, in 2.6, forbids the use of 'message'.
74
Exception.__init__(self)
76
# I was going to deprecate this, but it actually turns out to be
77
# quite handy - mbp 20061103.
78
self._preformatted_string = msg
80
self._preformatted_string = None
81
for key, value in kwds.items():
82
setattr(self, key, value)
85
s = getattr(self, '_preformatted_string', None)
87
# contains a preformatted message
91
fmt = self._get_format_string()
93
d = dict(self.__dict__)
95
# __str__() should always return a 'str' object
96
# never a 'unicode' object.
98
except Exception as e:
100
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
101
% (self.__class__.__name__,
103
getattr(self, '_fmt', None),
109
return '%s(%s)' % (self.__class__.__name__, str(self))
111
def _get_format_string(self):
112
"""Return format string for this exception or None"""
113
fmt = getattr(self, '_fmt', None)
115
from breezy.i18n import gettext
116
return gettext(fmt) # _fmt strings should be ascii
118
def __eq__(self, other):
119
if self.__class__ is not other.__class__:
120
return NotImplemented
121
return self.__dict__ == other.__dict__
127
class InternalBzrError(BzrError):
128
"""Base class for errors that are internal in nature.
130
This is a convenience class for errors that are internal. The
131
internal_error attribute can still be altered in subclasses, if needed.
132
Using this class is simply an easy way to get internal errors.
135
internal_error = True
138
class BranchError(BzrError):
139
"""Base class for concrete 'errors about a branch'."""
141
def __init__(self, branch):
142
BzrError.__init__(self, branch=branch)
145
class BzrCheckError(InternalBzrError):
147
_fmt = "Internal check failed: %(msg)s"
149
def __init__(self, msg):
150
BzrError.__init__(self)
154
class IncompatibleVersion(BzrError):
156
_fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\
157
'is required, but current version is %(current)r.'
159
def __init__(self, api, wanted, current):
162
self.current = current
165
class InProcessTransport(BzrError):
167
_fmt = "The transport '%(transport)s' is only accessible within this " \
170
def __init__(self, transport):
171
self.transport = transport
174
class InvalidRevisionNumber(BzrError):
176
_fmt = "Invalid revision number %(revno)s"
178
def __init__(self, revno):
179
BzrError.__init__(self)
183
class InvalidRevisionId(BzrError):
185
_fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
187
def __init__(self, revision_id, branch):
188
# branch can be any string or object with __str__ defined
189
BzrError.__init__(self)
190
self.revision_id = revision_id
194
class ReservedId(BzrError):
196
_fmt = "Reserved revision-id {%(revision_id)s}"
198
def __init__(self, revision_id):
199
self.revision_id = revision_id
202
class RootMissing(InternalBzrError):
204
_fmt = ("The root entry of a tree must be the first entry supplied to "
205
"the commit builder.")
208
class NoPublicBranch(BzrError):
210
_fmt = 'There is no public branch set for "%(branch_url)s".'
212
def __init__(self, branch):
213
from . import urlutils
214
public_location = urlutils.unescape_for_display(branch.base, 'ascii')
215
BzrError.__init__(self, branch_url=public_location)
218
class NoSuchId(BzrError):
220
_fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
222
def __init__(self, tree, file_id):
223
BzrError.__init__(self)
224
self.file_id = file_id
228
class NotStacked(BranchError):
230
_fmt = "The branch '%(branch)s' is not stacked."
233
class NoWorkingTree(BzrError):
235
_fmt = 'No WorkingTree exists for "%(base)s".'
237
def __init__(self, base):
238
BzrError.__init__(self)
242
class NotLocalUrl(BzrError):
244
_fmt = "%(url)s is not a local path."
246
def __init__(self, url):
250
class WorkingTreeAlreadyPopulated(InternalBzrError):
252
_fmt = 'Working tree already populated in "%(base)s"'
254
def __init__(self, base):
258
class NoWhoami(BzrError):
260
_fmt = ('Unable to determine your name.\n'
261
"Please, set your name with the 'whoami' command.\n"
262
'E.g. brz whoami "Your Name <name@example.com>"')
265
class CommandError(BzrError):
266
"""Error from user command"""
268
# Error from malformed user command; please avoid raising this as a
269
# generic exception not caused by user input.
271
# I think it's a waste of effort to differentiate between errors that
272
# are not intended to be caught anyway. UI code need not subclass
273
# CommandError, and non-UI code should not throw a subclass of
274
# CommandError. ADHB 20051211
277
# Provide the old name as backup, for the moment.
278
BzrCommandError = CommandError
281
class NotWriteLocked(BzrError):
283
_fmt = """%(not_locked)r is not write locked but needs to be."""
285
def __init__(self, not_locked):
286
self.not_locked = not_locked
289
class StrictCommitFailed(BzrError):
291
_fmt = "Commit refused because there are unknown files in the tree"
294
# XXX: Should be unified with TransportError; they seem to represent the
296
# RBC 20060929: I think that unifiying with TransportError would be a mistake
297
# - this is finer than a TransportError - and more useful as such. It
298
# differentiates between 'transport has failed' and 'operation on a transport
300
class PathError(BzrError):
302
_fmt = "Generic path error: %(path)r%(extra)s)"
304
def __init__(self, path, extra=None):
305
BzrError.__init__(self)
308
self.extra = ': ' + str(extra)
313
class NoSuchFile(PathError):
315
_fmt = "No such file: %(path)r%(extra)s"
318
class FileExists(PathError):
320
_fmt = "File exists: %(path)r%(extra)s"
323
class RenameFailedFilesExist(BzrError):
324
"""Used when renaming and both source and dest exist."""
326
_fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
327
" (Use --after to tell brz about a rename that has already"
328
" happened)%(extra)s")
330
def __init__(self, source, dest, extra=None):
331
BzrError.__init__(self)
332
self.source = str(source)
333
self.dest = str(dest)
335
self.extra = ' ' + str(extra)
340
class NotADirectory(PathError):
342
_fmt = '"%(path)s" is not a directory %(extra)s'
345
class NotInWorkingDirectory(PathError):
347
_fmt = '"%(path)s" is not in the working directory %(extra)s'
350
class DirectoryNotEmpty(PathError):
352
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
355
class HardLinkNotSupported(PathError):
357
_fmt = 'Hard-linking "%(path)s" is not supported'
360
class ReadingCompleted(InternalBzrError):
362
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
363
"called upon it - the request has been completed and no more "
366
def __init__(self, request):
367
self.request = request
370
class ResourceBusy(PathError):
372
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
375
class PermissionDenied(PathError):
377
_fmt = 'Permission denied: "%(path)s"%(extra)s'
380
class UnsupportedProtocol(PathError):
382
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
384
def __init__(self, url, extra=""):
385
PathError.__init__(self, url, extra=extra)
388
class UnstackableLocationError(BzrError):
390
_fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
392
def __init__(self, branch_url, target_url):
393
BzrError.__init__(self)
394
self.branch_url = branch_url
395
self.target_url = target_url
398
class UnstackableRepositoryFormat(BzrError):
400
_fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
401
"You will need to upgrade the repository to permit branch stacking.")
403
def __init__(self, format, url):
404
BzrError.__init__(self)
409
class ReadError(PathError):
411
_fmt = """Error reading from %(path)r."""
414
class ShortReadvError(PathError):
416
_fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
417
' at %(offset)s for "%(path)s"%(extra)s')
419
internal_error = True
421
def __init__(self, path, offset, length, actual, extra=None):
422
PathError.__init__(self, path, extra=extra)
428
class PathNotChild(PathError):
430
_fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
432
internal_error = False
434
def __init__(self, path, base, extra=None):
435
BzrError.__init__(self)
439
self.extra = ': ' + str(extra)
444
class InvalidNormalization(PathError):
446
_fmt = 'Path "%(path)s" is not unicode normalized'
449
# TODO: This is given a URL; we try to unescape it but doing that from inside
450
# the exception object is a bit undesirable.
451
# TODO: Probably this behavior of should be a common superclass
452
class NotBranchError(PathError):
454
_fmt = 'Not a branch: "%(path)s"%(detail)s.'
456
def __init__(self, path, detail=None, controldir=None):
457
from . import urlutils
458
path = urlutils.unescape_for_display(path, 'ascii')
459
if detail is not None:
460
detail = ': ' + detail
462
self.controldir = controldir
463
PathError.__init__(self, path=path)
466
return '<%s %r>' % (self.__class__.__name__, self.__dict__)
468
def _get_format_string(self):
469
# GZ 2017-06-08: Not the best place to lazy fill detail in.
470
if self.detail is None:
471
self.detail = self._get_detail()
472
return super(NotBranchError, self)._get_format_string()
474
def _get_detail(self):
475
if self.controldir is not None:
477
self.controldir.open_repository()
478
except NoRepositoryPresent:
480
except Exception as e:
481
# Just ignore unexpected errors. Raising arbitrary errors
482
# during str(err) can provoke strange bugs. Concretely
483
# Launchpad's codehosting managed to raise NotBranchError
484
# here, and then get stuck in an infinite loop/recursion
485
# trying to str() that error. All this error really cares
486
# about that there's no working repository there, and if
487
# open_repository() fails, there probably isn't.
488
return ': ' + e.__class__.__name__
490
return ': location is a repository'
494
class NoSubmitBranch(PathError):
496
_fmt = 'No submit branch available for branch "%(path)s"'
498
def __init__(self, branch):
499
from . import urlutils
500
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
503
class AlreadyControlDirError(PathError):
505
_fmt = 'A control directory already exists: "%(path)s".'
508
class AlreadyBranchError(PathError):
510
_fmt = 'Already a branch: "%(path)s".'
513
class InvalidBranchName(PathError):
515
_fmt = "Invalid branch name: %(name)s"
517
def __init__(self, name):
518
BzrError.__init__(self)
522
class ParentBranchExists(AlreadyBranchError):
524
_fmt = 'Parent branch already exists: "%(path)s".'
527
class BranchExistsWithoutWorkingTree(PathError):
529
_fmt = 'Directory contains a branch, but no working tree \
530
(use brz checkout if you wish to build a working tree): "%(path)s"'
533
class InaccessibleParent(PathError):
535
_fmt = ('Parent not accessible given base "%(base)s" and'
536
' relative path "%(path)s"')
538
def __init__(self, path, base):
539
PathError.__init__(self, path)
543
class NoRepositoryPresent(BzrError):
545
_fmt = 'No repository present: "%(path)s"'
547
def __init__(self, controldir):
548
BzrError.__init__(self)
549
self.path = controldir.transport.clone('..').base
552
class UnsupportedFormatError(BzrError):
554
_fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
557
class UnknownFormatError(BzrError):
559
_fmt = "Unknown %(kind)s format: %(format)r"
561
def __init__(self, format, kind='branch'):
566
class LineEndingError(BzrError):
568
_fmt = ("Line ending corrupted for file: %(file)s; "
569
"Maybe your files got corrupted in transport?")
571
def __init__(self, file):
575
class IncompatibleFormat(BzrError):
577
_fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
579
def __init__(self, format, controldir_format):
580
BzrError.__init__(self)
582
self.controldir = controldir_format
585
class ParseFormatError(BzrError):
587
_fmt = "Parse error on line %(lineno)d of %(format)s format: %(line)s"
589
def __init__(self, format, lineno, line, text):
590
BzrError.__init__(self)
597
class IncompatibleRepositories(BzrError):
598
"""Report an error that two repositories are not compatible.
600
Note that the source and target repositories are permitted to be strings:
601
this exception is thrown from the smart server and may refer to a
602
repository the client hasn't opened.
605
_fmt = "%(target)s\n" \
606
"is not compatible with\n" \
610
def __init__(self, source, target, details=None):
612
details = "(no details)"
613
BzrError.__init__(self, target=target, source=source, details=details)
616
class IncompatibleRevision(BzrError):
618
_fmt = "Revision is not compatible with %(repo_format)s"
620
def __init__(self, repo_format):
621
BzrError.__init__(self)
622
self.repo_format = repo_format
625
class AlreadyVersionedError(BzrError):
626
"""Used when a path is expected not to be versioned, but it is."""
628
_fmt = "%(context_info)s%(path)s is already versioned."
630
def __init__(self, path, context_info=None):
631
"""Construct a new AlreadyVersionedError.
633
:param path: This is the path which is versioned,
634
which should be in a user friendly form.
635
:param context_info: If given, this is information about the context,
636
which could explain why this is expected to not be versioned.
638
BzrError.__init__(self)
640
if context_info is None:
641
self.context_info = ''
643
self.context_info = context_info + ". "
646
class NotVersionedError(BzrError):
647
"""Used when a path is expected to be versioned, but it is not."""
649
_fmt = "%(context_info)s%(path)s is not versioned."
651
def __init__(self, path, context_info=None):
652
"""Construct a new NotVersionedError.
654
:param path: This is the path which is not versioned,
655
which should be in a user friendly form.
656
:param context_info: If given, this is information about the context,
657
which could explain why this is expected to be versioned.
659
BzrError.__init__(self)
661
if context_info is None:
662
self.context_info = ''
664
self.context_info = context_info + ". "
667
class PathsNotVersionedError(BzrError):
668
"""Used when reporting several paths which are not versioned"""
670
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
672
def __init__(self, paths):
673
from breezy.osutils import quotefn
674
BzrError.__init__(self)
676
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
679
class PathsDoNotExist(BzrError):
681
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
683
# used when reporting that paths are neither versioned nor in the working
686
def __init__(self, paths, extra=None):
688
from breezy.osutils import quotefn
689
BzrError.__init__(self)
691
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
693
self.extra = ': ' + str(extra)
698
class BadFileKindError(BzrError):
700
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
702
def __init__(self, filename, kind):
703
BzrError.__init__(self, filename=filename, kind=kind)
706
class BadFilenameEncoding(BzrError):
708
_fmt = ('Filename %(filename)r is not valid in your current filesystem'
709
' encoding %(fs_encoding)s')
711
def __init__(self, filename, fs_encoding):
712
BzrError.__init__(self)
713
self.filename = filename
714
self.fs_encoding = fs_encoding
717
class ForbiddenControlFileError(BzrError):
719
_fmt = 'Cannot operate on "%(filename)s" because it is a control file'
722
class LockError(InternalBzrError):
724
_fmt = "Lock error: %(msg)s"
726
# All exceptions from the lock/unlock functions should be from
727
# this exception class. They will be translated as necessary. The
728
# original exception is available as e.original_error
730
# New code should prefer to raise specific subclasses
731
def __init__(self, msg):
735
class LockActive(LockError):
737
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
739
internal_error = False
741
def __init__(self, lock_description):
742
self.lock_description = lock_description
745
class CommitNotPossible(LockError):
747
_fmt = "A commit was attempted but we do not have a write lock open."
753
class AlreadyCommitted(LockError):
755
_fmt = "A rollback was requested, but is not able to be accomplished."
761
class ReadOnlyError(LockError):
763
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
765
# TODO: There should also be an error indicating that you need a write
766
# lock and don't have any lock at all... mbp 20070226
768
def __init__(self, obj):
772
class LockFailed(LockError):
774
internal_error = False
776
_fmt = "Cannot lock %(lock)s: %(why)s"
778
def __init__(self, lock, why):
779
LockError.__init__(self, '')
784
class OutSideTransaction(BzrError):
786
_fmt = ("A transaction related operation was attempted after"
787
" the transaction finished.")
790
class ObjectNotLocked(LockError):
792
_fmt = "%(obj)r is not locked"
794
# this can indicate that any particular object is not locked; see also
795
# LockNotHeld which means that a particular *lock* object is not held by
796
# the caller -- perhaps they should be unified.
797
def __init__(self, obj):
801
class ReadOnlyObjectDirtiedError(ReadOnlyError):
803
_fmt = "Cannot change object %(obj)r in read only transaction"
805
def __init__(self, obj):
809
class UnlockableTransport(LockError):
811
internal_error = False
813
_fmt = "Cannot lock: transport is read only: %(transport)s"
815
def __init__(self, transport):
816
self.transport = transport
819
class LockContention(LockError):
821
_fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
823
internal_error = False
825
def __init__(self, lock, msg=''):
830
class LockBroken(LockError):
832
_fmt = ("Lock was broken while still open: %(lock)s"
833
" - check storage consistency!")
835
internal_error = False
837
def __init__(self, lock):
841
class LockBreakMismatch(LockError):
843
_fmt = ("Lock was released and re-acquired before being broken:"
844
" %(lock)s: held by %(holder)r, wanted to break %(target)r")
846
internal_error = False
848
def __init__(self, lock, holder, target):
854
class LockCorrupt(LockError):
856
_fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
857
"Use 'brz break-lock' to clear it")
859
internal_error = False
861
def __init__(self, corruption_info, file_data=None):
862
self.corruption_info = corruption_info
863
self.file_data = file_data
866
class LockNotHeld(LockError):
868
_fmt = "Lock not held: %(lock)s"
870
internal_error = False
872
def __init__(self, lock):
876
class TokenLockingNotSupported(LockError):
878
_fmt = "The object %(obj)s does not support token specifying a token when locking."
880
def __init__(self, obj):
884
class TokenMismatch(LockBroken):
886
_fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
888
internal_error = True
890
def __init__(self, given_token, lock_token):
891
self.given_token = given_token
892
self.lock_token = lock_token
895
class UpgradeReadonly(BzrError):
897
_fmt = "Upgrade URL cannot work with readonly URLs."
900
class UpToDateFormat(BzrError):
902
_fmt = "The branch format %(format)s is already at the most recent format."
904
def __init__(self, format):
905
BzrError.__init__(self)
909
class NoSuchRevision(InternalBzrError):
911
_fmt = "%(branch)s has no revision %(revision)s"
913
def __init__(self, branch, revision):
914
# 'branch' may sometimes be an internal object like a KnitRevisionStore
915
BzrError.__init__(self, branch=branch, revision=revision)
918
class RangeInChangeOption(BzrError):
920
_fmt = "Option --change does not accept revision ranges"
923
class NoSuchRevisionSpec(BzrError):
925
_fmt = "No namespace registered for string: %(spec)r"
927
def __init__(self, spec):
928
BzrError.__init__(self, spec=spec)
931
class NoSuchRevisionInTree(NoSuchRevision):
932
"""When using Tree.revision_tree, and the revision is not accessible."""
934
_fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
936
def __init__(self, tree, revision_id):
937
BzrError.__init__(self)
939
self.revision_id = revision_id
942
class AppendRevisionsOnlyViolation(BzrError):
944
_fmt = ('Operation denied because it would change the main history,'
945
' which is not permitted by the append_revisions_only setting on'
946
' branch "%(location)s".')
948
def __init__(self, location):
949
import breezy.urlutils as urlutils
950
location = urlutils.unescape_for_display(location, 'ascii')
951
BzrError.__init__(self, location=location)
954
class DivergedBranches(BzrError):
956
_fmt = ("These branches have diverged."
957
" Use the missing command to see how.\n"
958
"Use the merge command to reconcile them.")
960
def __init__(self, branch1, branch2):
961
self.branch1 = branch1
962
self.branch2 = branch2
965
class NotLefthandHistory(InternalBzrError):
967
_fmt = "Supplied history does not follow left-hand parents"
969
def __init__(self, history):
970
BzrError.__init__(self, history=history)
973
class UnrelatedBranches(BzrError):
975
_fmt = ("Branches have no common ancestor, and"
976
" no merge base revision was specified.")
979
class CannotReverseCherrypick(BzrError):
981
_fmt = ('Selected merge cannot perform reverse cherrypicks. Try merge3'
985
class NoCommonAncestor(BzrError):
987
_fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
989
def __init__(self, revision_a, revision_b):
990
self.revision_a = revision_a
991
self.revision_b = revision_b
994
class NoCommonRoot(BzrError):
996
_fmt = ("Revisions are not derived from the same root: "
997
"%(revision_a)s %(revision_b)s.")
999
def __init__(self, revision_a, revision_b):
1000
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
1003
class NotAncestor(BzrError):
1005
_fmt = "Revision %(rev_id)s is not an ancestor of %(not_ancestor_id)s"
1007
def __init__(self, rev_id, not_ancestor_id):
1008
BzrError.__init__(self, rev_id=rev_id,
1009
not_ancestor_id=not_ancestor_id)
1012
class NoCommits(BranchError):
1014
_fmt = "Branch %(branch)s has no commits."
1017
class UnlistableStore(BzrError):
1019
def __init__(self, store):
1020
BzrError.__init__(self, "Store %s is not listable" % store)
1023
class UnlistableBranch(BzrError):
1025
def __init__(self, br):
1026
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
1029
class BoundBranchOutOfDate(BzrError):
1031
_fmt = ("Bound branch %(branch)s is out of date with master branch"
1032
" %(master)s.%(extra_help)s")
1034
def __init__(self, branch, master):
1035
BzrError.__init__(self)
1036
self.branch = branch
1037
self.master = master
1038
self.extra_help = ''
1041
class CommitToDoubleBoundBranch(BzrError):
1043
_fmt = ("Cannot commit to branch %(branch)s."
1044
" It is bound to %(master)s, which is bound to %(remote)s.")
1046
def __init__(self, branch, master, remote):
1047
BzrError.__init__(self)
1048
self.branch = branch
1049
self.master = master
1050
self.remote = remote
1053
class OverwriteBoundBranch(BzrError):
1055
_fmt = "Cannot pull --overwrite to a branch which is bound %(branch)s"
1057
def __init__(self, branch):
1058
BzrError.__init__(self)
1059
self.branch = branch
1062
class BoundBranchConnectionFailure(BzrError):
1064
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1065
" => %(target)s: %(error)s")
1067
def __init__(self, branch, target, error):
1068
BzrError.__init__(self)
1069
self.branch = branch
1070
self.target = target
1074
class VersionedFileError(BzrError):
1076
_fmt = "Versioned file error"
1079
class RevisionNotPresent(VersionedFileError):
1081
_fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1083
def __init__(self, revision_id, file_id):
1084
VersionedFileError.__init__(self)
1085
self.revision_id = revision_id
1086
self.file_id = file_id
1089
class RevisionAlreadyPresent(VersionedFileError):
1091
_fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1093
def __init__(self, revision_id, file_id):
1094
VersionedFileError.__init__(self)
1095
self.revision_id = revision_id
1096
self.file_id = file_id
1099
class VersionedFileInvalidChecksum(VersionedFileError):
1101
_fmt = "Text did not match its checksum: %(msg)s"
1104
class RetryWithNewPacks(BzrError):
1105
"""Raised when we realize that the packs on disk have changed.
1107
This is meant as more of a signaling exception, to trap between where a
1108
local error occurred and the code that can actually handle the error and
1109
code that can retry appropriately.
1112
internal_error = True
1114
_fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1117
def __init__(self, context, reload_occurred, exc_info):
1118
"""create a new RetryWithNewPacks error.
1120
:param reload_occurred: Set to True if we know that the packs have
1121
already been reloaded, and we are failing because of an in-memory
1122
cache miss. If set to True then we will ignore if a reload says
1123
nothing has changed, because we assume it has already reloaded. If
1124
False, then a reload with nothing changed will force an error.
1125
:param exc_info: The original exception traceback, so if there is a
1126
problem we can raise the original error (value from sys.exc_info())
1128
BzrError.__init__(self)
1129
self.context = context
1130
self.reload_occurred = reload_occurred
1131
self.exc_info = exc_info
1132
self.orig_error = exc_info[1]
1133
# TODO: The global error handler should probably treat this by
1134
# raising/printing the original exception with a bit about
1135
# RetryWithNewPacks also not being caught
1138
class RetryAutopack(RetryWithNewPacks):
1139
"""Raised when we are autopacking and we find a missing file.
1141
Meant as a signaling exception, to tell the autopack code it should try
1145
internal_error = True
1147
_fmt = ("Pack files have changed, reload and try autopack again."
1148
" context: %(context)s %(orig_error)s")
1151
class NoSuchExportFormat(BzrError):
1153
_fmt = "Export format %(format)r not supported"
1155
def __init__(self, format):
1156
BzrError.__init__(self)
1157
self.format = format
1160
class TransportError(BzrError):
1162
_fmt = "Transport error: %(msg)s %(orig_error)s"
1164
def __init__(self, msg=None, orig_error=None):
1165
if msg is None and orig_error is not None:
1166
msg = str(orig_error)
1167
if orig_error is None:
1172
self.orig_error = orig_error
1173
BzrError.__init__(self)
1176
class TooManyConcurrentRequests(InternalBzrError):
1178
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1179
" Be sure to finish_writing and finish_reading on the"
1180
" currently open request.")
1182
def __init__(self, medium):
1183
self.medium = medium
1186
class SmartProtocolError(TransportError):
1188
_fmt = "Generic bzr smart protocol error: %(details)s"
1190
def __init__(self, details):
1191
self.details = details
1194
class UnexpectedProtocolVersionMarker(TransportError):
1196
_fmt = "Received bad protocol version marker: %(marker)r"
1198
def __init__(self, marker):
1199
self.marker = marker
1202
class UnknownSmartMethod(InternalBzrError):
1204
_fmt = "The server does not recognise the '%(verb)s' request."
1206
def __init__(self, verb):
1210
class SmartMessageHandlerError(InternalBzrError):
1212
_fmt = ("The message handler raised an exception:\n"
1213
"%(traceback_text)s")
1215
def __init__(self, exc_info):
1217
# GZ 2010-08-10: Cycle with exc_tb/exc_info affects at least one test
1218
self.exc_type, self.exc_value, self.exc_tb = exc_info
1219
self.exc_info = exc_info
1220
traceback_strings = traceback.format_exception(
1221
self.exc_type, self.exc_value, self.exc_tb)
1222
self.traceback_text = ''.join(traceback_strings)
1225
# A set of semi-meaningful errors which can be thrown
1226
class TransportNotPossible(TransportError):
1228
_fmt = "Transport operation not possible: %(msg)s %(orig_error)s"
1231
class ConnectionError(TransportError):
1233
_fmt = "Connection error: %(msg)s %(orig_error)s"
1236
class SocketConnectionError(ConnectionError):
1238
_fmt = "%(msg)s %(host)s%(port)s%(orig_error)s"
1240
def __init__(self, host, port=None, msg=None, orig_error=None):
1242
msg = 'Failed to connect to'
1243
if orig_error is None:
1246
orig_error = '; ' + str(orig_error)
1247
ConnectionError.__init__(self, msg=msg, orig_error=orig_error)
1252
self.port = ':%s' % port
1255
# XXX: This is also used for unexpected end of file, which is different at the
1256
# TCP level from "connection reset".
1257
class ConnectionReset(TransportError):
1259
_fmt = "Connection closed: %(msg)s %(orig_error)s"
1262
class ConnectionTimeout(ConnectionError):
1264
_fmt = "Connection Timeout: %(msg)s%(orig_error)s"
1267
class InvalidRange(TransportError):
1269
_fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1271
def __init__(self, path, offset, msg=None):
1272
TransportError.__init__(self, msg)
1274
self.offset = offset
1277
class InvalidHttpResponse(TransportError):
1279
_fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1281
def __init__(self, path, msg, orig_error=None):
1283
if orig_error is None:
1286
# This is reached for obscure and unusual errors so we want to
1287
# preserve as much info as possible to ease debug.
1288
orig_error = ': %r' % (orig_error,)
1289
TransportError.__init__(self, msg, orig_error=orig_error)
1292
class UnexpectedHttpStatus(InvalidHttpResponse):
1294
_fmt = "Unexpected HTTP status %(code)d for %(path)s"
1296
def __init__(self, path, code, msg=None):
1300
full_msg = 'status code %d unexpected' % code
1302
full_msg += ': ' + msg
1303
InvalidHttpResponse.__init__(
1304
self, path, full_msg)
1307
class BadHttpRequest(UnexpectedHttpStatus):
1309
_fmt = "Bad http request for %(path)s: %(reason)s"
1311
def __init__(self, path, reason):
1313
self.reason = reason
1314
TransportError.__init__(self, reason)
1317
class InvalidHttpRange(InvalidHttpResponse):
1319
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1321
def __init__(self, path, range, msg):
1323
InvalidHttpResponse.__init__(self, path, msg)
1326
class HttpBoundaryMissing(InvalidHttpResponse):
1327
"""A multipart response ends with no boundary marker.
1329
This is a special case caused by buggy proxies, described in
1330
<https://bugs.launchpad.net/bzr/+bug/198646>.
1333
_fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1335
def __init__(self, path, msg):
1336
InvalidHttpResponse.__init__(self, path, msg)
1339
class InvalidHttpContentType(InvalidHttpResponse):
1341
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1343
def __init__(self, path, ctype, msg):
1345
InvalidHttpResponse.__init__(self, path, msg)
1348
class RedirectRequested(TransportError):
1350
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1352
def __init__(self, source, target, is_permanent=False):
1353
self.source = source
1354
self.target = target
1356
self.permanently = ' permanently'
1358
self.permanently = ''
1359
TransportError.__init__(self)
1362
class TooManyRedirections(TransportError):
1364
_fmt = "Too many redirections"
1367
class ConflictsInTree(BzrError):
1369
_fmt = "Working tree has conflicts."
1372
class DependencyNotPresent(BzrError):
1374
_fmt = 'Unable to import library "%(library)s": %(error)s'
1376
def __init__(self, library, error):
1377
BzrError.__init__(self, library=library, error=error)
1380
class WorkingTreeNotRevision(BzrError):
1382
_fmt = ("The working tree for %(basedir)s has changed since"
1383
" the last commit, but weave merge requires that it be"
1386
def __init__(self, tree):
1387
BzrError.__init__(self, basedir=tree.basedir)
1390
class GraphCycleError(BzrError):
1392
_fmt = "Cycle in graph %(graph)r"
1394
def __init__(self, graph):
1395
BzrError.__init__(self)
1399
class WritingCompleted(InternalBzrError):
1401
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1402
"called upon it - accept bytes may not be called anymore.")
1404
def __init__(self, request):
1405
self.request = request
1408
class WritingNotComplete(InternalBzrError):
1410
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1411
"called upon it - until the write phase is complete no "
1412
"data may be read.")
1414
def __init__(self, request):
1415
self.request = request
1418
class NotConflicted(BzrError):
1420
_fmt = "File %(filename)s is not conflicted."
1422
def __init__(self, filename):
1423
BzrError.__init__(self)
1424
self.filename = filename
1427
class MediumNotConnected(InternalBzrError):
1429
_fmt = """The medium '%(medium)s' is not connected."""
1431
def __init__(self, medium):
1432
self.medium = medium
1435
class MustUseDecorated(Exception):
1437
_fmt = "A decorating function has requested its original command be used."
1440
class NoBundleFound(BzrError):
1442
_fmt = 'No bundle was found in "%(filename)s".'
1444
def __init__(self, filename):
1445
BzrError.__init__(self)
1446
self.filename = filename
1449
class BundleNotSupported(BzrError):
1451
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
1453
def __init__(self, version, msg):
1454
BzrError.__init__(self)
1455
self.version = version
1459
class MissingText(BzrError):
1461
_fmt = ("Branch %(base)s is missing revision"
1462
" %(text_revision)s of %(file_id)s")
1464
def __init__(self, branch, text_revision, file_id):
1465
BzrError.__init__(self)
1466
self.branch = branch
1467
self.base = branch.base
1468
self.text_revision = text_revision
1469
self.file_id = file_id
1472
class DuplicateKey(BzrError):
1474
_fmt = "Key %(key)s is already present in map"
1477
class DuplicateHelpPrefix(BzrError):
1479
_fmt = "The prefix %(prefix)s is in the help search path twice."
1481
def __init__(self, prefix):
1482
self.prefix = prefix
1485
class BzrBadParameter(InternalBzrError):
1487
_fmt = "Bad parameter: %(param)r"
1489
# This exception should never be thrown, but it is a base class for all
1490
# parameter-to-function errors.
1492
def __init__(self, param):
1493
BzrError.__init__(self)
1497
class BzrBadParameterNotUnicode(BzrBadParameter):
1499
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1502
class BzrMoveFailedError(BzrError):
1504
_fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1505
"%(_has_extra)s%(extra)s")
1507
def __init__(self, from_path='', to_path='', extra=None):
1508
from breezy.osutils import splitpath
1509
BzrError.__init__(self)
1511
self.extra, self._has_extra = extra, ': '
1513
self.extra = self._has_extra = ''
1515
has_from = len(from_path) > 0
1516
has_to = len(to_path) > 0
1518
self.from_path = splitpath(from_path)[-1]
1523
self.to_path = splitpath(to_path)[-1]
1528
if has_from and has_to:
1529
self.operator = " =>"
1531
self.from_path = "from " + from_path
1533
self.operator = "to"
1535
self.operator = "file"
1538
class BzrRenameFailedError(BzrMoveFailedError):
1540
_fmt = ("Could not rename %(from_path)s%(operator)s %(to_path)s"
1541
"%(_has_extra)s%(extra)s")
1543
def __init__(self, from_path, to_path, extra=None):
1544
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1547
class BzrBadParameterNotString(BzrBadParameter):
1549
_fmt = "Parameter %(param)s is not a string or unicode string."
1552
class BzrBadParameterMissing(BzrBadParameter):
1554
_fmt = "Parameter %(param)s is required but not present."
1557
class BzrBadParameterUnicode(BzrBadParameter):
1559
_fmt = ("Parameter %(param)s is unicode but"
1560
" only byte-strings are permitted.")
1563
class BzrBadParameterContainsNewline(BzrBadParameter):
1565
_fmt = "Parameter %(param)s contains a newline."
1568
class ParamikoNotPresent(DependencyNotPresent):
1570
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1572
def __init__(self, error):
1573
DependencyNotPresent.__init__(self, 'paramiko', error)
1576
class PointlessMerge(BzrError):
1578
_fmt = "Nothing to merge."
1581
class UninitializableFormat(BzrError):
1583
_fmt = "Format %(format)s cannot be initialised by this version of brz."
1585
def __init__(self, format):
1586
BzrError.__init__(self)
1587
self.format = format
1590
class BadConversionTarget(BzrError):
1592
_fmt = "Cannot convert from format %(from_format)s to format %(format)s." \
1595
def __init__(self, problem, format, from_format=None):
1596
BzrError.__init__(self)
1597
self.problem = problem
1598
self.format = format
1599
self.from_format = from_format or '(unspecified)'
1602
class NoDiffFound(BzrError):
1604
_fmt = 'Could not find an appropriate Differ for file "%(path)s"'
1606
def __init__(self, path):
1607
BzrError.__init__(self, path)
1610
class ExecutableMissing(BzrError):
1612
_fmt = "%(exe_name)s could not be found on this machine"
1614
def __init__(self, exe_name):
1615
BzrError.__init__(self, exe_name=exe_name)
1618
class NoDiff(BzrError):
1620
_fmt = "Diff is not installed on this machine: %(msg)s"
1622
def __init__(self, msg):
1623
BzrError.__init__(self, msg=msg)
1626
class NoDiff3(BzrError):
1628
_fmt = "Diff3 is not installed on this machine."
1631
class ExistingLimbo(BzrError):
1633
_fmt = """This tree contains left-over files from a failed operation.
1634
Please examine %(limbo_dir)s to see if it contains any files you wish to
1635
keep, and delete it when you are done."""
1637
def __init__(self, limbo_dir):
1638
BzrError.__init__(self)
1639
self.limbo_dir = limbo_dir
1642
class ExistingPendingDeletion(BzrError):
1644
_fmt = """This tree contains left-over files from a failed operation.
1645
Please examine %(pending_deletion)s to see if it contains any files you
1646
wish to keep, and delete it when you are done."""
1648
def __init__(self, pending_deletion):
1649
BzrError.__init__(self, pending_deletion=pending_deletion)
1652
class ImmortalPendingDeletion(BzrError):
1654
_fmt = ("Unable to delete transform temporary directory "
1655
"%(pending_deletion)s. Please examine %(pending_deletion)s to see if it "
1656
"contains any files you wish to keep, and delete it when you are done.")
1658
def __init__(self, pending_deletion):
1659
BzrError.__init__(self, pending_deletion=pending_deletion)
1662
class OutOfDateTree(BzrError):
1664
_fmt = "Working tree is out of date, please run 'brz update'.%(more)s"
1666
def __init__(self, tree, more=None):
1671
BzrError.__init__(self)
1676
class PublicBranchOutOfDate(BzrError):
1678
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1681
def __init__(self, public_location, revstring):
1682
import breezy.urlutils as urlutils
1683
public_location = urlutils.unescape_for_display(public_location,
1685
BzrError.__init__(self, public_location=public_location,
1686
revstring=revstring)
1689
class MergeModifiedFormatError(BzrError):
1691
_fmt = "Error in merge modified format"
1694
class ConflictFormatError(BzrError):
1696
_fmt = "Format error in conflict listings"
1699
class CorruptRepository(BzrError):
1701
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1702
"Please run brz reconcile on this repository.")
1704
def __init__(self, repo):
1705
BzrError.__init__(self)
1706
self.repo_path = repo.user_url
1709
class InconsistentDelta(BzrError):
1710
"""Used when we get a delta that is not valid."""
1712
_fmt = ("An inconsistent delta was supplied involving %(path)r,"
1713
" %(file_id)r\nreason: %(reason)s")
1715
def __init__(self, path, file_id, reason):
1716
BzrError.__init__(self)
1718
self.file_id = file_id
1719
self.reason = reason
1722
class InconsistentDeltaDelta(InconsistentDelta):
1723
"""Used when we get a delta that is not valid."""
1725
_fmt = ("An inconsistent delta was supplied: %(delta)r"
1726
"\nreason: %(reason)s")
1728
def __init__(self, delta, reason):
1729
BzrError.__init__(self)
1731
self.reason = reason
1734
class UpgradeRequired(BzrError):
1736
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1738
def __init__(self, path):
1739
BzrError.__init__(self)
1743
class RepositoryUpgradeRequired(UpgradeRequired):
1745
_fmt = "To use this feature you must upgrade your repository at %(path)s."
1748
class RichRootUpgradeRequired(UpgradeRequired):
1750
_fmt = ("To use this feature you must upgrade your branch at %(path)s to"
1751
" a format which supports rich roots.")
1754
class LocalRequiresBoundBranch(BzrError):
1756
_fmt = "Cannot perform local-only commits on unbound branches."
1759
class UnsupportedOperation(BzrError):
1761
_fmt = ("The method %(mname)s is not supported on"
1762
" objects of type %(tname)s.")
1764
def __init__(self, method, method_self):
1765
self.method = method
1766
self.mname = method.__name__
1767
self.tname = type(method_self).__name__
1770
class FetchLimitUnsupported(UnsupportedOperation):
1772
fmt = ("InterBranch %(interbranch)r does not support fetching limits.")
1774
def __init__(self, interbranch):
1775
BzrError.__init__(self, interbranch=interbranch)
1778
class NonAsciiRevisionId(UnsupportedOperation):
1779
"""Raised when a commit is attempting to set a non-ascii revision id
1784
class SharedRepositoriesUnsupported(UnsupportedOperation):
1785
_fmt = "Shared repositories are not supported by %(format)r."
1787
def __init__(self, format):
1788
BzrError.__init__(self, format=format)
1791
class GhostTagsNotSupported(BzrError):
1793
_fmt = "Ghost tags not supported by format %(format)r."
1795
def __init__(self, format):
1796
self.format = format
1799
class BinaryFile(BzrError):
1801
_fmt = "File is binary but should be text."
1804
class IllegalPath(BzrError):
1806
_fmt = "The path %(path)s is not permitted on this platform"
1808
def __init__(self, path):
1809
BzrError.__init__(self)
1813
class TestamentMismatch(BzrError):
1815
_fmt = """Testament did not match expected value.
1816
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1819
def __init__(self, revision_id, expected, measured):
1820
self.revision_id = revision_id
1821
self.expected = expected
1822
self.measured = measured
1825
class NotABundle(BzrError):
1827
_fmt = "Not a bzr revision-bundle: %(text)r"
1829
def __init__(self, text):
1830
BzrError.__init__(self)
1834
class BadBundle(BzrError):
1836
_fmt = "Bad bzr revision-bundle: %(text)r"
1838
def __init__(self, text):
1839
BzrError.__init__(self)
1843
class MalformedHeader(BadBundle):
1845
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1848
class MalformedPatches(BadBundle):
1850
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1853
class MalformedFooter(BadBundle):
1855
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1858
class UnsupportedEOLMarker(BadBundle):
1860
_fmt = "End of line marker was not \\n in bzr revision-bundle"
1863
# XXX: BadBundle's constructor assumes there's explanatory text,
1864
# but for this there is not
1865
BzrError.__init__(self)
1868
class IncompatibleBundleFormat(BzrError):
1870
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1872
def __init__(self, bundle_format, other):
1873
BzrError.__init__(self)
1874
self.bundle_format = bundle_format
1878
class RootNotRich(BzrError):
1880
_fmt = """This operation requires rich root data storage"""
1883
class NoSmartMedium(InternalBzrError):
1885
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1887
def __init__(self, transport):
1888
self.transport = transport
1891
class UnknownSSH(BzrError):
1893
_fmt = "Unrecognised value for BRZ_SSH environment variable: %(vendor)s"
1895
def __init__(self, vendor):
1896
BzrError.__init__(self)
1897
self.vendor = vendor
1900
class SSHVendorNotFound(BzrError):
1902
_fmt = ("Don't know how to handle SSH connections."
1903
" Please set BRZ_SSH environment variable.")
1906
class GhostRevisionsHaveNoRevno(BzrError):
1907
"""When searching for revnos, if we encounter a ghost, we are stuck"""
1909
_fmt = ("Could not determine revno for {%(revision_id)s} because"
1910
" its ancestry shows a ghost at {%(ghost_revision_id)s}")
1912
def __init__(self, revision_id, ghost_revision_id):
1913
self.revision_id = revision_id
1914
self.ghost_revision_id = ghost_revision_id
1917
class GhostRevisionUnusableHere(BzrError):
1919
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1921
def __init__(self, revision_id):
1922
BzrError.__init__(self)
1923
self.revision_id = revision_id
1926
class NotAMergeDirective(BzrError):
1927
"""File starting with %(firstline)r is not a merge directive"""
1929
def __init__(self, firstline):
1930
BzrError.__init__(self, firstline=firstline)
1933
class NoMergeSource(BzrError):
1934
"""Raise if no merge source was specified for a merge directive"""
1936
_fmt = "A merge directive must provide either a bundle or a public"\
1940
class PatchVerificationFailed(BzrError):
1941
"""A patch from a merge directive could not be verified"""
1943
_fmt = "Preview patch does not match requested changes."
1946
class PatchMissing(BzrError):
1947
"""Raise a patch type was specified but no patch supplied"""
1949
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
1951
def __init__(self, patch_type):
1952
BzrError.__init__(self)
1953
self.patch_type = patch_type
1956
class TargetNotBranch(BzrError):
1957
"""A merge directive's target branch is required, but isn't a branch"""
1959
_fmt = ("Your branch does not have all of the revisions required in "
1960
"order to merge this merge directive and the target "
1961
"location specified in the merge directive is not a branch: "
1964
def __init__(self, location):
1965
BzrError.__init__(self)
1966
self.location = location
1969
class BadSubsumeSource(BzrError):
1971
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
1973
def __init__(self, tree, other_tree, reason):
1975
self.other_tree = other_tree
1976
self.reason = reason
1979
class SubsumeTargetNeedsUpgrade(BzrError):
1981
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
1983
def __init__(self, other_tree):
1984
self.other_tree = other_tree
1987
class NoSuchTag(BzrError):
1989
_fmt = "No such tag: %(tag_name)s"
1991
def __init__(self, tag_name):
1992
self.tag_name = tag_name
1995
class TagsNotSupported(BzrError):
1997
_fmt = ("Tags not supported by %(branch)s;"
1998
" you may be able to use 'brz upgrade %(branch_url)s'.")
2000
def __init__(self, branch):
2001
self.branch = branch
2002
self.branch_url = branch.user_url
2005
class TagAlreadyExists(BzrError):
2007
_fmt = "Tag %(tag_name)s already exists."
2009
def __init__(self, tag_name):
2010
self.tag_name = tag_name
2013
class UnexpectedSmartServerResponse(BzrError):
2015
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2017
def __init__(self, response_tuple):
2018
self.response_tuple = response_tuple
2021
class ErrorFromSmartServer(BzrError):
2022
"""An error was received from a smart server.
2024
:seealso: UnknownErrorFromSmartServer
2027
_fmt = "Error received from smart server: %(error_tuple)r"
2029
internal_error = True
2031
def __init__(self, error_tuple):
2032
self.error_tuple = error_tuple
2034
self.error_verb = error_tuple[0]
2036
self.error_verb = None
2037
self.error_args = error_tuple[1:]
2040
class UnknownErrorFromSmartServer(BzrError):
2041
"""An ErrorFromSmartServer could not be translated into a typical breezy
2044
This is distinct from ErrorFromSmartServer so that it is possible to
2045
distinguish between the following two cases:
2047
- ErrorFromSmartServer was uncaught. This is logic error in the client
2048
and so should provoke a traceback to the user.
2049
- ErrorFromSmartServer was caught but its error_tuple could not be
2050
translated. This is probably because the server sent us garbage, and
2051
should not provoke a traceback.
2054
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2056
internal_error = False
2058
def __init__(self, error_from_smart_server):
2061
:param error_from_smart_server: An ErrorFromSmartServer instance.
2063
self.error_from_smart_server = error_from_smart_server
2064
self.error_tuple = error_from_smart_server.error_tuple
2067
class ContainerError(BzrError):
2068
"""Base class of container errors."""
2071
class UnknownContainerFormatError(ContainerError):
2073
_fmt = "Unrecognised container format: %(container_format)r"
2075
def __init__(self, container_format):
2076
self.container_format = container_format
2079
class UnexpectedEndOfContainerError(ContainerError):
2081
_fmt = "Unexpected end of container stream"
2084
class UnknownRecordTypeError(ContainerError):
2086
_fmt = "Unknown record type: %(record_type)r"
2088
def __init__(self, record_type):
2089
self.record_type = record_type
2092
class InvalidRecordError(ContainerError):
2094
_fmt = "Invalid record: %(reason)s"
2096
def __init__(self, reason):
2097
self.reason = reason
2100
class ContainerHasExcessDataError(ContainerError):
2102
_fmt = "Container has data after end marker: %(excess)r"
2104
def __init__(self, excess):
2105
self.excess = excess
2108
class DuplicateRecordNameError(ContainerError):
2110
_fmt = "Container has multiple records with the same name: %(name)s"
2112
def __init__(self, name):
2113
self.name = name.decode("utf-8")
2116
class RepositoryDataStreamError(BzrError):
2118
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2120
def __init__(self, reason):
2121
self.reason = reason
2124
class UncommittedChanges(BzrError):
2126
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2127
' (See brz status).%(more)s')
2129
def __init__(self, tree, more=None):
2134
import breezy.urlutils as urlutils
2135
user_url = getattr(tree, "user_url", None)
2136
if user_url is None:
2137
display_url = str(tree)
2139
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2140
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2143
class StoringUncommittedNotSupported(BzrError):
2145
_fmt = ('Branch "%(display_url)s" does not support storing uncommitted'
2148
def __init__(self, branch):
2149
import breezy.urlutils as urlutils
2150
user_url = getattr(branch, "user_url", None)
2151
if user_url is None:
2152
display_url = str(branch)
2154
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2155
BzrError.__init__(self, branch=branch, display_url=display_url)
2158
class ShelvedChanges(UncommittedChanges):
2160
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2161
' (See brz shelve --list).%(more)s')
2164
class UnableEncodePath(BzrError):
2166
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2167
'user encoding %(user_encoding)s')
2169
def __init__(self, path, kind):
2170
from breezy.osutils import get_user_encoding
2173
self.user_encoding = get_user_encoding()
2176
class NoSuchAlias(BzrError):
2178
_fmt = ('The alias "%(alias_name)s" does not exist.')
2180
def __init__(self, alias_name):
2181
BzrError.__init__(self, alias_name=alias_name)
2184
class CannotBindAddress(BzrError):
2186
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2188
def __init__(self, host, port, orig_error):
2189
# nb: in python2.4 socket.error doesn't have a useful repr
2190
BzrError.__init__(self, host=host, port=port,
2191
orig_error=repr(orig_error.args))
2194
class TipChangeRejected(BzrError):
2195
"""A pre_change_branch_tip hook function may raise this to cleanly and
2196
explicitly abort a change to a branch tip.
2199
_fmt = u"Tip change rejected: %(msg)s"
2201
def __init__(self, msg):
2205
class JailBreak(BzrError):
2207
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2209
def __init__(self, url):
2210
BzrError.__init__(self, url=url)
2213
class UserAbort(BzrError):
2215
_fmt = 'The user aborted the operation.'
2218
class UnresumableWriteGroup(BzrError):
2220
_fmt = ("Repository %(repository)s cannot resume write group "
2221
"%(write_groups)r: %(reason)s")
2223
internal_error = True
2225
def __init__(self, repository, write_groups, reason):
2226
self.repository = repository
2227
self.write_groups = write_groups
2228
self.reason = reason
2231
class UnsuspendableWriteGroup(BzrError):
2233
_fmt = ("Repository %(repository)s cannot suspend a write group.")
2235
internal_error = True
2237
def __init__(self, repository):
2238
self.repository = repository
2241
class LossyPushToSameVCS(BzrError):
2243
_fmt = ("Lossy push not possible between %(source_branch)r and "
2244
"%(target_branch)r that are in the same VCS.")
2246
internal_error = True
2248
def __init__(self, source_branch, target_branch):
2249
self.source_branch = source_branch
2250
self.target_branch = target_branch
2253
class NoRoundtrippingSupport(BzrError):
2255
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
2256
"%(target_branch)r.")
2258
internal_error = True
2260
def __init__(self, source_branch, target_branch):
2261
self.source_branch = source_branch
2262
self.target_branch = target_branch
2265
class NoColocatedBranchSupport(BzrError):
2267
_fmt = ("%(controldir)r does not support co-located branches.")
2269
def __init__(self, controldir):
2270
self.controldir = controldir
2273
class RecursiveBind(BzrError):
2275
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2276
'Please use `brz unbind` to fix.')
2278
def __init__(self, branch_url):
2279
self.branch_url = branch_url
2282
class UnsupportedKindChange(BzrError):
2284
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2285
"%(path)s not supported by format %(format)r")
2287
def __init__(self, path, from_kind, to_kind, format):
2289
self.from_kind = from_kind
2290
self.to_kind = to_kind
2291
self.format = format
2294
class ChangesAlreadyStored(CommandError):
2296
_fmt = ('Cannot store uncommitted changes because this branch already'
2297
' stores uncommitted changes.')
2300
class RevnoOutOfBounds(InternalBzrError):
2302
_fmt = ("The requested revision number %(revno)d is outside of the "
2303
"expected boundaries (%(minimum)d <= %(maximum)d).")
2305
def __init__(self, revno, bounds):
2306
InternalBzrError.__init__(
2307
self, revno=revno, minimum=bounds[0], maximum=bounds[1])