1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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,
235
236
class InventoryModified(BzrError):
237
_fmt = ("The current inventory for the tree %(tree)r has been modified, "
238
"so a clean inventory cannot be read without data loss.")
238
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
239
" so a clean inventory cannot be read without data loss.")
240
241
internal_error = True
480
482
self.path = urlutils.unescape_for_display(path, 'ascii')
485
class NoSubmitBranch(PathError):
487
_fmt = 'No submit branch available for branch "%(path)s"'
489
def __init__(self, branch):
490
import bzrlib.urlutils as urlutils
491
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
483
494
class AlreadyBranchError(PathError):
485
496
_fmt = "Already a branch: %(path)s."
494
505
class AtomicFileAlreadyClosed(PathError):
496
_fmt = "'%(function)s' called on an AtomicFile after it was closed: %(path)s"
507
_fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
498
510
def __init__(self, path, function):
499
511
PathError.__init__(self, path=path, extra=None)
503
515
class InaccessibleParent(PathError):
505
_fmt = "Parent not accessible given base %(base)s and relative path %(path)s"
517
_fmt = ("Parent not accessible given base %(base)s and"
518
" relative path %(path)s")
507
520
def __init__(self, path, base):
508
521
PathError.__init__(self, path)
563
576
_fmt = "%(context_info)s%(path)s is already versioned"
565
578
def __init__(self, path, context_info=None):
566
"""Construct a new NotVersionedError.
579
"""Construct a new AlreadyVersionedError.
568
581
:param path: This is the path which is versioned,
569
582
which should be in a user friendly form.
633
646
class BadFileKindError(BzrError):
635
_fmt = "Cannot operate on %(filename)s of unsupported kind %(kind)s"
648
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
650
def __init__(self, filename, kind):
651
BzrError.__init__(self, filename=filename, kind=kind)
638
654
class ForbiddenControlFileError(BzrError):
655
671
self.message = message
674
class LockActive(LockError):
676
_fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
678
internal_error = False
680
def __init__(self, lock_description):
681
self.lock_description = lock_description
658
684
class CommitNotPossible(LockError):
660
686
_fmt = "A commit was attempted but we do not have a write lock open."
676
702
_fmt = "A write attempt was made in a read only transaction on %(obj)s"
704
# TODO: There should also be an error indicating that you need a write
705
# lock and don't have any lock at all... mbp 20070226
678
707
def __init__(self, obj):
682
711
class OutSideTransaction(BzrError):
684
_fmt = "A transaction related operation was attempted after the transaction finished."
713
_fmt = ("A transaction related operation was attempted after"
714
" the transaction finished.")
687
717
class ObjectNotLocked(LockError):
813
845
class NotLeftParentDescendant(BzrError):
815
_fmt = "Revision %(old_revision)s is not the left parent of"\
816
" %(new_revision)s, but branch %(branch_location)s expects this"
847
_fmt = ("Revision %(old_revision)s is not the left parent of"
848
" %(new_revision)s, but branch %(branch_location)s expects this")
818
850
internal_error = True
831
863
BzrError.__init__(self, spec=spec)
866
class NoSuchRevisionInTree(NoSuchRevision):
867
"""When using Tree.revision_tree, and the revision is not accessible."""
869
_fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
871
def __init__(self, tree, revision_id):
872
BzrError.__init__(self)
874
self.revision_id = revision_id
834
877
class InvalidRevisionSpec(BzrError):
836
_fmt = "Requested revision: %(spec)r does not exist in branch: %(branch)s%(extra)s"
879
_fmt = ("Requested revision: %(spec)r does not exist in branch:"
880
" %(branch)s%(extra)s")
838
882
def __init__(self, spec, branch, extra=None):
839
883
BzrError.__init__(self, branch=branch, spec=spec)
851
895
class AppendRevisionsOnlyViolation(BzrError):
853
_fmt = 'Operation denied because it would change the main history, '\
854
'which is not permitted by the append_revisions_only setting on'\
855
' branch "%(location)s".'
897
_fmt = ('Operation denied because it would change the main history,'
898
' which is not permitted by the append_revisions_only setting on'
899
' branch "%(location)s".')
857
901
def __init__(self, location):
858
902
import bzrlib.urlutils as urlutils
900
946
class NoCommonRoot(BzrError):
902
_fmt = "Revisions are not derived from the same root: " \
903
"%(revision_a)s %(revision_b)s."
948
_fmt = ("Revisions are not derived from the same root: "
949
"%(revision_a)s %(revision_b)s.")
905
951
def __init__(self, revision_a, revision_b):
906
952
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
929
975
def __init__(self, bases):
930
976
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
931
977
DeprecationWarning)
932
msg = "The correct base is unclear, because %s are all equally close" %\
978
msg = ("The correct base is unclear, because %s are all equally close"
934
980
BzrError.__init__(self, msg)
935
981
self.bases = bases
959
1005
class BoundBranchOutOfDate(BzrError):
961
_fmt = "Bound branch %(branch)s is out of date with master branch %(master)s."
1007
_fmt = ("Bound branch %(branch)s is out of date"
1008
" with master branch %(master)s.")
963
1010
def __init__(self, branch, master):
964
1011
BzrError.__init__(self)
969
1016
class CommitToDoubleBoundBranch(BzrError):
971
_fmt = "Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."
1018
_fmt = ("Cannot commit to branch %(branch)s."
1019
" It is bound to %(master)s, which is bound to %(remote)s.")
973
1021
def __init__(self, branch, master, remote):
974
1022
BzrError.__init__(self)
989
1037
class BoundBranchConnectionFailure(BzrError):
991
_fmt = "Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"
1039
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1040
" => %(target)s: %(error)s")
993
1042
def __init__(self, branch, target, error):
994
1043
BzrError.__init__(self)
1049
1098
class WeaveTextDiffers(WeaveError):
1051
_fmt = "Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"
1100
_fmt = ("Weaves differ on text content. Revision:"
1101
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1053
1103
def __init__(self, revision_id, weave_a, weave_b):
1054
1104
WeaveError.__init__(self)
1060
1110
class WeaveTextDiffers(WeaveError):
1062
_fmt = "Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"
1112
_fmt = ("Weaves differ on text content. Revision:"
1113
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1064
1115
def __init__(self, revision_id, weave_a, weave_b):
1065
1116
WeaveError.__init__(self)
1163
1214
class TooManyConcurrentRequests(BzrError):
1165
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit. "
1166
"Be sure to finish_writing and finish_reading on the "
1167
"current request that is open.")
1216
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1217
" Be sure to finish_writing and finish_reading on the"
1218
" current request that is open.")
1169
1220
internal_error = True
1298
1349
class CantReprocessAndShowBase(BzrError):
1300
_fmt = "Can't reprocess and show base, because reprocessing obscures " \
1301
"the relationship of conflicting lines to the base"
1351
_fmt = ("Can't reprocess and show base, because reprocessing obscures "
1352
"the relationship of conflicting lines to the base")
1304
1355
class GraphCycleError(BzrError):
1379
1430
class MissingText(BzrError):
1381
_fmt = "Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"
1432
_fmt = ("Branch %(base)s is missing revision"
1433
" %(text_revision)s of %(file_id)s")
1383
1435
def __init__(self, branch, text_revision, file_id):
1384
1436
BzrError.__init__(self)
1388
1440
self.file_id = file_id
1443
class DuplicateFileId(BzrError):
1445
_fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1447
def __init__(self, file_id, entry):
1448
BzrError.__init__(self)
1449
self.file_id = file_id
1391
1453
class DuplicateKey(BzrError):
1393
1455
_fmt = "Key %(key)s is already present in map"
1583
1646
self.tree = tree
1649
class PublicBranchOutOfDate(BzrError):
1651
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1654
def __init__(self, public_location, revstring):
1655
import bzrlib.urlutils as urlutils
1656
public_location = urlutils.unescape_for_display(public_location,
1658
BzrError.__init__(self, public_location=public_location,
1659
revstring=revstring)
1586
1662
class MergeModifiedFormatError(BzrError):
1588
1664
_fmt = "Error in merge modified format"
1596
1672
class CorruptRepository(BzrError):
1598
_fmt = """An error has been detected in the repository %(repo_path)s.
1599
Please run bzr reconcile on this repository."""
1674
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1675
"Please run bzr reconcile on this repository.")
1601
1677
def __init__(self, repo):
1602
1678
BzrError.__init__(self)
1625
1701
class InvalidProgressBarType(BzrError):
1627
_fmt = """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1628
Select one of: %(valid_types)s"""
1703
_fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
1704
" is not a supported type Select one of: %(valid_types)s")
1630
1706
def __init__(self, bar_type, valid_types):
1631
1707
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1634
1710
class UnsupportedOperation(BzrError):
1636
_fmt = "The method %(mname)s is not supported on objects of type %(tname)s."
1712
_fmt = ("The method %(mname)s is not supported on"
1713
" objects of type %(tname)s.")
1638
1715
def __init__(self, method, method_self):
1639
1716
self.method = method
1666
1745
class TestamentMismatch(BzrError):
1668
_fmt = """Testament did not match expected value.
1669
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1747
_fmt = """Testament did not match expected value.
1748
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1670
1749
{%(measured)s}"""
1672
1751
def __init__(self, revision_id, expected, measured):
1741
1820
BadInventoryFormat.__init__(self, msg=msg)
1823
class RootNotRich(BzrError):
1825
_fmt = """This operation requires rich root data storage"""
1744
1828
class NoSmartMedium(BzrError):
1746
1830
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1747
1832
internal_error = True
1749
1834
def __init__(self, transport):
1807
1899
class ImportNameCollision(BzrError):
1809
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
1901
_fmt = ("Tried to import an object to the same name as"
1902
" an existing object. %(name)s")
1811
1904
internal_error = True
1813
1906
def __init__(self, name):
1814
1907
BzrError.__init__(self)
1815
1908
self.name = name
1911
class NoMergeSource(BzrError):
1912
"""Raise if no merge source was specified for a merge directive"""
1914
_fmt = "A merge directive must provide either a bundle or a public"\
1918
class PatchMissing(BzrError):
1919
"""Raise a patch type was specified but no patch supplied"""
1921
_fmt = "patch_type was %(patch_type)s, but no patch was supplied."
1923
def __init__(self, patch_type):
1924
BzrError.__init__(self)
1925
self.patch_type = patch_type
1928
class UnsupportedInventoryKind(BzrError):
1930
_fmt = """Unsupported entry kind %(kind)s"""
1932
def __init__(self, kind):
1936
class BadSubsumeSource(BzrError):
1938
_fmt = """Can't subsume %(other_tree)s into %(tree)s. %(reason)s"""
1940
def __init__(self, tree, other_tree, reason):
1942
self.other_tree = other_tree
1943
self.reason = reason
1946
class SubsumeTargetNeedsUpgrade(BzrError):
1948
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
1950
def __init__(self, other_tree):
1951
self.other_tree = other_tree
1954
class BadReferenceTarget(BzrError):
1956
_fmt = "Can't add reference to %(other_tree)s into %(tree)s. %(reason)s"
1958
internal_error = True
1960
def __init__(self, tree, other_tree, reason):
1962
self.other_tree = other_tree
1963
self.reason = reason
1966
class NoSuchTag(BzrError):
1968
_fmt = "No such tag: %(tag_name)s"
1970
def __init__(self, tag_name):
1971
self.tag_name = tag_name
1974
class TagsNotSupported(BzrError):
1976
_fmt = ("Tags not supported by %(branch)s;"
1977
" you may be able to use bzr upgrade.")
1979
def __init__(self, branch):
1980
self.branch = branch
1983
class TagAlreadyExists(BzrError):
1985
_fmt = "Tag %(tag_name)s already exists."
1987
def __init__(self, tag_name):
1988
self.tag_name = tag_name