1473
1715
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1475
def __init__(self, source, target, is_permament=False, qual_proto=None):
1717
def __init__(self, source, target, is_permanent=False):
1476
1718
self.source = source
1477
1719
self.target = target
1479
1721
self.permanently = ' permanently'
1481
1723
self.permanently = ''
1482
self.is_permament = is_permament
1483
self._qualified_proto = qual_proto
1484
1724
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
1727
class TooManyRedirections(TransportError):
1522
1729
_fmt = "Too many redirections"
1524
1732
class ConflictsInTree(BzrError):
1526
1734
_fmt = "Working tree has conflicts."
2398
2760
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2400
2762
_fmt = "Please specify smtp_server. No server at default %(host)s."
2765
class BzrDirError(BzrError):
2767
def __init__(self, bzrdir):
2768
import bzrlib.urlutils as urlutils
2769
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2771
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2774
class UnsyncedBranches(BzrDirError):
2776
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2777
" bzr help sync-for-reconfigure.")
2779
def __init__(self, bzrdir, target_branch):
2780
BzrDirError.__init__(self, bzrdir)
2781
import bzrlib.urlutils as urlutils
2782
self.target_url = urlutils.unescape_for_display(target_branch.base,
2786
class AlreadyBranch(BzrDirError):
2788
_fmt = "'%(display_url)s' is already a branch."
2791
class AlreadyTree(BzrDirError):
2793
_fmt = "'%(display_url)s' is already a tree."
2796
class AlreadyCheckout(BzrDirError):
2798
_fmt = "'%(display_url)s' is already a checkout."
2801
class AlreadyLightweightCheckout(BzrDirError):
2803
_fmt = "'%(display_url)s' is already a lightweight checkout."
2806
class AlreadyUsingShared(BzrDirError):
2808
_fmt = "'%(display_url)s' is already using a shared repository."
2811
class AlreadyStandalone(BzrDirError):
2813
_fmt = "'%(display_url)s' is already standalone."
2816
class AlreadyWithTrees(BzrDirError):
2818
_fmt = ("Shared repository '%(display_url)s' already creates "
2822
class AlreadyWithNoTrees(BzrDirError):
2824
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2828
class ReconfigurationNotSupported(BzrDirError):
2830
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2833
class NoBindLocation(BzrDirError):
2835
_fmt = "No location could be found to bind to at %(display_url)s."
2838
class UncommittedChanges(BzrError):
2840
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2841
' (See bzr status).%(more)s')
2843
def __init__(self, tree, more=None):
2848
import bzrlib.urlutils as urlutils
2849
display_url = urlutils.unescape_for_display(
2850
tree.user_url, 'ascii')
2851
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2854
class ShelvedChanges(UncommittedChanges):
2856
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2857
' (See bzr shelve --list).%(more)s')
2860
class MissingTemplateVariable(BzrError):
2862
_fmt = 'Variable {%(name)s} is not available.'
2864
def __init__(self, name):
2868
class NoTemplate(BzrError):
2870
_fmt = 'No template specified.'
2873
class UnableCreateSymlink(BzrError):
2875
_fmt = 'Unable to create symlink %(path_str)son this platform'
2877
def __init__(self, path=None):
2881
path_str = repr(str(path))
2882
except UnicodeEncodeError:
2883
path_str = repr(path)
2885
self.path_str = path_str
2888
class UnsupportedTimezoneFormat(BzrError):
2890
_fmt = ('Unsupported timezone format "%(timezone)s", '
2891
'options are "utc", "original", "local".')
2893
def __init__(self, timezone):
2894
self.timezone = timezone
2897
class CommandAvailableInPlugin(StandardError):
2899
internal_error = False
2901
def __init__(self, cmd_name, plugin_metadata, provider):
2903
self.plugin_metadata = plugin_metadata
2904
self.cmd_name = cmd_name
2905
self.provider = provider
2909
_fmt = ('"%s" is not a standard bzr command. \n'
2910
'However, the following official plugin provides this command: %s\n'
2911
'You can install it by going to: %s'
2912
% (self.cmd_name, self.plugin_metadata['name'],
2913
self.plugin_metadata['url']))
2918
class NoPluginAvailable(BzrError):
2922
class UnableEncodePath(BzrError):
2924
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2925
'user encoding %(user_encoding)s')
2927
def __init__(self, path, kind):
2928
from bzrlib.osutils import get_user_encoding
2931
self.user_encoding = osutils.get_user_encoding()
2934
class NoSuchAlias(BzrError):
2936
_fmt = ('The alias "%(alias_name)s" does not exist.')
2938
def __init__(self, alias_name):
2939
BzrError.__init__(self, alias_name=alias_name)
2942
class DirectoryLookupFailure(BzrError):
2943
"""Base type for lookup errors."""
2948
class InvalidLocationAlias(DirectoryLookupFailure):
2950
_fmt = '"%(alias_name)s" is not a valid location alias.'
2952
def __init__(self, alias_name):
2953
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2956
class UnsetLocationAlias(DirectoryLookupFailure):
2958
_fmt = 'No %(alias_name)s location assigned.'
2960
def __init__(self, alias_name):
2961
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2964
class CannotBindAddress(BzrError):
2966
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2968
def __init__(self, host, port, orig_error):
2969
# nb: in python2.4 socket.error doesn't have a useful repr
2970
BzrError.__init__(self, host=host, port=port,
2971
orig_error=repr(orig_error.args))
2974
class UnknownRules(BzrError):
2976
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2978
def __init__(self, unknowns):
2979
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2982
class HookFailed(BzrError):
2983
"""Raised when a pre_change_branch_tip hook function fails anything other
2984
than TipChangeRejected.
2986
Note that this exception is no longer raised, and the import is only left
2987
to be nice to code which might catch it in a plugin.
2990
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2991
"%(traceback_text)s%(exc_value)s")
2993
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
2995
symbol_versioning.warn("BzrError HookFailed has been deprecated "
2996
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
2998
self.hook_stage = hook_stage
2999
self.hook_name = hook_name
3000
self.exc_info = exc_info
3001
self.exc_type = exc_info[0]
3002
self.exc_value = exc_info[1]
3003
self.exc_tb = exc_info[2]
3004
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3007
class TipChangeRejected(BzrError):
3008
"""A pre_change_branch_tip hook function may raise this to cleanly and
3009
explicitly abort a change to a branch tip.
3012
_fmt = u"Tip change rejected: %(msg)s"
3014
def __init__(self, msg):
3018
class ShelfCorrupt(BzrError):
3020
_fmt = "Shelf corrupt."
3023
class NoSuchShelfId(BzrError):
3025
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3027
def __init__(self, shelf_id):
3028
BzrError.__init__(self, shelf_id=shelf_id)
3031
class InvalidShelfId(BzrError):
3033
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3035
def __init__(self, invalid_id):
3036
BzrError.__init__(self, invalid_id=invalid_id)
3039
class JailBreak(BzrError):
3041
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3043
def __init__(self, url):
3044
BzrError.__init__(self, url=url)
3047
class UserAbort(BzrError):
3049
_fmt = 'The user aborted the operation.'
3052
class MustHaveWorkingTree(BzrError):
3054
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3056
def __init__(self, format, url):
3057
BzrError.__init__(self, format=format, url=url)
3060
class NoSuchView(BzrError):
3061
"""A view does not exist.
3064
_fmt = u"No such view: %(view_name)s."
3066
def __init__(self, view_name):
3067
self.view_name = view_name
3070
class ViewsNotSupported(BzrError):
3071
"""Views are not supported by a tree format.
3074
_fmt = ("Views are not supported by %(tree)s;"
3075
" use 'bzr upgrade' to change your tree to a later format.")
3077
def __init__(self, tree):
3081
class FileOutsideView(BzrError):
3083
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3086
def __init__(self, file_name, view_files):
3087
self.file_name = file_name
3088
self.view_str = ", ".join(view_files)
3091
class UnresumableWriteGroup(BzrError):
3093
_fmt = ("Repository %(repository)s cannot resume write group "
3094
"%(write_groups)r: %(reason)s")
3096
internal_error = True
3098
def __init__(self, repository, write_groups, reason):
3099
self.repository = repository
3100
self.write_groups = write_groups
3101
self.reason = reason
3104
class UnsuspendableWriteGroup(BzrError):
3106
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3108
internal_error = True
3110
def __init__(self, repository):
3111
self.repository = repository
3114
class LossyPushToSameVCS(BzrError):
3116
_fmt = ("Lossy push not possible between %(source_branch)r and "
3117
"%(target_branch)r that are in the same VCS.")
3119
internal_error = True
3121
def __init__(self, source_branch, target_branch):
3122
self.source_branch = source_branch
3123
self.target_branch = target_branch
3126
class NoRoundtrippingSupport(BzrError):
3128
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3129
"%(target_branch)r.")
3131
internal_error = True
3133
def __init__(self, source_branch, target_branch):
3134
self.source_branch = source_branch
3135
self.target_branch = target_branch
3138
class FileTimestampUnavailable(BzrError):
3140
_fmt = "The filestamp for %(path)s is not available."
3142
internal_error = True
3144
def __init__(self, path):
3148
class NoColocatedBranchSupport(BzrError):
3150
_fmt = ("%(bzrdir)r does not support co-located branches.")
3152
def __init__(self, bzrdir):
3153
self.bzrdir = bzrdir
3155
class NoWhoami(BzrError):
3157
_fmt = ('Unable to determine your name.\n'
3158
"Please, set your name with the 'whoami' command.\n"
3159
'E.g. bzr whoami "Your Name <name@example.com>"')
3161
class InvalidPattern(BzrError):
3163
_fmt = ('Invalid pattern(s) found. %(msg)s')
3165
def __init__(self, msg):