343
289
_fmt = "Error in command line options"
346
class BadIndexFormatSignature(BzrError):
348
_fmt = "%(value)s is not an index of type %(_type)s."
350
def __init__(self, value, _type):
351
BzrError.__init__(self)
356
class BadIndexData(BzrError):
358
_fmt = "Error in data for index %(value)s."
360
def __init__(self, value):
361
BzrError.__init__(self)
365
class BadIndexDuplicateKey(BzrError):
367
_fmt = "The key '%(key)s' is already in index '%(index)s'."
369
def __init__(self, key, index):
370
BzrError.__init__(self)
375
class BadIndexKey(BzrError):
377
_fmt = "The key '%(key)s' is not a valid key."
379
def __init__(self, key):
380
BzrError.__init__(self)
384
class BadIndexOptions(BzrError):
386
_fmt = "Could not parse options for index %(value)s."
388
def __init__(self, value):
389
BzrError.__init__(self)
393
class BadIndexValue(BzrError):
395
_fmt = "The value '%(value)s' is not a valid value."
397
def __init__(self, value):
398
BzrError.__init__(self)
402
class BadOptionValue(BzrError):
404
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
406
def __init__(self, name, value):
407
BzrError.__init__(self, name=name, value=value)
410
292
class StrictCommitFailed(BzrError):
675
491
self.repo_format = repo_format
678
class AlreadyVersionedError(BzrError):
679
"""Used when a path is expected not to be versioned, but it is."""
681
_fmt = "%(context_info)s%(path)s is already versioned"
683
def __init__(self, path, context_info=None):
684
"""Construct a new AlreadyVersionedError.
686
:param path: This is the path which is versioned,
687
which should be in a user friendly form.
688
:param context_info: If given, this is information about the context,
689
which could explain why this is expected to not be versioned.
691
BzrError.__init__(self)
693
if context_info is None:
694
self.context_info = ''
696
self.context_info = context_info + ". "
699
494
class NotVersionedError(BzrError):
700
"""Used when a path is expected to be versioned, but it is not."""
702
_fmt = "%(context_info)s%(path)s is not versioned"
704
def __init__(self, path, context_info=None):
705
"""Construct a new NotVersionedError.
707
:param path: This is the path which is not versioned,
708
which should be in a user friendly form.
709
:param context_info: If given, this is information about the context,
710
which could explain why this is expected to be versioned.
496
_fmt = "%(path)s is not versioned"
498
def __init__(self, path):
712
499
BzrError.__init__(self)
714
if context_info is None:
715
self.context_info = ''
717
self.context_info = context_info + ". "
720
503
class PathsNotVersionedError(BzrError):
721
"""Used when reporting several paths which are not versioned"""
504
# used when reporting several paths are not versioned
723
506
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
732
515
class PathsDoNotExist(BzrError):
734
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
517
_fmt = "Path(s) do not exist: %(paths_as_string)s"
736
519
# used when reporting that paths are neither versioned nor in the working
739
def __init__(self, paths, extra=None):
522
def __init__(self, paths):
740
523
# circular import
741
524
from bzrlib.osutils import quotefn
742
525
BzrError.__init__(self)
743
526
self.paths = paths
744
527
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
746
self.extra = ': ' + str(extra)
751
530
class BadFileKindError(BzrError):
753
_fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
755
def __init__(self, filename, kind):
756
BzrError.__init__(self, filename=filename, kind=kind)
532
_fmt = "Cannot operate on %(filename)s of unsupported kind %(kind)s"
759
535
class ForbiddenControlFileError(BzrError):
908
class TokenLockingNotSupported(LockError):
910
_fmt = "The object %(obj)s does not support token specifying a token when locking."
912
internal_error = True
914
def __init__(self, obj):
918
class TokenMismatch(LockBroken):
920
_fmt = "The lock token %(given_token)r does not match lock token %(lock_token)r."
922
internal_error = True
924
def __init__(self, given_token, lock_token):
925
self.given_token = given_token
926
self.lock_token = lock_token
929
655
class PointlessCommit(BzrError):
931
657
_fmt = "No changes to commit"
934
class CannotCommitSelectedFileMerge(BzrError):
936
_fmt = 'Selected-file commit of merges is not supported yet:'\
937
' files %(files_str)s'
939
def __init__(self, files):
940
files_str = ', '.join(files)
941
BzrError.__init__(self, files=files, files_str=files_str)
944
660
class UpgradeReadonly(BzrError):
946
662
_fmt = "Upgrade URL cannot work with readonly URLs."
1437
1094
InvalidHttpResponse.__init__(self, path, msg)
1440
class RedirectRequested(TransportError):
1442
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1444
def __init__(self, source, target, is_permament=False, qual_proto=None):
1445
self.source = source
1446
self.target = target
1448
self.permanently = ' permanently'
1450
self.permanently = ''
1451
self.is_permament = is_permament
1452
self._qualified_proto = qual_proto
1453
TransportError.__init__(self)
1455
def _requalify_url(self, url):
1456
"""Restore the qualified proto in front of the url"""
1457
# When this exception is raised, source and target are in
1458
# user readable format. But some transports may use a
1459
# different proto (http+urllib:// will present http:// to
1460
# the user. If a qualified proto is specified, the code
1461
# trapping the exception can get the qualified urls to
1462
# properly handle the redirection themself (creating a
1463
# new transport object from the target url for example).
1464
# But checking that the scheme of the original and
1465
# redirected urls are the same can be tricky. (see the
1466
# FIXME in BzrDir.open_from_transport for the unique use
1468
if self._qualified_proto is None:
1471
# The TODO related to NotBranchError mention that doing
1472
# that kind of manipulation on the urls may not be the
1473
# exception object job. On the other hand, this object is
1474
# the interface between the code and the user so
1475
# presenting the urls in different ways is indeed its
1478
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1479
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1482
def get_source_url(self):
1483
return self._requalify_url(self.source)
1485
def get_target_url(self):
1486
return self._requalify_url(self.target)
1489
class TooManyRedirections(TransportError):
1491
_fmt = "Too many redirections"
1493
1097
class ConflictsInTree(BzrError):
1495
1099
_fmt = "Working tree has conflicts."
1694
1278
_fmt = "Moving the root directory is not supported at this time"
1697
class BzrMoveFailedError(BzrError):
1699
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1701
def __init__(self, from_path='', to_path='', extra=None):
1702
BzrError.__init__(self)
1704
self.extra = ': ' + str(extra)
1708
has_from = len(from_path) > 0
1709
has_to = len(to_path) > 0
1711
self.from_path = osutils.splitpath(from_path)[-1]
1716
self.to_path = osutils.splitpath(to_path)[-1]
1721
if has_from and has_to:
1722
self.operator = " =>"
1724
self.from_path = "from " + from_path
1726
self.operator = "to"
1728
self.operator = "file"
1731
class BzrRenameFailedError(BzrMoveFailedError):
1733
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1735
def __init__(self, from_path, to_path, extra=None):
1736
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1738
class BzrRemoveChangedFilesError(BzrError):
1739
"""Used when user is trying to remove changed files."""
1741
_fmt = ("Can't remove changed or unknown files:\n%(changes_as_text)s"
1742
"Use --keep to not delete them, or --force to delete them regardless.")
1744
def __init__(self, tree_delta):
1745
BzrError.__init__(self)
1746
self.changes_as_text = tree_delta.get_changes_as_text()
1747
#self.paths_as_string = '\n'.join(changed_files)
1748
#self.paths_as_string = '\n'.join([quotefn(p) for p in changed_files])
1751
1281
class BzrBadParameterNotString(BzrBadParameter):
1753
1283
_fmt = "Parameter %(param)s is not a string or unicode string."
2106
1605
class ImportNameCollision(BzrError):
2108
_fmt = ("Tried to import an object to the same name as"
2109
" an existing object. %(name)s")
2111
internal_error = True
2113
def __init__(self, name):
2114
BzrError.__init__(self)
2118
class NotAMergeDirective(BzrError):
2119
"""File starting with %(firstline)r is not a merge directive"""
2120
def __init__(self, firstline):
2121
BzrError.__init__(self, firstline=firstline)
2124
class NoMergeSource(BzrError):
2125
"""Raise if no merge source was specified for a merge directive"""
2127
_fmt = "A merge directive must provide either a bundle or a public"\
2131
class IllegalMergeDirectivePayload(BzrError):
2132
"""A merge directive contained something other than a patch or bundle"""
2134
_fmt = "Bad merge directive payload %(start)r"
2136
def __init__(self, start):
2141
class PatchVerificationFailed(BzrError):
2142
"""A patch from a merge directive could not be verified"""
2144
_fmt = "Preview patch does not match requested changes."
2147
class PatchMissing(BzrError):
2148
"""Raise a patch type was specified but no patch supplied"""
2150
_fmt = "patch_type was %(patch_type)s, but no patch was supplied."
2152
def __init__(self, patch_type):
2153
BzrError.__init__(self)
2154
self.patch_type = patch_type
2157
class UnsupportedInventoryKind(BzrError):
2159
_fmt = """Unsupported entry kind %(kind)s"""
2161
def __init__(self, kind):
2165
class BadSubsumeSource(BzrError):
2167
_fmt = """Can't subsume %(other_tree)s into %(tree)s. %(reason)s"""
2169
def __init__(self, tree, other_tree, reason):
2171
self.other_tree = other_tree
2172
self.reason = reason
2175
class SubsumeTargetNeedsUpgrade(BzrError):
2177
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2179
def __init__(self, other_tree):
2180
self.other_tree = other_tree
2183
class BadReferenceTarget(BzrError):
2185
_fmt = "Can't add reference to %(other_tree)s into %(tree)s. %(reason)s"
2187
internal_error = True
2189
def __init__(self, tree, other_tree, reason):
2191
self.other_tree = other_tree
2192
self.reason = reason
2195
class NoSuchTag(BzrError):
2197
_fmt = "No such tag: %(tag_name)s"
2199
def __init__(self, tag_name):
2200
self.tag_name = tag_name
2203
class TagsNotSupported(BzrError):
2205
_fmt = ("Tags not supported by %(branch)s;"
2206
" you may be able to use bzr upgrade --dirstate-tags.")
2208
def __init__(self, branch):
2209
self.branch = branch
2212
class TagAlreadyExists(BzrError):
2214
_fmt = "Tag %(tag_name)s already exists."
2216
def __init__(self, tag_name):
2217
self.tag_name = tag_name
2220
class MalformedBugIdentifier(BzrError):
2222
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2224
def __init__(self, bug_id, reason):
2225
self.bug_id = bug_id
2226
self.reason = reason
2229
class UnknownBugTrackerAbbreviation(BzrError):
2231
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2234
def __init__(self, abbreviation, branch):
2235
self.abbreviation = abbreviation
2236
self.branch = branch
2239
class UnexpectedSmartServerResponse(BzrError):
2241
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2243
def __init__(self, response_tuple):
2244
self.response_tuple = response_tuple
2247
class ContainerError(BzrError):
2248
"""Base class of container errors."""
2251
class UnknownContainerFormatError(ContainerError):
2253
_fmt = "Unrecognised container format: %(container_format)r"
2255
def __init__(self, container_format):
2256
self.container_format = container_format
2259
class UnexpectedEndOfContainerError(ContainerError):
2261
_fmt = "Unexpected end of container stream"
2263
internal_error = False
2266
class UnknownRecordTypeError(ContainerError):
2268
_fmt = "Unknown record type: %(record_type)r"
2270
def __init__(self, record_type):
2271
self.record_type = record_type
2274
class InvalidRecordError(ContainerError):
2276
_fmt = "Invalid record: %(reason)s"
2278
def __init__(self, reason):
2279
self.reason = reason
2282
class ContainerHasExcessDataError(ContainerError):
2284
_fmt = "Container has data after end marker: %(excess)r"
2286
def __init__(self, excess):
2287
self.excess = excess
2290
class DuplicateRecordNameError(ContainerError):
2292
_fmt = "Container has multiple records with the same name: \"%(name)s\""
2294
def __init__(self, name):
2298
class NoDestinationAddress(BzrError):
2300
_fmt = "Message does not have a destination address."
2302
internal_error = True
2305
class SMTPError(BzrError):
2307
_fmt = "SMTP error: %(error)s"
2309
def __init__(self, error):
1607
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
1609
internal_error = True
1611
def __init__(self, name):
1612
BzrError.__init__(self)