1771
1442
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1773
def __init__(self, source, target, is_permanent=False):
1444
def __init__(self, source, target, is_permament=False, qual_proto=None):
1774
1445
self.source = source
1775
1446
self.target = target
1777
1448
self.permanently = ' permanently'
1779
1450
self.permanently = ''
1451
self.is_permament = is_permament
1452
self._qualified_proto = qual_proto
1780
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)
1783
1489
class TooManyRedirections(TransportError):
1785
1491
_fmt = "Too many redirections"
1788
1493
class ConflictsInTree(BzrError):
1790
1495
_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
1802
1498
class ParseConfigError(BzrError):
1804
_fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
1806
1500
def __init__(self, errors, filename):
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)
1501
if filename is None:
1503
message = "Error(s) parsing config file %s:\n%s" % \
1504
(filename, ('\n'.join(e.message for e in errors)))
1505
BzrError.__init__(self, message)
1820
1508
class NoEmailInUsername(BzrError):
2822
2309
def __init__(self, error):
2823
2310
self.error = 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