532
460
class NotADirectory(PathError):
534
_fmt = '"%(path)s" is not a directory %(extra)s'
462
_fmt = "%(path)r is not a directory %(extra)s"
537
465
class NotInWorkingDirectory(PathError):
539
_fmt = '"%(path)s" is not in the working directory %(extra)s'
467
_fmt = "%(path)r is not in the working directory %(extra)s"
542
470
class DirectoryNotEmpty(PathError):
544
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
547
class HardLinkNotSupported(PathError):
549
_fmt = 'Hard-linking "%(path)s" is not supported'
552
class ReadingCompleted(InternalBzrError):
472
_fmt = "Directory not empty: %(path)r%(extra)s"
475
class ReadingCompleted(BzrError):
554
477
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
555
478
"called upon it - the request has been completed and no more "
556
479
"data may be read.")
481
internal_error = True
558
483
def __init__(self, request):
559
484
self.request = request
562
487
class ResourceBusy(PathError):
564
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
489
_fmt = "Device or resource busy: %(path)r%(extra)s"
567
492
class PermissionDenied(PathError):
569
_fmt = 'Permission denied: "%(path)s"%(extra)s'
494
_fmt = "Permission denied: %(path)r%(extra)s"
572
497
class InvalidURL(PathError):
574
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
499
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
577
502
class InvalidURLJoin(PathError):
579
_fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r"
581
def __init__(self, reason, base, join_args):
584
self.join_args = join_args
585
PathError.__init__(self, base, reason)
588
class InvalidRebaseURLs(PathError):
590
_fmt = "URLs differ by more than path: %(from_)r and %(to)r"
592
def __init__(self, from_, to):
595
PathError.__init__(self, from_, 'URLs differ by more than path.')
598
class UnavailableRepresentation(InternalBzrError):
600
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
601
"is encoded as '%(native)s'.")
603
def __init__(self, key, wanted, native):
604
InternalBzrError.__init__(self)
504
_fmt = "Invalid URL join request: %(args)s%(extra)s"
506
def __init__(self, msg, base, args):
507
PathError.__init__(self, base, msg)
508
self.args = [base] + list(args)
610
511
class UnknownHook(BzrError):
1751
1442
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1753
def __init__(self, source, target, is_permanent=False):
1444
def __init__(self, source, target, is_permament=False, qual_proto=None):
1754
1445
self.source = source
1755
1446
self.target = target
1757
1448
self.permanently = ' permanently'
1759
1450
self.permanently = ''
1451
self.is_permament = is_permament
1452
self._qualified_proto = qual_proto
1760
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)
1763
1489
class TooManyRedirections(TransportError):
1765
1491
_fmt = "Too many redirections"
1768
1493
class ConflictsInTree(BzrError):
1770
1495
_fmt = "Working tree has conflicts."
1773
class ConfigContentError(BzrError):
1775
_fmt = "Config file %(filename)s is not UTF-8 encoded\n"
1777
def __init__(self, filename):
1778
BzrError.__init__(self)
1779
self.filename = filename
1782
1498
class ParseConfigError(BzrError):
1784
_fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
1786
1500
def __init__(self, errors, filename):
1787
BzrError.__init__(self)
1788
self.filename = filename
1789
self.errors = '\n'.join(e.msg for e in errors)
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)
1792
1508
class NoEmailInUsername(BzrError):
2786
2309
def __init__(self, error):
2787
2310
self.error = error
2790
class NoMessageSupplied(BzrError):
2792
_fmt = "No message supplied."
2795
class NoMailAddressSpecified(BzrError):
2797
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2800
class UnknownMailClient(BzrError):
2802
_fmt = "Unknown mail client: %(mail_client)s"
2804
def __init__(self, mail_client):
2805
BzrError.__init__(self, mail_client=mail_client)
2808
class MailClientNotFound(BzrError):
2810
_fmt = "Unable to find mail client with the following names:"\
2811
" %(mail_command_list_string)s"
2813
def __init__(self, mail_command_list):
2814
mail_command_list_string = ', '.join(mail_command_list)
2815
BzrError.__init__(self, mail_command_list=mail_command_list,
2816
mail_command_list_string=mail_command_list_string)
2818
class SMTPConnectionRefused(SMTPError):
2820
_fmt = "SMTP connection to %(host)s refused"
2822
def __init__(self, error, host):
2827
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2829
_fmt = "Please specify smtp_server. No server at default %(host)s."
2832
class BzrDirError(BzrError):
2834
def __init__(self, bzrdir):
2835
import bzrlib.urlutils as urlutils
2836
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2838
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2841
class UnsyncedBranches(BzrDirError):
2843
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2844
" bzr help sync-for-reconfigure.")
2846
def __init__(self, bzrdir, target_branch):
2847
BzrDirError.__init__(self, bzrdir)
2848
import bzrlib.urlutils as urlutils
2849
self.target_url = urlutils.unescape_for_display(target_branch.base,
2853
class AlreadyBranch(BzrDirError):
2855
_fmt = "'%(display_url)s' is already a branch."
2858
class AlreadyTree(BzrDirError):
2860
_fmt = "'%(display_url)s' is already a tree."
2863
class AlreadyCheckout(BzrDirError):
2865
_fmt = "'%(display_url)s' is already a checkout."
2868
class AlreadyLightweightCheckout(BzrDirError):
2870
_fmt = "'%(display_url)s' is already a lightweight checkout."
2873
class AlreadyUsingShared(BzrDirError):
2875
_fmt = "'%(display_url)s' is already using a shared repository."
2878
class AlreadyStandalone(BzrDirError):
2880
_fmt = "'%(display_url)s' is already standalone."
2883
class AlreadyWithTrees(BzrDirError):
2885
_fmt = ("Shared repository '%(display_url)s' already creates "
2889
class AlreadyWithNoTrees(BzrDirError):
2891
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2895
class ReconfigurationNotSupported(BzrDirError):
2897
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2900
class NoBindLocation(BzrDirError):
2902
_fmt = "No location could be found to bind to at %(display_url)s."
2905
class UncommittedChanges(BzrError):
2907
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2908
' (See bzr status).%(more)s')
2910
def __init__(self, tree, more=None):
2915
import bzrlib.urlutils as urlutils
2916
user_url = getattr(tree, "user_url", None)
2917
if user_url is None:
2918
display_url = str(tree)
2920
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2921
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2924
class ShelvedChanges(UncommittedChanges):
2926
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2927
' (See bzr shelve --list).%(more)s')
2930
class MissingTemplateVariable(BzrError):
2932
_fmt = 'Variable {%(name)s} is not available.'
2934
def __init__(self, name):
2938
class NoTemplate(BzrError):
2940
_fmt = 'No template specified.'
2943
class UnableCreateSymlink(BzrError):
2945
_fmt = 'Unable to create symlink %(path_str)son this platform'
2947
def __init__(self, path=None):
2951
path_str = repr(str(path))
2952
except UnicodeEncodeError:
2953
path_str = repr(path)
2955
self.path_str = path_str
2958
class UnsupportedTimezoneFormat(BzrError):
2960
_fmt = ('Unsupported timezone format "%(timezone)s", '
2961
'options are "utc", "original", "local".')
2963
def __init__(self, timezone):
2964
self.timezone = timezone
2967
class CommandAvailableInPlugin(StandardError):
2969
internal_error = False
2971
def __init__(self, cmd_name, plugin_metadata, provider):
2973
self.plugin_metadata = plugin_metadata
2974
self.cmd_name = cmd_name
2975
self.provider = provider
2979
_fmt = ('"%s" is not a standard bzr command. \n'
2980
'However, the following official plugin provides this command: %s\n'
2981
'You can install it by going to: %s'
2982
% (self.cmd_name, self.plugin_metadata['name'],
2983
self.plugin_metadata['url']))
2988
class NoPluginAvailable(BzrError):
2992
class UnableEncodePath(BzrError):
2994
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2995
'user encoding %(user_encoding)s')
2997
def __init__(self, path, kind):
2998
from bzrlib.osutils import get_user_encoding
3001
self.user_encoding = osutils.get_user_encoding()
3004
class NoSuchConfig(BzrError):
3006
_fmt = ('The "%(config_id)s" configuration does not exist.')
3008
def __init__(self, config_id):
3009
BzrError.__init__(self, config_id=config_id)
3012
class NoSuchConfigOption(BzrError):
3014
_fmt = ('The "%(option_name)s" configuration option does not exist.')
3016
def __init__(self, option_name):
3017
BzrError.__init__(self, option_name=option_name)
3020
class NoSuchAlias(BzrError):
3022
_fmt = ('The alias "%(alias_name)s" does not exist.')
3024
def __init__(self, alias_name):
3025
BzrError.__init__(self, alias_name=alias_name)
3028
class DirectoryLookupFailure(BzrError):
3029
"""Base type for lookup errors."""
3034
class InvalidLocationAlias(DirectoryLookupFailure):
3036
_fmt = '"%(alias_name)s" is not a valid location alias.'
3038
def __init__(self, alias_name):
3039
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
3042
class UnsetLocationAlias(DirectoryLookupFailure):
3044
_fmt = 'No %(alias_name)s location assigned.'
3046
def __init__(self, alias_name):
3047
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
3050
class CannotBindAddress(BzrError):
3052
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
3054
def __init__(self, host, port, orig_error):
3055
# nb: in python2.4 socket.error doesn't have a useful repr
3056
BzrError.__init__(self, host=host, port=port,
3057
orig_error=repr(orig_error.args))
3060
class UnknownRules(BzrError):
3062
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
3064
def __init__(self, unknowns):
3065
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
3068
class HookFailed(BzrError):
3069
"""Raised when a pre_change_branch_tip hook function fails anything other
3070
than TipChangeRejected.
3072
Note that this exception is no longer raised, and the import is only left
3073
to be nice to code which might catch it in a plugin.
3076
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
3077
"%(traceback_text)s%(exc_value)s")
3079
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
3081
symbol_versioning.warn("BzrError HookFailed has been deprecated "
3082
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
3084
self.hook_stage = hook_stage
3085
self.hook_name = hook_name
3086
self.exc_info = exc_info
3087
self.exc_type = exc_info[0]
3088
self.exc_value = exc_info[1]
3089
self.exc_tb = exc_info[2]
3090
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3093
class TipChangeRejected(BzrError):
3094
"""A pre_change_branch_tip hook function may raise this to cleanly and
3095
explicitly abort a change to a branch tip.
3098
_fmt = u"Tip change rejected: %(msg)s"
3100
def __init__(self, msg):
3104
class ShelfCorrupt(BzrError):
3106
_fmt = "Shelf corrupt."
3109
class DecompressCorruption(BzrError):
3111
_fmt = "Corruption while decompressing repository file%(orig_error)s"
3113
def __init__(self, orig_error=None):
3114
if orig_error is not None:
3115
self.orig_error = ", %s" % (orig_error,)
3117
self.orig_error = ""
3118
BzrError.__init__(self)
3121
class NoSuchShelfId(BzrError):
3123
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3125
def __init__(self, shelf_id):
3126
BzrError.__init__(self, shelf_id=shelf_id)
3129
class InvalidShelfId(BzrError):
3131
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3133
def __init__(self, invalid_id):
3134
BzrError.__init__(self, invalid_id=invalid_id)
3137
class JailBreak(BzrError):
3139
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3141
def __init__(self, url):
3142
BzrError.__init__(self, url=url)
3145
class UserAbort(BzrError):
3147
_fmt = 'The user aborted the operation.'
3150
class MustHaveWorkingTree(BzrError):
3152
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3154
def __init__(self, format, url):
3155
BzrError.__init__(self, format=format, url=url)
3158
class NoSuchView(BzrError):
3159
"""A view does not exist.
3162
_fmt = u"No such view: %(view_name)s."
3164
def __init__(self, view_name):
3165
self.view_name = view_name
3168
class ViewsNotSupported(BzrError):
3169
"""Views are not supported by a tree format.
3172
_fmt = ("Views are not supported by %(tree)s;"
3173
" use 'bzr upgrade' to change your tree to a later format.")
3175
def __init__(self, tree):
3179
class FileOutsideView(BzrError):
3181
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3184
def __init__(self, file_name, view_files):
3185
self.file_name = file_name
3186
self.view_str = ", ".join(view_files)
3189
class UnresumableWriteGroup(BzrError):
3191
_fmt = ("Repository %(repository)s cannot resume write group "
3192
"%(write_groups)r: %(reason)s")
3194
internal_error = True
3196
def __init__(self, repository, write_groups, reason):
3197
self.repository = repository
3198
self.write_groups = write_groups
3199
self.reason = reason
3202
class UnsuspendableWriteGroup(BzrError):
3204
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3206
internal_error = True
3208
def __init__(self, repository):
3209
self.repository = repository
3212
class LossyPushToSameVCS(BzrError):
3214
_fmt = ("Lossy push not possible between %(source_branch)r and "
3215
"%(target_branch)r that are in the same VCS.")
3217
internal_error = True
3219
def __init__(self, source_branch, target_branch):
3220
self.source_branch = source_branch
3221
self.target_branch = target_branch
3224
class NoRoundtrippingSupport(BzrError):
3226
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3227
"%(target_branch)r.")
3229
internal_error = True
3231
def __init__(self, source_branch, target_branch):
3232
self.source_branch = source_branch
3233
self.target_branch = target_branch
3236
class FileTimestampUnavailable(BzrError):
3238
_fmt = "The filestamp for %(path)s is not available."
3240
internal_error = True
3242
def __init__(self, path):
3246
class NoColocatedBranchSupport(BzrError):
3248
_fmt = ("%(bzrdir)r does not support co-located branches.")
3250
def __init__(self, bzrdir):
3251
self.bzrdir = bzrdir
3254
class NoWhoami(BzrError):
3256
_fmt = ('Unable to determine your name.\n'
3257
"Please, set your name with the 'whoami' command.\n"
3258
'E.g. bzr whoami "Your Name <name@example.com>"')
3261
class InvalidPattern(BzrError):
3263
_fmt = ('Invalid pattern(s) found. %(msg)s')
3265
def __init__(self, msg):
3269
class RecursiveBind(BzrError):
3271
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3272
'Please use `bzr unbind` to fix.')
3274
def __init__(self, branch_url):
3275
self.branch_url = branch_url
3278
# FIXME: I would prefer to define the config related exception classes in
3279
# config.py but the lazy import mechanism proscribes this -- vila 20101222
3280
class OptionExpansionLoop(BzrError):
3282
_fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
3284
def __init__(self, string, refs):
3285
self.string = string
3286
self.refs = '->'.join(refs)
3289
class ExpandingUnknownOption(BzrError):
3291
_fmt = 'Option %(name)s is not defined while expanding "%(string)s".'
3293
def __init__(self, name, string):
3295
self.string = string
3298
class NoCompatibleInter(BzrError):
3300
_fmt = ('No compatible object available for operations from %(source)r '
3303
def __init__(self, source, target):
3304
self.source = source
3305
self.target = target