1237
1713
class InvalidRange(TransportError):
1239
_fmt = "Invalid range access in %(path)s at %(offset)s."
1241
def __init__(self, path, offset):
1242
TransportError.__init__(self, ("Invalid range access in %s at %d"
1715
_fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1717
def __init__(self, path, offset, msg=None):
1718
TransportError.__init__(self, msg)
1244
1719
self.path = path
1245
1720
self.offset = offset
1248
1723
class InvalidHttpResponse(TransportError):
1250
_fmt = "Invalid http response for %(path)s: %(msg)s"
1725
_fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1252
1727
def __init__(self, path, msg, orig_error=None):
1253
1728
self.path = path
1729
if orig_error is None:
1732
# This is reached for obscure and unusual errors so we want to
1733
# preserve as much info as possible to ease debug.
1734
orig_error = ': %r' % (orig_error,)
1254
1735
TransportError.__init__(self, msg, orig_error=orig_error)
1257
1738
class InvalidHttpRange(InvalidHttpResponse):
1259
1740
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1261
1742
def __init__(self, path, range, msg):
1262
1743
self.range = range
1263
1744
InvalidHttpResponse.__init__(self, path, msg)
1747
class HttpBoundaryMissing(InvalidHttpResponse):
1748
"""A multipart response ends with no boundary marker.
1750
This is a special case caused by buggy proxies, described in
1751
<https://bugs.launchpad.net/bzr/+bug/198646>.
1754
_fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1756
def __init__(self, path, msg):
1757
InvalidHttpResponse.__init__(self, path, msg)
1266
1760
class InvalidHttpContentType(InvalidHttpResponse):
1268
1762
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1270
1764
def __init__(self, path, ctype, msg):
1271
1765
self.ctype = ctype
1272
1766
InvalidHttpResponse.__init__(self, path, msg)
1769
class RedirectRequested(TransportError):
1771
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1773
def __init__(self, source, target, is_permanent=False):
1774
self.source = source
1775
self.target = target
1777
self.permanently = ' permanently'
1779
self.permanently = ''
1780
TransportError.__init__(self)
1783
class TooManyRedirections(TransportError):
1785
_fmt = "Too many redirections"
1275
1788
class ConflictsInTree(BzrError):
1277
1790
_fmt = "Working tree has conflicts."
1793
class ConfigContentError(BzrError):
1795
_fmt = "Config file %(filename)s is not UTF-8 encoded\n"
1797
def __init__(self, filename):
1798
BzrError.__init__(self)
1799
self.filename = filename
1280
1802
class ParseConfigError(BzrError):
1804
_fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
1282
1806
def __init__(self, errors, filename):
1283
if filename is None:
1285
message = "Error(s) parsing config file %s:\n%s" % \
1286
(filename, ('\n'.join(e.message for e in errors)))
1287
BzrError.__init__(self, message)
1807
BzrError.__init__(self)
1808
self.filename = filename
1809
self.errors = '\n'.join(e.msg for e in errors)
1812
class ConfigOptionValueError(BzrError):
1814
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
1816
def __init__(self, name, value):
1817
BzrError.__init__(self, name=name, value=value)
1290
1820
class NoEmailInUsername(BzrError):
1953
2644
def __init__(self, branch):
1954
2645
self.branch = branch
1957
2648
class TagAlreadyExists(BzrError):
1959
2650
_fmt = "Tag %(tag_name)s already exists."
1961
2652
def __init__(self, tag_name):
1962
2653
self.tag_name = tag_name
2656
class MalformedBugIdentifier(BzrError):
2658
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2659
'See "bzr help bugs" for more information on this feature.')
2661
def __init__(self, bug_id, reason):
2662
self.bug_id = bug_id
2663
self.reason = reason
2666
class InvalidBugTrackerURL(BzrError):
2668
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2669
"contain {id}: %(url)s")
2671
def __init__(self, abbreviation, url):
2672
self.abbreviation = abbreviation
2676
class UnknownBugTrackerAbbreviation(BzrError):
2678
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2681
def __init__(self, abbreviation, branch):
2682
self.abbreviation = abbreviation
2683
self.branch = branch
2686
class InvalidLineInBugsProperty(BzrError):
2688
_fmt = ("Invalid line in bugs property: '%(line)s'")
2690
def __init__(self, line):
2694
class InvalidBugStatus(BzrError):
2696
_fmt = ("Invalid bug status: '%(status)s'")
2698
def __init__(self, status):
2699
self.status = status
2702
class UnexpectedSmartServerResponse(BzrError):
2704
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2706
def __init__(self, response_tuple):
2707
self.response_tuple = response_tuple
2710
class ErrorFromSmartServer(BzrError):
2711
"""An error was received from a smart server.
2713
:seealso: UnknownErrorFromSmartServer
2716
_fmt = "Error received from smart server: %(error_tuple)r"
2718
internal_error = True
2720
def __init__(self, error_tuple):
2721
self.error_tuple = error_tuple
2723
self.error_verb = error_tuple[0]
2725
self.error_verb = None
2726
self.error_args = error_tuple[1:]
2729
class UnknownErrorFromSmartServer(BzrError):
2730
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2733
This is distinct from ErrorFromSmartServer so that it is possible to
2734
distinguish between the following two cases:
2736
- ErrorFromSmartServer was uncaught. This is logic error in the client
2737
and so should provoke a traceback to the user.
2738
- ErrorFromSmartServer was caught but its error_tuple could not be
2739
translated. This is probably because the server sent us garbage, and
2740
should not provoke a traceback.
2743
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2745
internal_error = False
2747
def __init__(self, error_from_smart_server):
2750
:param error_from_smart_server: An ErrorFromSmartServer instance.
2752
self.error_from_smart_server = error_from_smart_server
2753
self.error_tuple = error_from_smart_server.error_tuple
2756
class ContainerError(BzrError):
2757
"""Base class of container errors."""
2760
class UnknownContainerFormatError(ContainerError):
2762
_fmt = "Unrecognised container format: %(container_format)r"
2764
def __init__(self, container_format):
2765
self.container_format = container_format
2768
class UnexpectedEndOfContainerError(ContainerError):
2770
_fmt = "Unexpected end of container stream"
2773
class UnknownRecordTypeError(ContainerError):
2775
_fmt = "Unknown record type: %(record_type)r"
2777
def __init__(self, record_type):
2778
self.record_type = record_type
2781
class InvalidRecordError(ContainerError):
2783
_fmt = "Invalid record: %(reason)s"
2785
def __init__(self, reason):
2786
self.reason = reason
2789
class ContainerHasExcessDataError(ContainerError):
2791
_fmt = "Container has data after end marker: %(excess)r"
2793
def __init__(self, excess):
2794
self.excess = excess
2797
class DuplicateRecordNameError(ContainerError):
2799
_fmt = "Container has multiple records with the same name: %(name)s"
2801
def __init__(self, name):
2802
self.name = name.decode("utf-8")
2805
class NoDestinationAddress(InternalBzrError):
2807
_fmt = "Message does not have a destination address."
2810
class RepositoryDataStreamError(BzrError):
2812
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2814
def __init__(self, reason):
2815
self.reason = reason
2818
class SMTPError(BzrError):
2820
_fmt = "SMTP error: %(error)s"
2822
def __init__(self, error):
2826
class NoMessageSupplied(BzrError):
2828
_fmt = "No message supplied."
2831
class NoMailAddressSpecified(BzrError):
2833
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2836
class UnknownMailClient(BzrError):
2838
_fmt = "Unknown mail client: %(mail_client)s"
2840
def __init__(self, mail_client):
2841
BzrError.__init__(self, mail_client=mail_client)
2844
class MailClientNotFound(BzrError):
2846
_fmt = "Unable to find mail client with the following names:"\
2847
" %(mail_command_list_string)s"
2849
def __init__(self, mail_command_list):
2850
mail_command_list_string = ', '.join(mail_command_list)
2851
BzrError.__init__(self, mail_command_list=mail_command_list,
2852
mail_command_list_string=mail_command_list_string)
2854
class SMTPConnectionRefused(SMTPError):
2856
_fmt = "SMTP connection to %(host)s refused"
2858
def __init__(self, error, host):
2863
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2865
_fmt = "Please specify smtp_server. No server at default %(host)s."
2868
class BzrDirError(BzrError):
2870
def __init__(self, bzrdir):
2871
import bzrlib.urlutils as urlutils
2872
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2874
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2877
class UnsyncedBranches(BzrDirError):
2879
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2880
" bzr help sync-for-reconfigure.")
2882
def __init__(self, bzrdir, target_branch):
2883
BzrDirError.__init__(self, bzrdir)
2884
import bzrlib.urlutils as urlutils
2885
self.target_url = urlutils.unescape_for_display(target_branch.base,
2889
class AlreadyBranch(BzrDirError):
2891
_fmt = "'%(display_url)s' is already a branch."
2894
class AlreadyTree(BzrDirError):
2896
_fmt = "'%(display_url)s' is already a tree."
2899
class AlreadyCheckout(BzrDirError):
2901
_fmt = "'%(display_url)s' is already a checkout."
2904
class AlreadyLightweightCheckout(BzrDirError):
2906
_fmt = "'%(display_url)s' is already a lightweight checkout."
2909
class AlreadyUsingShared(BzrDirError):
2911
_fmt = "'%(display_url)s' is already using a shared repository."
2914
class AlreadyStandalone(BzrDirError):
2916
_fmt = "'%(display_url)s' is already standalone."
2919
class AlreadyWithTrees(BzrDirError):
2921
_fmt = ("Shared repository '%(display_url)s' already creates "
2925
class AlreadyWithNoTrees(BzrDirError):
2927
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2931
class ReconfigurationNotSupported(BzrDirError):
2933
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2936
class NoBindLocation(BzrDirError):
2938
_fmt = "No location could be found to bind to at %(display_url)s."
2941
class UncommittedChanges(BzrError):
2943
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2944
' (See bzr status).%(more)s')
2946
def __init__(self, tree, more=None):
2951
import bzrlib.urlutils as urlutils
2952
user_url = getattr(tree, "user_url", None)
2953
if user_url is None:
2954
display_url = str(tree)
2956
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2957
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2960
class ShelvedChanges(UncommittedChanges):
2962
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2963
' (See bzr shelve --list).%(more)s')
2966
class MissingTemplateVariable(BzrError):
2968
_fmt = 'Variable {%(name)s} is not available.'
2970
def __init__(self, name):
2974
class NoTemplate(BzrError):
2976
_fmt = 'No template specified.'
2979
class UnableCreateSymlink(BzrError):
2981
_fmt = 'Unable to create symlink %(path_str)son this platform'
2983
def __init__(self, path=None):
2987
path_str = repr(str(path))
2988
except UnicodeEncodeError:
2989
path_str = repr(path)
2991
self.path_str = path_str
2994
class UnsupportedTimezoneFormat(BzrError):
2996
_fmt = ('Unsupported timezone format "%(timezone)s", '
2997
'options are "utc", "original", "local".')
2999
def __init__(self, timezone):
3000
self.timezone = timezone
3003
class CommandAvailableInPlugin(StandardError):
3005
internal_error = False
3007
def __init__(self, cmd_name, plugin_metadata, provider):
3009
self.plugin_metadata = plugin_metadata
3010
self.cmd_name = cmd_name
3011
self.provider = provider
3015
_fmt = ('"%s" is not a standard bzr command. \n'
3016
'However, the following official plugin provides this command: %s\n'
3017
'You can install it by going to: %s'
3018
% (self.cmd_name, self.plugin_metadata['name'],
3019
self.plugin_metadata['url']))
3024
class NoPluginAvailable(BzrError):
3028
class UnableEncodePath(BzrError):
3030
_fmt = ('Unable to encode %(kind)s path %(path)r in '
3031
'user encoding %(user_encoding)s')
3033
def __init__(self, path, kind):
3034
from bzrlib.osutils import get_user_encoding
3037
self.user_encoding = osutils.get_user_encoding()
3040
class NoSuchConfig(BzrError):
3042
_fmt = ('The "%(config_id)s" configuration does not exist.')
3044
def __init__(self, config_id):
3045
BzrError.__init__(self, config_id=config_id)
3048
class NoSuchConfigOption(BzrError):
3050
_fmt = ('The "%(option_name)s" configuration option does not exist.')
3052
def __init__(self, option_name):
3053
BzrError.__init__(self, option_name=option_name)
3056
class NoSuchAlias(BzrError):
3058
_fmt = ('The alias "%(alias_name)s" does not exist.')
3060
def __init__(self, alias_name):
3061
BzrError.__init__(self, alias_name=alias_name)
3064
class DirectoryLookupFailure(BzrError):
3065
"""Base type for lookup errors."""
3070
class InvalidLocationAlias(DirectoryLookupFailure):
3072
_fmt = '"%(alias_name)s" is not a valid location alias.'
3074
def __init__(self, alias_name):
3075
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
3078
class UnsetLocationAlias(DirectoryLookupFailure):
3080
_fmt = 'No %(alias_name)s location assigned.'
3082
def __init__(self, alias_name):
3083
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
3086
class CannotBindAddress(BzrError):
3088
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
3090
def __init__(self, host, port, orig_error):
3091
# nb: in python2.4 socket.error doesn't have a useful repr
3092
BzrError.__init__(self, host=host, port=port,
3093
orig_error=repr(orig_error.args))
3096
class UnknownRules(BzrError):
3098
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
3100
def __init__(self, unknowns):
3101
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
3104
class HookFailed(BzrError):
3105
"""Raised when a pre_change_branch_tip hook function fails anything other
3106
than TipChangeRejected.
3108
Note that this exception is no longer raised, and the import is only left
3109
to be nice to code which might catch it in a plugin.
3112
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
3113
"%(traceback_text)s%(exc_value)s")
3115
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
3117
symbol_versioning.warn("BzrError HookFailed has been deprecated "
3118
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
3120
self.hook_stage = hook_stage
3121
self.hook_name = hook_name
3122
self.exc_info = exc_info
3123
self.exc_type = exc_info[0]
3124
self.exc_value = exc_info[1]
3125
self.exc_tb = exc_info[2]
3126
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3129
class TipChangeRejected(BzrError):
3130
"""A pre_change_branch_tip hook function may raise this to cleanly and
3131
explicitly abort a change to a branch tip.
3134
_fmt = u"Tip change rejected: %(msg)s"
3136
def __init__(self, msg):
3140
class ShelfCorrupt(BzrError):
3142
_fmt = "Shelf corrupt."
3145
class DecompressCorruption(BzrError):
3147
_fmt = "Corruption while decompressing repository file%(orig_error)s"
3149
def __init__(self, orig_error=None):
3150
if orig_error is not None:
3151
self.orig_error = ", %s" % (orig_error,)
3153
self.orig_error = ""
3154
BzrError.__init__(self)
3157
class NoSuchShelfId(BzrError):
3159
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3161
def __init__(self, shelf_id):
3162
BzrError.__init__(self, shelf_id=shelf_id)
3165
class InvalidShelfId(BzrError):
3167
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3169
def __init__(self, invalid_id):
3170
BzrError.__init__(self, invalid_id=invalid_id)
3173
class JailBreak(BzrError):
3175
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3177
def __init__(self, url):
3178
BzrError.__init__(self, url=url)
3181
class UserAbort(BzrError):
3183
_fmt = 'The user aborted the operation.'
3186
class MustHaveWorkingTree(BzrError):
3188
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3190
def __init__(self, format, url):
3191
BzrError.__init__(self, format=format, url=url)
3194
class NoSuchView(BzrError):
3195
"""A view does not exist.
3198
_fmt = u"No such view: %(view_name)s."
3200
def __init__(self, view_name):
3201
self.view_name = view_name
3204
class ViewsNotSupported(BzrError):
3205
"""Views are not supported by a tree format.
3208
_fmt = ("Views are not supported by %(tree)s;"
3209
" use 'bzr upgrade' to change your tree to a later format.")
3211
def __init__(self, tree):
3215
class FileOutsideView(BzrError):
3217
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3220
def __init__(self, file_name, view_files):
3221
self.file_name = file_name
3222
self.view_str = ", ".join(view_files)
3225
class UnresumableWriteGroup(BzrError):
3227
_fmt = ("Repository %(repository)s cannot resume write group "
3228
"%(write_groups)r: %(reason)s")
3230
internal_error = True
3232
def __init__(self, repository, write_groups, reason):
3233
self.repository = repository
3234
self.write_groups = write_groups
3235
self.reason = reason
3238
class UnsuspendableWriteGroup(BzrError):
3240
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3242
internal_error = True
3244
def __init__(self, repository):
3245
self.repository = repository
3248
class LossyPushToSameVCS(BzrError):
3250
_fmt = ("Lossy push not possible between %(source_branch)r and "
3251
"%(target_branch)r that are in the same VCS.")
3253
internal_error = True
3255
def __init__(self, source_branch, target_branch):
3256
self.source_branch = source_branch
3257
self.target_branch = target_branch
3260
class NoRoundtrippingSupport(BzrError):
3262
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3263
"%(target_branch)r.")
3265
internal_error = True
3267
def __init__(self, source_branch, target_branch):
3268
self.source_branch = source_branch
3269
self.target_branch = target_branch
3272
class FileTimestampUnavailable(BzrError):
3274
_fmt = "The filestamp for %(path)s is not available."
3276
internal_error = True
3278
def __init__(self, path):
3282
class NoColocatedBranchSupport(BzrError):
3284
_fmt = ("%(bzrdir)r does not support co-located branches.")
3286
def __init__(self, bzrdir):
3287
self.bzrdir = bzrdir
3290
class NoWhoami(BzrError):
3292
_fmt = ('Unable to determine your name.\n'
3293
"Please, set your name with the 'whoami' command.\n"
3294
'E.g. bzr whoami "Your Name <name@example.com>"')
3297
class InvalidPattern(BzrError):
3299
_fmt = ('Invalid pattern(s) found. %(msg)s')
3301
def __init__(self, msg):
3305
class RecursiveBind(BzrError):
3307
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3308
'Please use `bzr unbind` to fix.')
3310
def __init__(self, branch_url):
3311
self.branch_url = branch_url
3314
# FIXME: I would prefer to define the config related exception classes in
3315
# config.py but the lazy import mechanism proscribes this -- vila 20101222
3316
class OptionExpansionLoop(BzrError):
3318
_fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
3320
def __init__(self, string, refs):
3321
self.string = string
3322
self.refs = '->'.join(refs)
3325
class ExpandingUnknownOption(BzrError):
3327
_fmt = 'Option %(name)s is not defined while expanding "%(string)s".'
3329
def __init__(self, name, string):
3331
self.string = string
3334
class NoCompatibleInter(BzrError):
3336
_fmt = ('No compatible object available for operations from %(source)r '
3339
def __init__(self, source, target):
3340
self.source = source
3341
self.target = target
3344
class HpssVfsRequestNotAllowed(BzrError):
3346
_fmt = ("VFS requests over the smart server are not allowed. Encountered: "
3347
"%(method)s, %(arguments)s.")
3349
def __init__(self, method, arguments):
3350
self.method = method
3351
self.arguments = arguments