1
# Copyright (C) 2005, 2006 Canonical
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Exceptions for bzr, and reporting of them.
19
There are 3 different classes of error:
21
* KeyboardInterrupt, and OSError with EPIPE - the program terminates
22
with an appropriate short message
24
* User errors, indicating a problem caused by the user such as a bad URL.
25
These are printed in a short form.
27
* Internal unexpected errors, including most Python builtin errors
28
and some raised from inside bzr. These are printed with a full
29
traceback and an invitation to report the bug.
31
Exceptions are caught at a high level to report errors to the user, and
32
might also be caught inside the program. Therefore it needs to be
33
possible to convert them to a meaningful string, and also for them to be
34
interrogated by the program.
36
Exceptions are defined such that the arguments given to the constructor
37
are stored in the object as properties of the same name. When the
38
object is printed as a string, the doc string of the class is used as
39
a format string with the property dictionary available to it.
41
This means that exceptions can used like this:
45
... raise NotBranchError(path='/foo/bar')
47
... print sys.exc_type
48
... print sys.exc_value
49
... path = getattr(sys.exc_value, 'path', None)
50
... if path is not None:
52
bzrlib.errors.NotBranchError
53
Not a branch: /foo/bar
58
* create a new exception class for any class of error that can be
59
usefully distinguished. If no callers are likely to want to catch
60
one but not another, don't worry about them.
62
* the __str__ method should generate something useful; BzrError provides
63
a good default implementation
65
Exception strings should start with a capital letter and should not have a
69
from warnings import warn
71
from bzrlib.patches import (PatchSyntax,
78
# based on Scott James Remnant's hct error classes
80
# TODO: is there any value in providing the .args field used by standard
81
# python exceptions? A list of values with no names seems less useful
84
# TODO: Perhaps convert the exception to a string at the moment it's
85
# constructed to make sure it will succeed. But that says nothing about
86
# exceptions that are never raised.
88
# TODO: Convert all the other error classes here to BzrNewError, and eliminate
91
# TODO: The pattern (from hct) of using classes docstrings as message
92
# templates is cute but maybe not such a great idea - perhaps should have a
93
# separate static message_template.
96
class BzrError(StandardError):
101
# XXX: Should we show the exception class in
102
# exceptions that don't provide their own message?
103
# maybe it should be done at a higher level
104
## n = self.__class__.__name__ + ': '
106
if len(self.args) == 1:
107
return str(self.args[0])
108
elif len(self.args) == 2:
109
# further explanation or suggestions
111
return n + '\n '.join([self.args[0]] + self.args[1])
113
return n + "%r" % self
115
return n + `self.args`
118
class BzrNewError(BzrError):
120
# base classes should override the docstring with their human-
121
# readable explanation
123
def __init__(self, **kwds):
124
for key, value in kwds.items():
125
setattr(self, key, value)
129
# __str__() should always return a 'str' object
130
# never a 'unicode' object.
131
s = self.__doc__ % self.__dict__
132
if isinstance(s, unicode):
133
return s.encode('utf8')
135
except (NameError, ValueError, KeyError), e:
136
return 'Unprintable exception %s: %s' \
137
% (self.__class__.__name__, str(e))
140
class BzrCheckError(BzrNewError):
141
"""Internal check failed: %(message)s"""
143
is_user_error = False
145
def __init__(self, message):
146
BzrNewError.__init__(self)
147
self.message = message
150
class InvalidEntryName(BzrNewError):
151
"""Invalid entry name: %(name)s"""
153
is_user_error = False
155
def __init__(self, name):
156
BzrNewError.__init__(self)
160
class InvalidRevisionNumber(BzrNewError):
161
"""Invalid revision number %(revno)d"""
162
def __init__(self, revno):
163
BzrNewError.__init__(self)
167
class InvalidRevisionId(BzrNewError):
168
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
170
def __init__(self, revision_id, branch):
171
# branch can be any string or object with __str__ defined
172
BzrNewError.__init__(self)
173
self.revision_id = revision_id
177
class NoWorkingTree(BzrNewError):
178
"""No WorkingTree exists for %(base)s."""
180
def __init__(self, base):
181
BzrNewError.__init__(self)
185
class NotLocalUrl(BzrNewError):
186
"""%(url)s is not a local path."""
188
def __init__(self, url):
189
BzrNewError.__init__(self)
193
class BzrCommandError(BzrNewError):
194
"""Error from user command"""
198
# Error from malformed user command; please avoid raising this as a
199
# generic exception not caused by user input.
201
# I think it's a waste of effort to differentiate between errors that
202
# are not intended to be caught anyway. UI code need not subclass
203
# BzrCommandError, and non-UI code should not throw a subclass of
204
# BzrCommandError. ADHB 20051211
205
def __init__(self, msg):
206
# Object.__str__() must return a real string
207
# returning a Unicode string is a python error.
208
if isinstance(msg, unicode):
209
self.msg = msg.encode('utf8')
217
class BzrOptionError(BzrCommandError):
218
"""Error in command line options"""
221
class StrictCommitFailed(BzrNewError):
222
"""Commit refused because there are unknown files in the tree"""
225
# XXX: Should be unified with TransportError; they seem to represent the
227
class PathError(BzrNewError):
228
"""Generic path error: %(path)r%(extra)s)"""
230
def __init__(self, path, extra=None):
231
BzrNewError.__init__(self)
234
self.extra = ': ' + str(extra)
239
class NoSuchFile(PathError):
240
"""No such file: %(path)r%(extra)s"""
243
class FileExists(PathError):
244
"""File exists: %(path)r%(extra)s"""
247
class DirectoryNotEmpty(PathError):
248
"""Directory not empty: %(path)r%(extra)s"""
251
class ResourceBusy(PathError):
252
"""Device or resource busy: %(path)r%(extra)s"""
255
class PermissionDenied(PathError):
256
"""Permission denied: %(path)r%(extra)s"""
259
class InvalidURL(PathError):
260
"""Invalid url supplied to transport: %(path)r%(extra)s"""
263
class InvalidURLJoin(PathError):
264
"""Invalid URL join request: %(args)s%(extra)s"""
266
def __init__(self, msg, base, args):
267
PathError.__init__(self, base, msg)
269
self.args.extend(args)
272
class UnsupportedProtocol(PathError):
273
"""Unsupported protocol for url "%(path)s"%(extra)s"""
275
def __init__(self, url, extra):
276
PathError.__init__(self, url, extra=extra)
279
class PathNotChild(BzrNewError):
280
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
282
is_user_error = False
284
def __init__(self, path, base, extra=None):
285
BzrNewError.__init__(self)
289
self.extra = ': ' + str(extra)
294
class InvalidNormalization(PathError):
295
"""Path %(path)r is not unicode normalized"""
298
# TODO: This is given a URL; we try to unescape it but doing that from inside
299
# the exception object is a bit undesirable.
300
# TODO: Probably this behavior of should be a common superclass
301
class NotBranchError(PathError):
302
"""Not a branch: %(path)s"""
304
def __init__(self, path):
305
import bzrlib.urlutils as urlutils
306
self.path = urlutils.unescape_for_display(path, 'ascii')
309
class AlreadyBranchError(PathError):
310
"""Already a branch: %(path)s."""
313
class BranchExistsWithoutWorkingTree(PathError):
314
"""Directory contains a branch, but no working tree \
315
(use bzr checkout if you wish to build a working tree): %(path)s"""
318
class AtomicFileAlreadyClosed(PathError):
319
"""'%(function)s' called on an AtomicFile after it was closed: %(path)s"""
321
def __init__(self, path, function):
322
PathError.__init__(self, path=path, extra=None)
323
self.function = function
326
class InaccessibleParent(PathError):
327
"""Parent not accessible given base %(base)s and relative path %(path)s"""
329
def __init__(self, path, base):
330
PathError.__init__(self, path)
334
class NoRepositoryPresent(BzrNewError):
335
"""No repository present: %(path)r"""
336
def __init__(self, bzrdir):
337
BzrNewError.__init__(self)
338
self.path = bzrdir.transport.clone('..').base
341
class FileInWrongBranch(BzrNewError):
342
"""File %(path)s in not in branch %(branch_base)s."""
344
def __init__(self, branch, path):
345
BzrNewError.__init__(self)
347
self.branch_base = branch.base
351
class UnsupportedFormatError(BzrNewError):
352
"""Unsupported branch format: %(format)s"""
355
class UnknownFormatError(BzrNewError):
356
"""Unknown branch format: %(format)r"""
359
class IncompatibleFormat(BzrNewError):
360
"""Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
362
def __init__(self, format, bzrdir_format):
363
BzrNewError.__init__(self)
365
self.bzrdir = bzrdir_format
368
class NotVersionedError(BzrNewError):
369
"""%(path)s is not versioned"""
370
def __init__(self, path):
371
BzrNewError.__init__(self)
375
class PathsNotVersionedError(BzrNewError):
376
# used when reporting several paths are not versioned
377
"""Path(s) are not versioned: %(paths_as_string)s"""
379
def __init__(self, paths):
380
from bzrlib.osutils import quotefn
381
BzrNewError.__init__(self)
383
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
386
class PathsDoNotExist(BzrNewError):
387
"""Path(s) do not exist: %(paths_as_string)s"""
389
# used when reporting that paths are neither versioned nor in the working
392
def __init__(self, paths):
394
from bzrlib.osutils import quotefn
395
BzrNewError.__init__(self)
397
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
400
class BadFileKindError(BzrNewError):
401
"""Cannot operate on %(filename)s of unsupported kind %(kind)s"""
404
class ForbiddenControlFileError(BzrNewError):
405
"""Cannot operate on %(filename)s because it is a control file"""
408
class LockError(BzrNewError):
409
"""Lock error: %(message)s"""
410
# All exceptions from the lock/unlock functions should be from
411
# this exception class. They will be translated as necessary. The
412
# original exception is available as e.original_error
414
# New code should prefer to raise specific subclasses
415
def __init__(self, message):
416
self.message = message
419
class CommitNotPossible(LockError):
420
"""A commit was attempted but we do not have a write lock open."""
425
class AlreadyCommitted(LockError):
426
"""A rollback was requested, but is not able to be accomplished."""
431
class ReadOnlyError(LockError):
432
"""A write attempt was made in a read only transaction on %(obj)s"""
433
def __init__(self, obj):
437
class OutSideTransaction(BzrNewError):
438
"""A transaction related operation was attempted after the transaction finished."""
441
class ObjectNotLocked(LockError):
442
"""%(obj)r is not locked"""
444
is_user_error = False
446
# this can indicate that any particular object is not locked; see also
447
# LockNotHeld which means that a particular *lock* object is not held by
448
# the caller -- perhaps they should be unified.
449
def __init__(self, obj):
453
class ReadOnlyObjectDirtiedError(ReadOnlyError):
454
"""Cannot change object %(obj)r in read only transaction"""
455
def __init__(self, obj):
459
class UnlockableTransport(LockError):
460
"""Cannot lock: transport is read only: %(transport)s"""
461
def __init__(self, transport):
462
self.transport = transport
465
class LockContention(LockError):
466
"""Could not acquire lock %(lock)s"""
467
# TODO: show full url for lock, combining the transport and relative bits?
468
def __init__(self, lock):
472
class LockBroken(LockError):
473
"""Lock was broken while still open: %(lock)s - check storage consistency!"""
474
def __init__(self, lock):
478
class LockBreakMismatch(LockError):
479
"""Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"""
480
def __init__(self, lock, holder, target):
486
class LockNotHeld(LockError):
487
"""Lock not held: %(lock)s"""
488
def __init__(self, lock):
492
class PointlessCommit(BzrNewError):
493
"""No changes to commit"""
496
class UpgradeReadonly(BzrNewError):
497
"""Upgrade URL cannot work with readonly URL's."""
500
class UpToDateFormat(BzrNewError):
501
"""The branch format %(format)s is already at the most recent format."""
503
def __init__(self, format):
504
BzrNewError.__init__(self)
509
class StrictCommitFailed(Exception):
510
"""Commit refused because there are unknowns in the tree."""
513
class NoSuchRevision(BzrNewError):
514
"""Branch %(branch)s has no revision %(revision)s"""
516
is_user_error = False
518
def __init__(self, branch, revision):
520
self.revision = revision
523
class HistoryMissing(BzrError):
524
def __init__(self, branch, object_type, object_id):
526
BzrError.__init__(self,
527
'%s is missing %s {%s}'
528
% (branch, object_type, object_id))
531
class DivergedBranches(BzrNewError):
532
"These branches have diverged. Use the merge command to reconcile them."""
536
def __init__(self, branch1, branch2):
537
self.branch1 = branch1
538
self.branch2 = branch2
541
class UnrelatedBranches(BzrNewError):
542
"Branches have no common ancestor, and no merge base revision was specified."
547
class NoCommonAncestor(BzrNewError):
548
"Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
550
def __init__(self, revision_a, revision_b):
551
self.revision_a = revision_a
552
self.revision_b = revision_b
555
class NoCommonRoot(BzrError):
556
def __init__(self, revision_a, revision_b):
557
msg = "Revisions are not derived from the same root: %s %s." \
558
% (revision_a, revision_b)
559
BzrError.__init__(self, msg)
563
class NotAncestor(BzrError):
564
def __init__(self, rev_id, not_ancestor_id):
565
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
567
BzrError.__init__(self, msg)
569
self.not_ancestor_id = not_ancestor_id
572
class InstallFailed(BzrError):
573
def __init__(self, revisions):
574
msg = "Could not install revisions:\n%s" % " ,".join(revisions)
575
BzrError.__init__(self, msg)
576
self.revisions = revisions
579
class AmbiguousBase(BzrError):
580
def __init__(self, bases):
581
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
583
msg = "The correct base is unclear, because %s are all equally close" %\
585
BzrError.__init__(self, msg)
589
class NoCommits(BzrError):
590
def __init__(self, branch):
591
msg = "Branch %s has no commits." % branch
592
BzrError.__init__(self, msg)
595
class UnlistableStore(BzrError):
596
def __init__(self, store):
597
BzrError.__init__(self, "Store %s is not listable" % store)
601
class UnlistableBranch(BzrError):
602
def __init__(self, br):
603
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
606
class BoundBranchOutOfDate(BzrNewError):
607
"""Bound branch %(branch)s is out of date with master branch %(master)s."""
608
def __init__(self, branch, master):
609
BzrNewError.__init__(self)
614
class CommitToDoubleBoundBranch(BzrNewError):
615
"""Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."""
616
def __init__(self, branch, master, remote):
617
BzrNewError.__init__(self)
623
class OverwriteBoundBranch(BzrNewError):
624
"""Cannot pull --overwrite to a branch which is bound %(branch)s"""
625
def __init__(self, branch):
626
BzrNewError.__init__(self)
630
class BoundBranchConnectionFailure(BzrNewError):
631
"""Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"""
632
def __init__(self, branch, target, error):
633
BzrNewError.__init__(self)
639
class WeaveError(BzrNewError):
640
"""Error in processing weave: %(message)s"""
642
def __init__(self, message=None):
643
BzrNewError.__init__(self)
644
self.message = message
647
class WeaveRevisionAlreadyPresent(WeaveError):
648
"""Revision {%(revision_id)s} already present in %(weave)s"""
649
def __init__(self, revision_id, weave):
651
WeaveError.__init__(self)
652
self.revision_id = revision_id
656
class WeaveRevisionNotPresent(WeaveError):
657
"""Revision {%(revision_id)s} not present in %(weave)s"""
659
def __init__(self, revision_id, weave):
660
WeaveError.__init__(self)
661
self.revision_id = revision_id
665
class WeaveFormatError(WeaveError):
666
"""Weave invariant violated: %(what)s"""
668
def __init__(self, what):
669
WeaveError.__init__(self)
673
class WeaveParentMismatch(WeaveError):
674
"""Parents are mismatched between two revisions."""
677
class WeaveInvalidChecksum(WeaveError):
678
"""Text did not match it's checksum: %(message)s"""
681
class WeaveTextDiffers(WeaveError):
682
"""Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
684
def __init__(self, revision_id, weave_a, weave_b):
685
WeaveError.__init__(self)
686
self.revision_id = revision_id
687
self.weave_a = weave_a
688
self.weave_b = weave_b
691
class WeaveTextDiffers(WeaveError):
692
"""Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
694
def __init__(self, revision_id, weave_a, weave_b):
695
WeaveError.__init__(self)
696
self.revision_id = revision_id
697
self.weave_a = weave_a
698
self.weave_b = weave_b
701
class VersionedFileError(BzrNewError):
702
"""Versioned file error."""
705
class RevisionNotPresent(VersionedFileError):
706
"""Revision {%(revision_id)s} not present in %(file_id)s."""
708
def __init__(self, revision_id, file_id):
709
VersionedFileError.__init__(self)
710
self.revision_id = revision_id
711
self.file_id = file_id
714
class RevisionAlreadyPresent(VersionedFileError):
715
"""Revision {%(revision_id)s} already present in %(file_id)s."""
717
def __init__(self, revision_id, file_id):
718
VersionedFileError.__init__(self)
719
self.revision_id = revision_id
720
self.file_id = file_id
723
class KnitError(BzrNewError):
727
class KnitHeaderError(KnitError):
728
"""Knit header error: %(badline)r unexpected"""
730
def __init__(self, badline):
731
KnitError.__init__(self)
732
self.badline = badline
735
class KnitCorrupt(KnitError):
736
"""Knit %(filename)s corrupt: %(how)s"""
738
def __init__(self, filename, how):
739
KnitError.__init__(self)
740
self.filename = filename
744
class NoSuchExportFormat(BzrNewError):
745
"""Export format %(format)r not supported"""
746
def __init__(self, format):
747
BzrNewError.__init__(self)
751
class TransportError(BzrNewError):
752
"""Transport error: %(msg)s %(orig_error)s"""
754
def __init__(self, msg=None, orig_error=None):
755
if msg is None and orig_error is not None:
756
msg = str(orig_error)
757
if orig_error is None:
762
self.orig_error = orig_error
763
BzrNewError.__init__(self)
766
# A set of semi-meaningful errors which can be thrown
767
class TransportNotPossible(TransportError):
768
"""Transport operation not possible: %(msg)s %(orig_error)%"""
771
class ConnectionError(TransportError):
772
"""Connection error: %(msg)s %(orig_error)s"""
775
class ConnectionReset(TransportError):
776
"""Connection closed: %(msg)s %(orig_error)s"""
779
class InvalidRange(TransportError):
780
"""Invalid range access."""
782
def __init__(self, path, offset):
783
TransportError.__init__(self, ("Invalid range access in %s at %d"
787
class InvalidHttpResponse(TransportError):
788
"""Invalid http response for %(path)s: %(msg)s"""
790
def __init__(self, path, msg, orig_error=None):
792
TransportError.__init__(self, msg, orig_error=orig_error)
795
class InvalidHttpRange(InvalidHttpResponse):
796
"""Invalid http range "%(range)s" for %(path)s: %(msg)s"""
798
def __init__(self, path, range, msg):
800
InvalidHttpResponse.__init__(self, path, msg)
803
class InvalidHttpContentType(InvalidHttpResponse):
804
"""Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s"""
806
def __init__(self, path, ctype, msg):
808
InvalidHttpResponse.__init__(self, path, msg)
811
class ConflictsInTree(BzrError):
813
BzrError.__init__(self, "Working tree has conflicts.")
816
class ParseConfigError(BzrError):
817
def __init__(self, errors, filename):
820
message = "Error(s) parsing config file %s:\n%s" % \
821
(filename, ('\n'.join(e.message for e in errors)))
822
BzrError.__init__(self, message)
825
class SigningFailed(BzrError):
826
def __init__(self, command_line):
827
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
831
class WorkingTreeNotRevision(BzrError):
832
def __init__(self, tree):
833
BzrError.__init__(self, "The working tree for %s has changed since"
834
" last commit, but weave merge requires that it be"
835
" unchanged." % tree.basedir)
838
class CantReprocessAndShowBase(BzrNewError):
839
"""Can't reprocess and show base.
840
Reprocessing obscures relationship of conflicting lines to base."""
843
class GraphCycleError(BzrNewError):
844
"""Cycle in graph %(graph)r"""
845
def __init__(self, graph):
846
BzrNewError.__init__(self)
850
class NotConflicted(BzrNewError):
851
"""File %(filename)s is not conflicted."""
853
def __init__(self, filename):
854
BzrNewError.__init__(self)
855
self.filename = filename
858
class MustUseDecorated(Exception):
859
"""A decorating function has requested its original command be used.
861
This should never escape bzr, so does not need to be printable.
865
class NoBundleFound(BzrNewError):
866
"""No bundle was found in %(filename)s"""
867
def __init__(self, filename):
868
BzrNewError.__init__(self)
869
self.filename = filename
872
class BundleNotSupported(BzrNewError):
873
"""Unable to handle bundle version %(version)s: %(msg)s"""
874
def __init__(self, version, msg):
875
BzrNewError.__init__(self)
876
self.version = version
880
class MissingText(BzrNewError):
881
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
883
def __init__(self, branch, text_revision, file_id):
884
BzrNewError.__init__(self)
886
self.base = branch.base
887
self.text_revision = text_revision
888
self.file_id = file_id
891
class DuplicateKey(BzrNewError):
892
"""Key %(key)s is already present in map"""
895
class MalformedTransform(BzrNewError):
896
"""Tree transform is malformed %(conflicts)r"""
899
class BzrBadParameter(BzrNewError):
900
"""A bad parameter : %(param)s is not usable.
902
This exception should never be thrown, but it is a base class for all
903
parameter-to-function errors.
905
def __init__(self, param):
906
BzrNewError.__init__(self)
910
class BzrBadParameterNotUnicode(BzrBadParameter):
911
"""Parameter %(param)s is neither unicode nor utf8."""
914
class ReusingTransform(BzrNewError):
915
"""Attempt to reuse a transform that has already been applied."""
918
class CantMoveRoot(BzrNewError):
919
"""Moving the root directory is not supported at this time"""
922
class BzrBadParameterNotString(BzrBadParameter):
923
"""Parameter %(param)s is not a string or unicode string."""
926
class BzrBadParameterMissing(BzrBadParameter):
927
"""Parameter $(param)s is required but not present."""
930
class BzrBadParameterUnicode(BzrBadParameter):
931
"""Parameter %(param)s is unicode but only byte-strings are permitted."""
934
class BzrBadParameterContainsNewline(BzrBadParameter):
935
"""Parameter %(param)s contains a newline."""
938
class DependencyNotPresent(BzrNewError):
939
"""Unable to import library "%(library)s": %(error)s"""
941
def __init__(self, library, error):
942
BzrNewError.__init__(self, library=library, error=error)
945
class ParamikoNotPresent(DependencyNotPresent):
946
"""Unable to import paramiko (required for sftp support): %(error)s"""
948
def __init__(self, error):
949
DependencyNotPresent.__init__(self, 'paramiko', error)
952
class UninitializableFormat(BzrNewError):
953
"""Format %(format)s cannot be initialised by this version of bzr."""
955
def __init__(self, format):
956
BzrNewError.__init__(self)
960
class NoDiff(BzrNewError):
961
"""Diff is not installed on this machine: %(msg)s"""
963
def __init__(self, msg):
964
BzrNewError.__init__(self, msg=msg)
967
class NoDiff3(BzrNewError):
968
"""Diff3 is not installed on this machine."""
971
class ExistingLimbo(BzrNewError):
972
"""This tree contains left-over files from a failed operation.
973
Please examine %(limbo_dir)s to see if it contains any files you wish to
974
keep, and delete it when you are done.
976
def __init__(self, limbo_dir):
977
BzrNewError.__init__(self)
978
self.limbo_dir = limbo_dir
981
class ImmortalLimbo(BzrNewError):
982
"""Unable to delete transform temporary directory $(limbo_dir)s.
983
Please examine %(limbo_dir)s to see if it contains any files you wish to
984
keep, and delete it when you are done.
986
def __init__(self, limbo_dir):
987
BzrNewError.__init__(self)
988
self.limbo_dir = limbo_dir
991
class OutOfDateTree(BzrNewError):
992
"""Working tree is out of date, please run 'bzr update'."""
994
def __init__(self, tree):
995
BzrNewError.__init__(self)
999
class MergeModifiedFormatError(BzrNewError):
1000
"""Error in merge modified format"""
1003
class ConflictFormatError(BzrNewError):
1004
"""Format error in conflict listings"""
1007
class CorruptRepository(BzrNewError):
1008
"""An error has been detected in the repository %(repo_path)s.
1009
Please run bzr reconcile on this repository."""
1011
def __init__(self, repo):
1012
BzrNewError.__init__(self)
1013
self.repo_path = repo.bzrdir.root_transport.base
1016
class UpgradeRequired(BzrNewError):
1017
"""To use this feature you must upgrade your branch at %(path)s."""
1019
def __init__(self, path):
1020
BzrNewError.__init__(self)
1024
class LocalRequiresBoundBranch(BzrNewError):
1025
"""Cannot perform local-only commits on unbound branches."""
1028
class MissingProgressBarFinish(BzrNewError):
1029
"""A nested progress bar was not 'finished' correctly."""
1032
class InvalidProgressBarType(BzrNewError):
1033
"""Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1034
Select one of: %(valid_types)s"""
1036
def __init__(self, bar_type, valid_types):
1037
BzrNewError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1040
class UnsupportedOperation(BzrNewError):
1041
"""The method %(mname)s is not supported on objects of type %(tname)s."""
1042
def __init__(self, method, method_self):
1043
self.method = method
1044
self.mname = method.__name__
1045
self.tname = type(method_self).__name__
1048
class BinaryFile(BzrNewError):
1049
"""File is binary but should be text."""
1052
class IllegalPath(BzrNewError):
1053
"""The path %(path)s is not permitted on this platform"""
1055
def __init__(self, path):
1056
BzrNewError.__init__(self)
1060
class TestamentMismatch(BzrNewError):
1061
"""Testament did not match expected value.
1062
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1065
def __init__(self, revision_id, expected, measured):
1066
self.revision_id = revision_id
1067
self.expected = expected
1068
self.measured = measured
1071
class NotABundle(BzrNewError):
1072
"""Not a bzr revision-bundle: %(text)r"""
1074
def __init__(self, text):
1075
BzrNewError.__init__(self)
1079
class BadBundle(BzrNewError):
1080
"""Bad bzr revision-bundle: %(text)r"""
1082
def __init__(self, text):
1083
BzrNewError.__init__(self)
1087
class MalformedHeader(BadBundle):
1088
"""Malformed bzr revision-bundle header: %(text)r"""
1090
def __init__(self, text):
1091
BzrNewError.__init__(self)
1095
class MalformedPatches(BadBundle):
1096
"""Malformed patches in bzr revision-bundle: %(text)r"""
1098
def __init__(self, text):
1099
BzrNewError.__init__(self)
1103
class MalformedFooter(BadBundle):
1104
"""Malformed footer in bzr revision-bundle: %(text)r"""
1106
def __init__(self, text):
1107
BzrNewError.__init__(self)
1111
class UnsupportedEOLMarker(BadBundle):
1112
"""End of line marker was not \\n in bzr revision-bundle"""
1115
BzrNewError.__init__(self)
1118
class UnknownSSH(BzrNewError):
1119
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1121
def __init__(self, vendor):
1122
BzrNewError.__init__(self)
1123
self.vendor = vendor
1126
class GhostRevisionUnusableHere(BzrNewError):
1127
"""Ghost revision {%(revision_id)s} cannot be used here."""
1129
def __init__(self, revision_id):
1130
BzrNewError.__init__(self)
1131
self.revision_id = revision_id