1473
1724
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1475
def __init__(self, source, target, is_permament=False, qual_proto=None):
1726
def __init__(self, source, target, is_permanent=False):
1476
1727
self.source = source
1477
1728
self.target = target
1479
1730
self.permanently = ' permanently'
1481
1732
self.permanently = ''
1482
self.is_permament = is_permament
1483
self._qualified_proto = qual_proto
1484
1733
TransportError.__init__(self)
1486
def _requalify_url(self, url):
1487
"""Restore the qualified proto in front of the url"""
1488
# When this exception is raised, source and target are in
1489
# user readable format. But some transports may use a
1490
# different proto (http+urllib:// will present http:// to
1491
# the user. If a qualified proto is specified, the code
1492
# trapping the exception can get the qualified urls to
1493
# properly handle the redirection themself (creating a
1494
# new transport object from the target url for example).
1495
# But checking that the scheme of the original and
1496
# redirected urls are the same can be tricky. (see the
1497
# FIXME in BzrDir.open_from_transport for the unique use
1499
if self._qualified_proto is None:
1502
# The TODO related to NotBranchError mention that doing
1503
# that kind of manipulation on the urls may not be the
1504
# exception object job. On the other hand, this object is
1505
# the interface between the code and the user so
1506
# presenting the urls in different ways is indeed its
1509
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1510
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1513
def get_source_url(self):
1514
return self._requalify_url(self.source)
1516
def get_target_url(self):
1517
return self._requalify_url(self.target)
1520
1736
class TooManyRedirections(TransportError):
1522
1738
_fmt = "Too many redirections"
1524
1741
class ConflictsInTree(BzrError):
1526
1743
_fmt = "Working tree has conflicts."
2398
2771
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2400
2773
_fmt = "Please specify smtp_server. No server at default %(host)s."
2776
class BzrDirError(BzrError):
2778
def __init__(self, bzrdir):
2779
import bzrlib.urlutils as urlutils
2780
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2782
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2785
class UnsyncedBranches(BzrDirError):
2787
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2788
" bzr help sync-for-reconfigure.")
2790
def __init__(self, bzrdir, target_branch):
2791
BzrDirError.__init__(self, bzrdir)
2792
import bzrlib.urlutils as urlutils
2793
self.target_url = urlutils.unescape_for_display(target_branch.base,
2797
class AlreadyBranch(BzrDirError):
2799
_fmt = "'%(display_url)s' is already a branch."
2802
class AlreadyTree(BzrDirError):
2804
_fmt = "'%(display_url)s' is already a tree."
2807
class AlreadyCheckout(BzrDirError):
2809
_fmt = "'%(display_url)s' is already a checkout."
2812
class AlreadyLightweightCheckout(BzrDirError):
2814
_fmt = "'%(display_url)s' is already a lightweight checkout."
2817
class AlreadyUsingShared(BzrDirError):
2819
_fmt = "'%(display_url)s' is already using a shared repository."
2822
class AlreadyStandalone(BzrDirError):
2824
_fmt = "'%(display_url)s' is already standalone."
2827
class AlreadyWithTrees(BzrDirError):
2829
_fmt = ("Shared repository '%(display_url)s' already creates "
2833
class AlreadyWithNoTrees(BzrDirError):
2835
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2839
class ReconfigurationNotSupported(BzrDirError):
2841
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2844
class NoBindLocation(BzrDirError):
2846
_fmt = "No location could be found to bind to at %(display_url)s."
2849
class UncommittedChanges(BzrError):
2851
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2852
' (See bzr status).%(more)s')
2854
def __init__(self, tree, more=None):
2859
import bzrlib.urlutils as urlutils
2860
user_url = getattr(tree, "user_url", None)
2861
if user_url is None:
2862
display_url = str(tree)
2864
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2865
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2868
class ShelvedChanges(UncommittedChanges):
2870
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2871
' (See bzr shelve --list).%(more)s')
2874
class MissingTemplateVariable(BzrError):
2876
_fmt = 'Variable {%(name)s} is not available.'
2878
def __init__(self, name):
2882
class NoTemplate(BzrError):
2884
_fmt = 'No template specified.'
2887
class UnableCreateSymlink(BzrError):
2889
_fmt = 'Unable to create symlink %(path_str)son this platform'
2891
def __init__(self, path=None):
2895
path_str = repr(str(path))
2896
except UnicodeEncodeError:
2897
path_str = repr(path)
2899
self.path_str = path_str
2902
class UnsupportedTimezoneFormat(BzrError):
2904
_fmt = ('Unsupported timezone format "%(timezone)s", '
2905
'options are "utc", "original", "local".')
2907
def __init__(self, timezone):
2908
self.timezone = timezone
2911
class CommandAvailableInPlugin(StandardError):
2913
internal_error = False
2915
def __init__(self, cmd_name, plugin_metadata, provider):
2917
self.plugin_metadata = plugin_metadata
2918
self.cmd_name = cmd_name
2919
self.provider = provider
2923
_fmt = ('"%s" is not a standard bzr command. \n'
2924
'However, the following official plugin provides this command: %s\n'
2925
'You can install it by going to: %s'
2926
% (self.cmd_name, self.plugin_metadata['name'],
2927
self.plugin_metadata['url']))
2932
class NoPluginAvailable(BzrError):
2936
class UnableEncodePath(BzrError):
2938
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2939
'user encoding %(user_encoding)s')
2941
def __init__(self, path, kind):
2942
from bzrlib.osutils import get_user_encoding
2945
self.user_encoding = osutils.get_user_encoding()
2948
class NoSuchAlias(BzrError):
2950
_fmt = ('The alias "%(alias_name)s" does not exist.')
2952
def __init__(self, alias_name):
2953
BzrError.__init__(self, alias_name=alias_name)
2956
class DirectoryLookupFailure(BzrError):
2957
"""Base type for lookup errors."""
2962
class InvalidLocationAlias(DirectoryLookupFailure):
2964
_fmt = '"%(alias_name)s" is not a valid location alias.'
2966
def __init__(self, alias_name):
2967
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2970
class UnsetLocationAlias(DirectoryLookupFailure):
2972
_fmt = 'No %(alias_name)s location assigned.'
2974
def __init__(self, alias_name):
2975
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2978
class CannotBindAddress(BzrError):
2980
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2982
def __init__(self, host, port, orig_error):
2983
# nb: in python2.4 socket.error doesn't have a useful repr
2984
BzrError.__init__(self, host=host, port=port,
2985
orig_error=repr(orig_error.args))
2988
class UnknownRules(BzrError):
2990
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2992
def __init__(self, unknowns):
2993
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2996
class HookFailed(BzrError):
2997
"""Raised when a pre_change_branch_tip hook function fails anything other
2998
than TipChangeRejected.
3000
Note that this exception is no longer raised, and the import is only left
3001
to be nice to code which might catch it in a plugin.
3004
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
3005
"%(traceback_text)s%(exc_value)s")
3007
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
3009
symbol_versioning.warn("BzrError HookFailed has been deprecated "
3010
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
3012
self.hook_stage = hook_stage
3013
self.hook_name = hook_name
3014
self.exc_info = exc_info
3015
self.exc_type = exc_info[0]
3016
self.exc_value = exc_info[1]
3017
self.exc_tb = exc_info[2]
3018
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3021
class TipChangeRejected(BzrError):
3022
"""A pre_change_branch_tip hook function may raise this to cleanly and
3023
explicitly abort a change to a branch tip.
3026
_fmt = u"Tip change rejected: %(msg)s"
3028
def __init__(self, msg):
3032
class ShelfCorrupt(BzrError):
3034
_fmt = "Shelf corrupt."
3037
class NoSuchShelfId(BzrError):
3039
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3041
def __init__(self, shelf_id):
3042
BzrError.__init__(self, shelf_id=shelf_id)
3045
class InvalidShelfId(BzrError):
3047
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3049
def __init__(self, invalid_id):
3050
BzrError.__init__(self, invalid_id=invalid_id)
3053
class JailBreak(BzrError):
3055
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3057
def __init__(self, url):
3058
BzrError.__init__(self, url=url)
3061
class UserAbort(BzrError):
3063
_fmt = 'The user aborted the operation.'
3066
class MustHaveWorkingTree(BzrError):
3068
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3070
def __init__(self, format, url):
3071
BzrError.__init__(self, format=format, url=url)
3074
class NoSuchView(BzrError):
3075
"""A view does not exist.
3078
_fmt = u"No such view: %(view_name)s."
3080
def __init__(self, view_name):
3081
self.view_name = view_name
3084
class ViewsNotSupported(BzrError):
3085
"""Views are not supported by a tree format.
3088
_fmt = ("Views are not supported by %(tree)s;"
3089
" use 'bzr upgrade' to change your tree to a later format.")
3091
def __init__(self, tree):
3095
class FileOutsideView(BzrError):
3097
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3100
def __init__(self, file_name, view_files):
3101
self.file_name = file_name
3102
self.view_str = ", ".join(view_files)
3105
class UnresumableWriteGroup(BzrError):
3107
_fmt = ("Repository %(repository)s cannot resume write group "
3108
"%(write_groups)r: %(reason)s")
3110
internal_error = True
3112
def __init__(self, repository, write_groups, reason):
3113
self.repository = repository
3114
self.write_groups = write_groups
3115
self.reason = reason
3118
class UnsuspendableWriteGroup(BzrError):
3120
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3122
internal_error = True
3124
def __init__(self, repository):
3125
self.repository = repository
3128
class LossyPushToSameVCS(BzrError):
3130
_fmt = ("Lossy push not possible between %(source_branch)r and "
3131
"%(target_branch)r that are in the same VCS.")
3133
internal_error = True
3135
def __init__(self, source_branch, target_branch):
3136
self.source_branch = source_branch
3137
self.target_branch = target_branch
3140
class NoRoundtrippingSupport(BzrError):
3142
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3143
"%(target_branch)r.")
3145
internal_error = True
3147
def __init__(self, source_branch, target_branch):
3148
self.source_branch = source_branch
3149
self.target_branch = target_branch
3152
class FileTimestampUnavailable(BzrError):
3154
_fmt = "The filestamp for %(path)s is not available."
3156
internal_error = True
3158
def __init__(self, path):
3162
class NoColocatedBranchSupport(BzrError):
3164
_fmt = ("%(bzrdir)r does not support co-located branches.")
3166
def __init__(self, bzrdir):
3167
self.bzrdir = bzrdir
3170
class NoWhoami(BzrError):
3172
_fmt = ('Unable to determine your name.\n'
3173
"Please, set your name with the 'whoami' command.\n"
3174
'E.g. bzr whoami "Your Name <name@example.com>"')
3177
class InvalidPattern(BzrError):
3179
_fmt = ('Invalid pattern(s) found. %(msg)s')
3181
def __init__(self, msg):
3185
class RecursiveBind(BzrError):
3187
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3188
'Please use `bzr unbind` to fix.')
3190
def __init__(self, branch_url):
3191
self.branch_url = branch_url