2668
2118
self.branch = branch
2671
class InvalidLineInBugsProperty(BzrError):
2673
_fmt = ("Invalid line in bugs property: '%(line)s'")
2675
def __init__(self, line):
2679
class InvalidBugStatus(BzrError):
2681
_fmt = ("Invalid bug status: '%(status)s'")
2683
def __init__(self, status):
2684
self.status = status
2687
2121
class UnexpectedSmartServerResponse(BzrError):
2689
2123
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2691
2125
def __init__(self, response_tuple):
2692
2126
self.response_tuple = response_tuple
2695
class ErrorFromSmartServer(BzrError):
2696
"""An error was received from a smart server.
2698
:seealso: UnknownErrorFromSmartServer
2701
_fmt = "Error received from smart server: %(error_tuple)r"
2703
internal_error = True
2705
def __init__(self, error_tuple):
2706
self.error_tuple = error_tuple
2708
self.error_verb = error_tuple[0]
2710
self.error_verb = None
2711
self.error_args = error_tuple[1:]
2714
class UnknownErrorFromSmartServer(BzrError):
2715
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2718
This is distinct from ErrorFromSmartServer so that it is possible to
2719
distinguish between the following two cases:
2721
- ErrorFromSmartServer was uncaught. This is logic error in the client
2722
and so should provoke a traceback to the user.
2723
- ErrorFromSmartServer was caught but its error_tuple could not be
2724
translated. This is probably because the server sent us garbage, and
2725
should not provoke a traceback.
2728
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2730
internal_error = False
2732
def __init__(self, error_from_smart_server):
2735
:param error_from_smart_server: An ErrorFromSmartServer instance.
2737
self.error_from_smart_server = error_from_smart_server
2738
self.error_tuple = error_from_smart_server.error_tuple
2741
class ContainerError(BzrError):
2742
"""Base class of container errors."""
2745
class UnknownContainerFormatError(ContainerError):
2747
_fmt = "Unrecognised container format: %(container_format)r"
2749
def __init__(self, container_format):
2750
self.container_format = container_format
2753
class UnexpectedEndOfContainerError(ContainerError):
2755
_fmt = "Unexpected end of container stream"
2758
class UnknownRecordTypeError(ContainerError):
2760
_fmt = "Unknown record type: %(record_type)r"
2762
def __init__(self, record_type):
2763
self.record_type = record_type
2766
class InvalidRecordError(ContainerError):
2768
_fmt = "Invalid record: %(reason)s"
2770
def __init__(self, reason):
2771
self.reason = reason
2774
class ContainerHasExcessDataError(ContainerError):
2776
_fmt = "Container has data after end marker: %(excess)r"
2778
def __init__(self, excess):
2779
self.excess = excess
2782
class DuplicateRecordNameError(ContainerError):
2784
_fmt = "Container has multiple records with the same name: %(name)s"
2786
def __init__(self, name):
2790
class NoDestinationAddress(InternalBzrError):
2792
_fmt = "Message does not have a destination address."
2795
class RepositoryDataStreamError(BzrError):
2797
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2799
def __init__(self, reason):
2800
self.reason = reason
2803
class SMTPError(BzrError):
2805
_fmt = "SMTP error: %(error)s"
2807
def __init__(self, error):
2811
class NoMessageSupplied(BzrError):
2813
_fmt = "No message supplied."
2816
class NoMailAddressSpecified(BzrError):
2818
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2821
class UnknownMailClient(BzrError):
2823
_fmt = "Unknown mail client: %(mail_client)s"
2825
def __init__(self, mail_client):
2826
BzrError.__init__(self, mail_client=mail_client)
2829
class MailClientNotFound(BzrError):
2831
_fmt = "Unable to find mail client with the following names:"\
2832
" %(mail_command_list_string)s"
2834
def __init__(self, mail_command_list):
2835
mail_command_list_string = ', '.join(mail_command_list)
2836
BzrError.__init__(self, mail_command_list=mail_command_list,
2837
mail_command_list_string=mail_command_list_string)
2839
class SMTPConnectionRefused(SMTPError):
2841
_fmt = "SMTP connection to %(host)s refused"
2843
def __init__(self, error, host):
2848
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2850
_fmt = "Please specify smtp_server. No server at default %(host)s."
2853
class BzrDirError(BzrError):
2855
def __init__(self, bzrdir):
2856
import bzrlib.urlutils as urlutils
2857
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2859
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2862
class UnsyncedBranches(BzrDirError):
2864
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2865
" bzr help sync-for-reconfigure.")
2867
def __init__(self, bzrdir, target_branch):
2868
BzrDirError.__init__(self, bzrdir)
2869
import bzrlib.urlutils as urlutils
2870
self.target_url = urlutils.unescape_for_display(target_branch.base,
2874
class AlreadyBranch(BzrDirError):
2876
_fmt = "'%(display_url)s' is already a branch."
2879
class AlreadyTree(BzrDirError):
2881
_fmt = "'%(display_url)s' is already a tree."
2884
class AlreadyCheckout(BzrDirError):
2886
_fmt = "'%(display_url)s' is already a checkout."
2889
class AlreadyLightweightCheckout(BzrDirError):
2891
_fmt = "'%(display_url)s' is already a lightweight checkout."
2894
class AlreadyUsingShared(BzrDirError):
2896
_fmt = "'%(display_url)s' is already using a shared repository."
2899
class AlreadyStandalone(BzrDirError):
2901
_fmt = "'%(display_url)s' is already standalone."
2904
class AlreadyWithTrees(BzrDirError):
2906
_fmt = ("Shared repository '%(display_url)s' already creates "
2910
class AlreadyWithNoTrees(BzrDirError):
2912
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2916
class ReconfigurationNotSupported(BzrDirError):
2918
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2921
class NoBindLocation(BzrDirError):
2923
_fmt = "No location could be found to bind to at %(display_url)s."
2926
class UncommittedChanges(BzrError):
2928
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2929
' (See bzr status).%(more)s')
2931
def __init__(self, tree, more=None):
2936
import bzrlib.urlutils as urlutils
2937
user_url = getattr(tree, "user_url", None)
2938
if user_url is None:
2939
display_url = str(tree)
2941
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2942
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2945
class ShelvedChanges(UncommittedChanges):
2947
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2948
' (See bzr shelve --list).%(more)s')
2951
class MissingTemplateVariable(BzrError):
2953
_fmt = 'Variable {%(name)s} is not available.'
2955
def __init__(self, name):
2959
class NoTemplate(BzrError):
2961
_fmt = 'No template specified.'
2964
class UnableCreateSymlink(BzrError):
2966
_fmt = 'Unable to create symlink %(path_str)son this platform'
2968
def __init__(self, path=None):
2972
path_str = repr(str(path))
2973
except UnicodeEncodeError:
2974
path_str = repr(path)
2976
self.path_str = path_str
2979
class UnsupportedTimezoneFormat(BzrError):
2981
_fmt = ('Unsupported timezone format "%(timezone)s", '
2982
'options are "utc", "original", "local".')
2984
def __init__(self, timezone):
2985
self.timezone = timezone
2988
class CommandAvailableInPlugin(StandardError):
2990
internal_error = False
2992
def __init__(self, cmd_name, plugin_metadata, provider):
2994
self.plugin_metadata = plugin_metadata
2995
self.cmd_name = cmd_name
2996
self.provider = provider
3000
_fmt = ('"%s" is not a standard bzr command. \n'
3001
'However, the following official plugin provides this command: %s\n'
3002
'You can install it by going to: %s'
3003
% (self.cmd_name, self.plugin_metadata['name'],
3004
self.plugin_metadata['url']))
3009
class NoPluginAvailable(BzrError):
3013
class UnableEncodePath(BzrError):
3015
_fmt = ('Unable to encode %(kind)s path %(path)r in '
3016
'user encoding %(user_encoding)s')
3018
def __init__(self, path, kind):
3019
from bzrlib.osutils import get_user_encoding
3022
self.user_encoding = osutils.get_user_encoding()
3025
class NoSuchConfig(BzrError):
3027
_fmt = ('The "%(config_id)s" configuration does not exist.')
3029
def __init__(self, config_id):
3030
BzrError.__init__(self, config_id=config_id)
3033
class NoSuchConfigOption(BzrError):
3035
_fmt = ('The "%(option_name)s" configuration option does not exist.')
3037
def __init__(self, option_name):
3038
BzrError.__init__(self, option_name=option_name)
3041
class NoSuchAlias(BzrError):
3043
_fmt = ('The alias "%(alias_name)s" does not exist.')
3045
def __init__(self, alias_name):
3046
BzrError.__init__(self, alias_name=alias_name)
3049
class DirectoryLookupFailure(BzrError):
3050
"""Base type for lookup errors."""
3055
class InvalidLocationAlias(DirectoryLookupFailure):
3057
_fmt = '"%(alias_name)s" is not a valid location alias.'
3059
def __init__(self, alias_name):
3060
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
3063
class UnsetLocationAlias(DirectoryLookupFailure):
3065
_fmt = 'No %(alias_name)s location assigned.'
3067
def __init__(self, alias_name):
3068
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
3071
class CannotBindAddress(BzrError):
3073
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
3075
def __init__(self, host, port, orig_error):
3076
# nb: in python2.4 socket.error doesn't have a useful repr
3077
BzrError.__init__(self, host=host, port=port,
3078
orig_error=repr(orig_error.args))
3081
class UnknownRules(BzrError):
3083
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
3085
def __init__(self, unknowns):
3086
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
3089
class HookFailed(BzrError):
3090
"""Raised when a pre_change_branch_tip hook function fails anything other
3091
than TipChangeRejected.
3093
Note that this exception is no longer raised, and the import is only left
3094
to be nice to code which might catch it in a plugin.
3097
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
3098
"%(traceback_text)s%(exc_value)s")
3100
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
3102
symbol_versioning.warn("BzrError HookFailed has been deprecated "
3103
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
3105
self.hook_stage = hook_stage
3106
self.hook_name = hook_name
3107
self.exc_info = exc_info
3108
self.exc_type = exc_info[0]
3109
self.exc_value = exc_info[1]
3110
self.exc_tb = exc_info[2]
3111
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3114
class TipChangeRejected(BzrError):
3115
"""A pre_change_branch_tip hook function may raise this to cleanly and
3116
explicitly abort a change to a branch tip.
3119
_fmt = u"Tip change rejected: %(msg)s"
3121
def __init__(self, msg):
3125
class ShelfCorrupt(BzrError):
3127
_fmt = "Shelf corrupt."
3130
class DecompressCorruption(BzrError):
3132
_fmt = "Corruption while decompressing repository file%(orig_error)s"
3134
def __init__(self, orig_error=None):
3135
if orig_error is not None:
3136
self.orig_error = ", %s" % (orig_error,)
3138
self.orig_error = ""
3139
BzrError.__init__(self)
3142
class NoSuchShelfId(BzrError):
3144
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3146
def __init__(self, shelf_id):
3147
BzrError.__init__(self, shelf_id=shelf_id)
3150
class InvalidShelfId(BzrError):
3152
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3154
def __init__(self, invalid_id):
3155
BzrError.__init__(self, invalid_id=invalid_id)
3158
class JailBreak(BzrError):
3160
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3162
def __init__(self, url):
3163
BzrError.__init__(self, url=url)
3166
class UserAbort(BzrError):
3168
_fmt = 'The user aborted the operation.'
3171
class MustHaveWorkingTree(BzrError):
3173
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3175
def __init__(self, format, url):
3176
BzrError.__init__(self, format=format, url=url)
3179
class NoSuchView(BzrError):
3180
"""A view does not exist.
3183
_fmt = u"No such view: %(view_name)s."
3185
def __init__(self, view_name):
3186
self.view_name = view_name
3189
class ViewsNotSupported(BzrError):
3190
"""Views are not supported by a tree format.
3193
_fmt = ("Views are not supported by %(tree)s;"
3194
" use 'bzr upgrade' to change your tree to a later format.")
3196
def __init__(self, tree):
3200
class FileOutsideView(BzrError):
3202
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3205
def __init__(self, file_name, view_files):
3206
self.file_name = file_name
3207
self.view_str = ", ".join(view_files)
3210
class UnresumableWriteGroup(BzrError):
3212
_fmt = ("Repository %(repository)s cannot resume write group "
3213
"%(write_groups)r: %(reason)s")
3215
internal_error = True
3217
def __init__(self, repository, write_groups, reason):
3218
self.repository = repository
3219
self.write_groups = write_groups
3220
self.reason = reason
3223
class UnsuspendableWriteGroup(BzrError):
3225
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3227
internal_error = True
3229
def __init__(self, repository):
3230
self.repository = repository
3233
class LossyPushToSameVCS(BzrError):
3235
_fmt = ("Lossy push not possible between %(source_branch)r and "
3236
"%(target_branch)r that are in the same VCS.")
3238
internal_error = True
3240
def __init__(self, source_branch, target_branch):
3241
self.source_branch = source_branch
3242
self.target_branch = target_branch
3245
class NoRoundtrippingSupport(BzrError):
3247
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3248
"%(target_branch)r.")
3250
internal_error = True
3252
def __init__(self, source_branch, target_branch):
3253
self.source_branch = source_branch
3254
self.target_branch = target_branch
3257
class FileTimestampUnavailable(BzrError):
3259
_fmt = "The filestamp for %(path)s is not available."
3261
internal_error = True
3263
def __init__(self, path):
3267
class NoColocatedBranchSupport(BzrError):
3269
_fmt = ("%(bzrdir)r does not support co-located branches.")
3271
def __init__(self, bzrdir):
3272
self.bzrdir = bzrdir
3275
class NoWhoami(BzrError):
3277
_fmt = ('Unable to determine your name.\n'
3278
"Please, set your name with the 'whoami' command.\n"
3279
'E.g. bzr whoami "Your Name <name@example.com>"')
3282
class InvalidPattern(BzrError):
3284
_fmt = ('Invalid pattern(s) found. %(msg)s')
3286
def __init__(self, msg):
3290
class RecursiveBind(BzrError):
3292
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3293
'Please use `bzr unbind` to fix.')
3295
def __init__(self, branch_url):
3296
self.branch_url = branch_url
3299
# FIXME: I would prefer to define the config related exception classes in
3300
# config.py but the lazy import mechanism proscribes this -- vila 20101222
3301
class OptionExpansionLoop(BzrError):
3303
_fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
3305
def __init__(self, string, refs):
3306
self.string = string
3307
self.refs = '->'.join(refs)
3310
class ExpandingUnknownOption(BzrError):
3312
_fmt = 'Option %(name)s is not defined while expanding "%(string)s".'
3314
def __init__(self, name, string):
3316
self.string = string
3319
class NoCompatibleInter(BzrError):
3321
_fmt = ('No compatible object available for operations from %(source)r '
3324
def __init__(self, source, target):
3325
self.source = source
3326
self.target = target