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,
174
175
self.message = message
178
class DisabledMethod(BzrError):
180
_fmt = "The smart server method '%(class_name)s' is disabled."
182
internal_error = True
184
def __init__(self, class_name):
185
BzrError.__init__(self)
186
self.class_name = class_name
177
189
class InvalidEntryName(BzrError):
179
191
_fmt = "Invalid entry name: %(name)s"
211
223
def __init__(self, revision_id):
212
224
self.revision_id = revision_id
227
class NoHelpTopic(BzrError):
229
_fmt = ("No help could be found for '%(topic)s'. "
230
"Please use 'bzr help topics' to obtain a list of topics.")
232
def __init__(self, topic):
214
236
class NoSuchId(BzrError):
216
238
_fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
224
246
class InventoryModified(BzrError):
226
_fmt = ("The current inventory for the tree %(tree)r has been modified, "
227
"so a clean inventory cannot be read without data loss.")
248
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
249
" so a clean inventory cannot be read without data loss.")
229
251
internal_error = True
469
492
self.path = urlutils.unescape_for_display(path, 'ascii')
495
class NoSubmitBranch(PathError):
497
_fmt = 'No submit branch available for branch "%(path)s"'
499
def __init__(self, branch):
500
import bzrlib.urlutils as urlutils
501
self.path = urlutils.unescape_for_display(branch.base, 'ascii')
472
504
class AlreadyBranchError(PathError):
474
506
_fmt = "Already a branch: %(path)s."
483
515
class AtomicFileAlreadyClosed(PathError):
485
_fmt = "'%(function)s' called on an AtomicFile after it was closed: %(path)s"
517
_fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
487
520
def __init__(self, path, function):
488
521
PathError.__init__(self, path=path, extra=None)
492
525
class InaccessibleParent(PathError):
494
_fmt = "Parent not accessible given base %(base)s and relative path %(path)s"
527
_fmt = ("Parent not accessible given base %(base)s and"
528
" relative path %(path)s")
496
530
def __init__(self, path, base):
497
531
PathError.__init__(self, path)
537
571
self.bzrdir = bzrdir_format
574
class IncompatibleRepositories(BzrError):
576
_fmt = "Repository %(target)s is not compatible with repository"\
579
def __init__(self, source, target):
580
BzrError.__init__(self, target=target, source=source)
540
583
class IncompatibleRevision(BzrError):
542
585
_fmt = "Revision is not compatible with %(repo_format)s"
645
688
# New code should prefer to raise specific subclasses
646
689
def __init__(self, message):
647
self.message = message
690
# Python 2.5 uses a slot for StandardError.message,
691
# so use a different variable name
692
# so it is exposed in self.__dict__
650
696
class LockActive(LockError):
733
class ReadOnlyLockError(LockError):
735
_fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
737
def __init__(self, fname, msg):
738
LockError.__init__(self, '')
687
743
class OutSideTransaction(BzrError):
689
_fmt = "A transaction related operation was attempted after the transaction finished."
745
_fmt = ("A transaction related operation was attempted after"
746
" the transaction finished.")
692
749
class ObjectNotLocked(LockError):
725
782
internal_error = False
727
784
def __init__(self, lock):
731
788
class LockBroken(LockError):
733
_fmt = "Lock was broken while still open: %(lock)s - check storage consistency!"
790
_fmt = ("Lock was broken while still open: %(lock)s"
791
" - check storage consistency!")
735
793
internal_error = False
822
class TokenLockingNotSupported(LockError):
824
_fmt = "The object %(obj)s does not support token specifying a token when locking."
826
internal_error = True
828
def __init__(self, obj):
832
class TokenMismatch(LockBroken):
834
_fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
836
internal_error = True
838
def __init__(self, given_token, lock_token):
839
self.given_token = given_token
840
self.lock_token = lock_token
763
843
class PointlessCommit(BzrError):
765
845
_fmt = "No changes to commit"
797
877
class NotLeftParentDescendant(BzrError):
799
_fmt = "Revision %(old_revision)s is not the left parent of"\
800
" %(new_revision)s, but branch %(branch_location)s expects this"
879
_fmt = ("Revision %(old_revision)s is not the left parent of"
880
" %(new_revision)s, but branch %(branch_location)s expects this")
802
882
internal_error = True
829
909
class InvalidRevisionSpec(BzrError):
831
_fmt = "Requested revision: %(spec)r does not exist in branch: %(branch)s%(extra)s"
911
_fmt = ("Requested revision: %(spec)r does not exist in branch:"
912
" %(branch)s%(extra)s")
833
914
def __init__(self, spec, branch, extra=None):
834
915
BzrError.__init__(self, branch=branch, spec=spec)
846
927
class AppendRevisionsOnlyViolation(BzrError):
848
_fmt = 'Operation denied because it would change the main history, '\
849
'which is not permitted by the append_revisions_only setting on'\
850
' branch "%(location)s".'
929
_fmt = ('Operation denied because it would change the main history,'
930
' which is not permitted by the append_revisions_only setting on'
931
' branch "%(location)s".')
852
933
def __init__(self, location):
853
934
import bzrlib.urlutils as urlutils
895
978
class NoCommonRoot(BzrError):
897
_fmt = "Revisions are not derived from the same root: " \
898
"%(revision_a)s %(revision_b)s."
980
_fmt = ("Revisions are not derived from the same root: "
981
"%(revision_a)s %(revision_b)s.")
900
983
def __init__(self, revision_a, revision_b):
901
984
BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
924
1007
def __init__(self, bases):
925
1008
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
926
1009
DeprecationWarning)
927
msg = "The correct base is unclear, because %s are all equally close" %\
1010
msg = ("The correct base is unclear, because %s are all equally close"
929
1012
BzrError.__init__(self, msg)
930
1013
self.bases = bases
954
1037
class BoundBranchOutOfDate(BzrError):
956
_fmt = "Bound branch %(branch)s is out of date with master branch %(master)s."
1039
_fmt = ("Bound branch %(branch)s is out of date"
1040
" with master branch %(master)s.")
958
1042
def __init__(self, branch, master):
959
1043
BzrError.__init__(self)
964
1048
class CommitToDoubleBoundBranch(BzrError):
966
_fmt = "Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."
1050
_fmt = ("Cannot commit to branch %(branch)s."
1051
" It is bound to %(master)s, which is bound to %(remote)s.")
968
1053
def __init__(self, branch, master, remote):
969
1054
BzrError.__init__(self)
984
1069
class BoundBranchConnectionFailure(BzrError):
986
_fmt = "Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"
1071
_fmt = ("Unable to connect to target of bound branch %(branch)s"
1072
" => %(target)s: %(error)s")
988
1074
def __init__(self, branch, target, error):
989
1075
BzrError.__init__(self)
1044
1130
class WeaveTextDiffers(WeaveError):
1046
_fmt = "Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"
1132
_fmt = ("Weaves differ on text content. Revision:"
1133
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1048
1135
def __init__(self, revision_id, weave_a, weave_b):
1049
1136
WeaveError.__init__(self)
1055
1142
class WeaveTextDiffers(WeaveError):
1057
_fmt = "Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"
1144
_fmt = ("Weaves differ on text content. Revision:"
1145
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1059
1147
def __init__(self, revision_id, weave_a, weave_b):
1060
1148
WeaveError.__init__(self)
1158
1246
class TooManyConcurrentRequests(BzrError):
1160
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit. "
1161
"Be sure to finish_writing and finish_reading on the "
1162
"current request that is open.")
1248
_fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1249
" Be sure to finish_writing and finish_reading on the"
1250
" currently open request.")
1164
1252
internal_error = True
1248
1336
InvalidHttpResponse.__init__(self, path, msg)
1339
class RedirectRequested(TransportError):
1341
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1343
def __init__(self, source, target, is_permament=False, qual_proto=None):
1344
self.source = source
1345
self.target = target
1347
self.permanently = ' permanently'
1349
self.permanently = ''
1350
self.is_permament = is_permament
1351
self._qualified_proto = qual_proto
1352
TransportError.__init__(self)
1354
def _requalify_url(self, url):
1355
"""Restore the qualified proto in front of the url"""
1356
# When this exception is raised, source and target are in
1357
# user readable format. But some transports may use a
1358
# different proto (http+urllib:// will present http:// to
1359
# the user. If a qualified proto is specified, the code
1360
# trapping the exception can get the qualified urls to
1361
# properly handle the redirection themself (creating a
1362
# new transport object from the target url for example).
1363
# But checking that the scheme of the original and
1364
# redirected urls are the same can be tricky. (see the
1365
# FIXME in BzrDir.open_from_transport for the unique use
1367
if self._qualified_proto is None:
1370
# The TODO related to NotBranchError mention that doing
1371
# that kind of manipulation on the urls may not be the
1372
# exception object job. On the other hand, this object is
1373
# the interface between the code and the user so
1374
# presenting the urls in different ways is indeed its
1377
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1378
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1381
def get_source_url(self):
1382
return self._requalify_url(self.source)
1384
def get_target_url(self):
1385
return self._requalify_url(self.target)
1388
class TooManyRedirections(TransportError):
1390
_fmt = "Too many redirections"
1251
1392
class ConflictsInTree(BzrError):
1253
1394
_fmt = "Working tree has conflicts."
1293
1434
class CantReprocessAndShowBase(BzrError):
1295
_fmt = "Can't reprocess and show base, because reprocessing obscures " \
1296
"the relationship of conflicting lines to the base"
1436
_fmt = ("Can't reprocess and show base, because reprocessing obscures "
1437
"the relationship of conflicting lines to the base")
1299
1440
class GraphCycleError(BzrError):
1374
1515
class MissingText(BzrError):
1376
_fmt = "Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"
1517
_fmt = ("Branch %(base)s is missing revision"
1518
" %(text_revision)s of %(file_id)s")
1378
1520
def __init__(self, branch, text_revision, file_id):
1379
1521
BzrError.__init__(self)
1398
1540
_fmt = "Key %(key)s is already present in map"
1543
class DuplicateHelpPrefix(BzrError):
1545
_fmt = "The prefix %(prefix)s is in the help search path twice."
1547
def __init__(self, prefix):
1548
self.prefix = prefix
1401
1551
class MalformedTransform(BzrError):
1403
1553
_fmt = "Tree transform is malformed %(conflicts)r"
1588
1739
self.tree = tree
1742
class PublicBranchOutOfDate(BzrError):
1744
_fmt = 'Public branch "%(public_location)s" lacks revision '\
1747
def __init__(self, public_location, revstring):
1748
import bzrlib.urlutils as urlutils
1749
public_location = urlutils.unescape_for_display(public_location,
1751
BzrError.__init__(self, public_location=public_location,
1752
revstring=revstring)
1591
1755
class MergeModifiedFormatError(BzrError):
1593
1757
_fmt = "Error in merge modified format"
1601
1765
class CorruptRepository(BzrError):
1603
_fmt = """An error has been detected in the repository %(repo_path)s.
1604
Please run bzr reconcile on this repository."""
1767
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1768
"Please run bzr reconcile on this repository.")
1606
1770
def __init__(self, repo):
1607
1771
BzrError.__init__(self)
1630
1794
class InvalidProgressBarType(BzrError):
1632
_fmt = """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1633
Select one of: %(valid_types)s"""
1796
_fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
1797
" is not a supported type Select one of: %(valid_types)s")
1635
1799
def __init__(self, bar_type, valid_types):
1636
1800
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1639
1803
class UnsupportedOperation(BzrError):
1641
_fmt = "The method %(mname)s is not supported on objects of type %(tname)s."
1805
_fmt = ("The method %(mname)s is not supported on"
1806
" objects of type %(tname)s.")
1643
1808
def __init__(self, method, method_self):
1644
1809
self.method = method
1671
1838
class TestamentMismatch(BzrError):
1673
_fmt = """Testament did not match expected value.
1674
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1840
_fmt = """Testament did not match expected value.
1841
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1675
1842
{%(measured)s}"""
1677
1844
def __init__(self, revision_id, expected, measured):
1826
2001
self.name = name
2004
class NotAMergeDirective(BzrError):
2005
"""File starting with %(firstline)r is not a merge directive"""
2006
def __init__(self, firstline):
2007
BzrError.__init__(self, firstline=firstline)
2010
class NoMergeSource(BzrError):
2011
"""Raise if no merge source was specified for a merge directive"""
2013
_fmt = "A merge directive must provide either a bundle or a public"\
2017
class PatchMissing(BzrError):
2018
"""Raise a patch type was specified but no patch supplied"""
2020
_fmt = "patch_type was %(patch_type)s, but no patch was supplied."
2022
def __init__(self, patch_type):
2023
BzrError.__init__(self)
2024
self.patch_type = patch_type
1829
2027
class UnsupportedInventoryKind(BzrError):
1831
2029
_fmt = """Unsupported entry kind %(kind)s"""
1875
2073
class TagsNotSupported(BzrError):
1877
_fmt = "Tags not supported by %(branch)s; you may be able to use bzr upgrade."
2075
_fmt = ("Tags not supported by %(branch)s;"
2076
" you may be able to use bzr upgrade --dirstate-tags.")
1879
2078
def __init__(self, branch):
1880
2079
self.branch = branch
1887
2086
def __init__(self, tag_name):
1888
2087
self.tag_name = tag_name
2090
class UnexpectedSmartServerResponse(BzrError):
2092
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2094
def __init__(self, response_tuple):
2095
self.response_tuple = response_tuple