132
132
# readable explanation
134
134
def __init__(self, *args, **kwds):
135
# XXX: Use the underlying BzrError to always generate the args attribute
136
# if it doesn't exist. We can't use super here, because exceptions are
137
# old-style classes in python2.4 (but new in 2.5). --bmc, 20060426
135
# XXX: Use the underlying BzrError to always generate the args
136
# attribute if it doesn't exist. We can't use super here, because
137
# exceptions are old-style classes in python2.4 (but new in 2.5).
138
139
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
139
'please convert %s to use BzrError instead'
140
'please convert %s to use BzrError instead'
140
141
% self.__class__.__name__,
141
142
DeprecationWarning,
469
471
self.path = urlutils.unescape_for_display(path, 'ascii')
474
class NoSubmitBranch(PathError):
476
_fmt = 'No submit branch available for branch "%(path)s"'
478
def __init__(self, branch):
479
import bzrlib.urlutils as urlutils
480
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
472
483
class AlreadyBranchError(PathError):
474
485
_fmt = "Already a branch: %(path)s."
483
494
class AtomicFileAlreadyClosed(PathError):
485
_fmt = "'%(function)s' called on an AtomicFile after it was closed: %(path)s"
496
_fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
487
499
def __init__(self, path, function):
488
500
PathError.__init__(self, path=path, extra=None)
492
504
class InaccessibleParent(PathError):
494
_fmt = "Parent not accessible given base %(base)s and relative path %(path)s"
506
_fmt = ("Parent not accessible given base %(base)s and"
507
" relative path %(path)s")
496
509
def __init__(self, path, base):
497
510
PathError.__init__(self, path)
552
565
_fmt = "%(context_info)s%(path)s is already versioned"
554
567
def __init__(self, path, context_info=None):
555
"""Construct a new NotVersionedError.
568
"""Construct a new AlreadyVersionedError.
557
570
:param path: This is the path which is versioned,
558
571
which should be in a user friendly form.
622
635
class BadFileKindError(BzrError):
624
_fmt = "Cannot operate on %(filename)s of unsupported kind %(kind)s"
637
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
639
def __init__(self, filename, kind):
640
BzrError.__init__(self, filename=filename, kind=kind)
627
643
class ForbiddenControlFileError(BzrError):
642
658
# New code should prefer to raise specific subclasses
643
659
def __init__(self, message):
644
self.message = message
660
# Python 2.5 uses a slot for StandardError.message,
661
# so use a different variable name
662
# so it is exposed in self.__dict__
666
class LockActive(LockError):
668
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
670
internal_error = False
672
def __init__(self, lock_description):
673
self.lock_description = lock_description
647
676
class CommitNotPossible(LockError):
665
694
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
696
# TODO: There should also be an error indicating that you need a write
697
# lock and don't have any lock at all... mbp 20070226
667
699
def __init__(self, obj):
703
class ReadOnlyLockError(LockError):
705
_fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
707
def __init__(self, fname, msg):
708
LockError.__init__(self, '')
671
713
class OutSideTransaction(BzrError):
673
_fmt = "A transaction related operation was attempted after the transaction finished."
715
_fmt = ("A transaction related operation was attempted after"
716
" the transaction finished.")
676
719
class ObjectNotLocked(LockError):
799
844
BzrError.__init__(self, branch=branch, revision=revision)
847
class NotLeftParentDescendant(BzrError):
849
_fmt = ("Revision %(old_revision)s is not the left parent of"
850
" %(new_revision)s, but branch %(branch_location)s expects this")
852
internal_error = True
854
def __init__(self, branch, old_revision, new_revision):
855
BzrError.__init__(self, branch_location=branch.base,
856
old_revision=old_revision,
857
new_revision=new_revision)
802
860
class NoSuchRevisionSpec(BzrError):
804
862
_fmt = "No namespace registered for string: %(spec)r"
807
865
BzrError.__init__(self, spec=spec)
868
class NoSuchRevisionInTree(NoSuchRevision):
869
"""When using Tree.revision_tree, and the revision is not accessible."""
871
_fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
873
def __init__(self, tree, revision_id):
874
BzrError.__init__(self)
876
self.revision_id = revision_id
810
879
class InvalidRevisionSpec(BzrError):
812
_fmt = "Requested revision: %(spec)r does not exist in branch: %(branch)s%(extra)s"
881
_fmt = ("Requested revision: %(spec)r does not exist in branch:"
882
" %(branch)s%(extra)s")
814
884
def __init__(self, spec, branch, extra=None):
815
885
BzrError.__init__(self, branch=branch, spec=spec)
824
894
_fmt = "%(branch)s is missing %(object_type)s {%(object_id)s}"
897
class AppendRevisionsOnlyViolation(BzrError):
899
_fmt = ('Operation denied because it would change the main history,'
900
' which is not permitted by the append_revisions_only setting on'
901
' branch "%(location)s".')
903
def __init__(self, location):
904
import bzrlib.urlutils as urlutils
905
location = urlutils.unescape_for_display(location, 'ascii')
906
BzrError.__init__(self, location=location)
827
909
class DivergedBranches(BzrError):
829
_fmt = "These branches have diverged. Use the merge command to reconcile them."""
911
_fmt = ("These branches have diverged."
912
" Use the merge command to reconcile them.")
831
914
internal_error = False
835
918
self.branch2 = branch2
921
class NotLefthandHistory(BzrError):
923
_fmt = "Supplied history does not follow left-hand parents"
925
internal_error = True
927
def __init__(self, history):
928
BzrError.__init__(self, history=history)
838
931
class UnrelatedBranches(BzrError):
840
_fmt = "Branches have no common ancestor, and no merge base revision was specified."
933
_fmt = ("Branches have no common ancestor, and"
934
" no merge base revision was specified.")
842
936
internal_error = False
854
948
class NoCommonRoot(BzrError):
856
_fmt = "Revisions are not derived from the same root: " \
857
"%(revision_a)s %(revision_b)s."
950
_fmt = ("Revisions are not derived from the same root: "
951
"%(revision_a)s %(revision_b)s.")
859
953
def __init__(self, revision_a, revision_b):
860
954
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
883
977
def __init__(self, bases):
884
978
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
885
979
DeprecationWarning)
886
msg = "The correct base is unclear, because %s are all equally close" %\
980
msg = ("The correct base is unclear, because %s are all equally close"
888
982
BzrError.__init__(self, msg)
889
983
self.bases = bases
923
1018
class CommitToDoubleBoundBranch(BzrError):
925
_fmt = "Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."
1020
_fmt = ("Cannot commit to branch %(branch)s."
1021
" It is bound to %(master)s, which is bound to %(remote)s.")
927
1023
def __init__(self, branch, master, remote):
928
1024
BzrError.__init__(self)
943
1039
class BoundBranchConnectionFailure(BzrError):
945
_fmt = "Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"
1041
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1042
" => %(target)s: %(error)s")
947
1044
def __init__(self, branch, target, error):
948
1045
BzrError.__init__(self)
1003
1100
class WeaveTextDiffers(WeaveError):
1005
_fmt = "Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"
1102
_fmt = ("Weaves differ on text content. Revision:"
1103
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1007
1105
def __init__(self, revision_id, weave_a, weave_b):
1008
1106
WeaveError.__init__(self)
1014
1112
class WeaveTextDiffers(WeaveError):
1016
_fmt = "Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"
1114
_fmt = ("Weaves differ on text content. Revision:"
1115
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1018
1117
def __init__(self, revision_id, weave_a, weave_b):
1019
1118
WeaveError.__init__(self)
1117
1216
class TooManyConcurrentRequests(BzrError):
1119
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit. "
1120
"Be sure to finish_writing and finish_reading on the "
1121
"current request that is open.")
1218
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1219
" Be sure to finish_writing and finish_reading on the"
1220
" current request that is open.")
1123
1222
internal_error = True
1252
1351
class CantReprocessAndShowBase(BzrError):
1254
_fmt = "Can't reprocess and show base, because reprocessing obscures " \
1255
"the relationship of conflicting lines to the base"
1353
_fmt = ("Can't reprocess and show base, because reprocessing obscures "
1354
"the relationship of conflicting lines to the base")
1258
1357
class GraphCycleError(BzrError):
1537
1648
self.tree = tree
1651
class PublicBranchOutOfDate(BzrError):
1653
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1656
def __init__(self, public_location, revstring):
1657
import bzrlib.urlutils as urlutils
1658
public_location = urlutils.unescape_for_display(public_location,
1660
BzrError.__init__(self, public_location=public_location,
1661
revstring=revstring)
1540
1664
class MergeModifiedFormatError(BzrError):
1542
1666
_fmt = "Error in merge modified format"
1550
1674
class CorruptRepository(BzrError):
1552
_fmt = """An error has been detected in the repository %(repo_path)s.
1553
Please run bzr reconcile on this repository."""
1676
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1677
"Please run bzr reconcile on this repository.")
1555
1679
def __init__(self, repo):
1556
1680
BzrError.__init__(self)
1579
1703
class InvalidProgressBarType(BzrError):
1581
_fmt = """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1582
Select one of: %(valid_types)s"""
1705
_fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
1706
" is not a supported type Select one of: %(valid_types)s")
1584
1708
def __init__(self, bar_type, valid_types):
1585
1709
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1620
1747
class TestamentMismatch(BzrError):
1622
_fmt = """Testament did not match expected value.
1623
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1749
_fmt = """Testament did not match expected value.
1750
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1624
1751
{%(measured)s}"""
1626
1753
def __init__(self, revision_id, expected, measured):
1695
1822
BadInventoryFormat.__init__(self, msg=msg)
1825
class RootNotRich(BzrError):
1827
_fmt = """This operation requires rich root data storage"""
1698
1830
class NoSmartMedium(BzrError):
1700
1832
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1701
1834
internal_error = True
1703
1836
def __init__(self, transport):
1761
1901
class ImportNameCollision(BzrError):
1763
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
1903
_fmt = ("Tried to import an object to the same name as"
1904
" an existing object. %(name)s")
1765
1906
internal_error = True
1767
1908
def __init__(self, name):
1768
1909
BzrError.__init__(self)
1769
1910
self.name = name
1913
class NotAMergeDirective(BzrError):
1914
"""File starting with %(firstline)r is not a merge directive"""
1915
def __init__(self, firstline):
1916
BzrError.__init__(self, firstline=firstline)
1919
class NoMergeSource(BzrError):
1920
"""Raise if no merge source was specified for a merge directive"""
1922
_fmt = "A merge directive must provide either a bundle or a public"\
1926
class PatchMissing(BzrError):
1927
"""Raise a patch type was specified but no patch supplied"""
1929
_fmt = "patch_type was %(patch_type)s, but no patch was supplied."
1931
def __init__(self, patch_type):
1932
BzrError.__init__(self)
1933
self.patch_type = patch_type
1936
class UnsupportedInventoryKind(BzrError):
1938
_fmt = """Unsupported entry kind %(kind)s"""
1940
def __init__(self, kind):
1944
class BadSubsumeSource(BzrError):
1946
_fmt = """Can't subsume %(other_tree)s into %(tree)s. %(reason)s"""
1948
def __init__(self, tree, other_tree, reason):
1950
self.other_tree = other_tree
1951
self.reason = reason
1954
class SubsumeTargetNeedsUpgrade(BzrError):
1956
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
1958
def __init__(self, other_tree):
1959
self.other_tree = other_tree
1962
class BadReferenceTarget(BzrError):
1964
_fmt = "Can't add reference to %(other_tree)s into %(tree)s. %(reason)s"
1966
internal_error = True
1968
def __init__(self, tree, other_tree, reason):
1970
self.other_tree = other_tree
1971
self.reason = reason
1974
class NoSuchTag(BzrError):
1976
_fmt = "No such tag: %(tag_name)s"
1978
def __init__(self, tag_name):
1979
self.tag_name = tag_name
1982
class TagsNotSupported(BzrError):
1984
_fmt = ("Tags not supported by %(branch)s;"
1985
" you may be able to use bzr upgrade.")
1987
def __init__(self, branch):
1988
self.branch = branch
1991
class TagAlreadyExists(BzrError):
1993
_fmt = "Tag %(tag_name)s already exists."
1995
def __init__(self, tag_name):
1996
self.tag_name = tag_name