2639
2055
class TagsNotSupported(BzrError):
2641
2057
_fmt = ("Tags not supported by %(branch)s;"
2642
" you may be able to use bzr upgrade.")
2058
" you may be able to use bzr upgrade --dirstate-tags.")
2644
2060
def __init__(self, branch):
2645
2061
self.branch = branch
2648
2064
class TagAlreadyExists(BzrError):
2650
2066
_fmt = "Tag %(tag_name)s already exists."
2652
2068
def __init__(self, tag_name):
2653
2069
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