1350
1494
self.options = options
1497
class RetryWithNewPacks(BzrError):
1498
"""Raised when we realize that the packs on disk have changed.
1500
This is meant as more of a signaling exception, to trap between where a
1501
local error occurred and the code that can actually handle the error and
1502
code that can retry appropriately.
1505
internal_error = True
1507
_fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1510
def __init__(self, context, reload_occurred, exc_info):
1511
"""create a new RetryWithNewPacks error.
1513
:param reload_occurred: Set to True if we know that the packs have
1514
already been reloaded, and we are failing because of an in-memory
1515
cache miss. If set to True then we will ignore if a reload says
1516
nothing has changed, because we assume it has already reloaded. If
1517
False, then a reload with nothing changed will force an error.
1518
:param exc_info: The original exception traceback, so if there is a
1519
problem we can raise the original error (value from sys.exc_info())
1521
BzrError.__init__(self)
1522
self.reload_occurred = reload_occurred
1523
self.exc_info = exc_info
1524
self.orig_error = exc_info[1]
1525
# TODO: The global error handler should probably treat this by
1526
# raising/printing the original exception with a bit about
1527
# RetryWithNewPacks also not being caught
1530
class RetryAutopack(RetryWithNewPacks):
1531
"""Raised when we are autopacking and we find a missing file.
1533
Meant as a signaling exception, to tell the autopack code it should try
1537
internal_error = True
1539
_fmt = ("Pack files have changed, reload and try autopack again."
1540
" context: %(context)s %(orig_error)s")
1353
1543
class NoSuchExportFormat(BzrError):
1355
1545
_fmt = "Export format %(format)r not supported"
1357
1547
def __init__(self, format):
1473
1692
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1475
def __init__(self, source, target, is_permament=False, qual_proto=None):
1694
def __init__(self, source, target, is_permanent=False):
1476
1695
self.source = source
1477
1696
self.target = target
1479
1698
self.permanently = ' permanently'
1481
1700
self.permanently = ''
1482
self.is_permament = is_permament
1483
self._qualified_proto = qual_proto
1484
1701
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
1704
class TooManyRedirections(TransportError):
1522
1706
_fmt = "Too many redirections"
1524
1709
class ConflictsInTree(BzrError):
1526
1711
_fmt = "Working tree has conflicts."
2398
2726
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2400
2728
_fmt = "Please specify smtp_server. No server at default %(host)s."
2731
class BzrDirError(BzrError):
2733
def __init__(self, bzrdir):
2734
import bzrlib.urlutils as urlutils
2735
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2737
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2740
class UnsyncedBranches(BzrDirError):
2742
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2743
" bzr help sync-for-reconfigure.")
2745
def __init__(self, bzrdir, target_branch):
2746
BzrDirError.__init__(self, bzrdir)
2747
import bzrlib.urlutils as urlutils
2748
self.target_url = urlutils.unescape_for_display(target_branch.base,
2752
class AlreadyBranch(BzrDirError):
2754
_fmt = "'%(display_url)s' is already a branch."
2757
class AlreadyTree(BzrDirError):
2759
_fmt = "'%(display_url)s' is already a tree."
2762
class AlreadyCheckout(BzrDirError):
2764
_fmt = "'%(display_url)s' is already a checkout."
2767
class AlreadyLightweightCheckout(BzrDirError):
2769
_fmt = "'%(display_url)s' is already a lightweight checkout."
2772
class AlreadyUsingShared(BzrDirError):
2774
_fmt = "'%(display_url)s' is already using a shared repository."
2777
class AlreadyStandalone(BzrDirError):
2779
_fmt = "'%(display_url)s' is already standalone."
2782
class AlreadyWithTrees(BzrDirError):
2784
_fmt = ("Shared repository '%(display_url)s' already creates "
2788
class AlreadyWithNoTrees(BzrDirError):
2790
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2794
class ReconfigurationNotSupported(BzrDirError):
2796
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2799
class NoBindLocation(BzrDirError):
2801
_fmt = "No location could be found to bind to at %(display_url)s."
2804
class UncommittedChanges(BzrError):
2806
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2807
' (See bzr status).%(more)s')
2809
def __init__(self, tree, more=None):
2814
import bzrlib.urlutils as urlutils
2815
display_url = urlutils.unescape_for_display(
2816
tree.bzrdir.root_transport.base, 'ascii')
2817
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2820
class MissingTemplateVariable(BzrError):
2822
_fmt = 'Variable {%(name)s} is not available.'
2824
def __init__(self, name):
2828
class NoTemplate(BzrError):
2830
_fmt = 'No template specified.'
2833
class UnableCreateSymlink(BzrError):
2835
_fmt = 'Unable to create symlink %(path_str)son this platform'
2837
def __init__(self, path=None):
2841
path_str = repr(str(path))
2842
except UnicodeEncodeError:
2843
path_str = repr(path)
2845
self.path_str = path_str
2848
class UnsupportedTimezoneFormat(BzrError):
2850
_fmt = ('Unsupported timezone format "%(timezone)s", '
2851
'options are "utc", "original", "local".')
2853
def __init__(self, timezone):
2854
self.timezone = timezone
2857
class CommandAvailableInPlugin(StandardError):
2859
internal_error = False
2861
def __init__(self, cmd_name, plugin_metadata, provider):
2863
self.plugin_metadata = plugin_metadata
2864
self.cmd_name = cmd_name
2865
self.provider = provider
2869
_fmt = ('"%s" is not a standard bzr command. \n'
2870
'However, the following official plugin provides this command: %s\n'
2871
'You can install it by going to: %s'
2872
% (self.cmd_name, self.plugin_metadata['name'],
2873
self.plugin_metadata['url']))
2878
class NoPluginAvailable(BzrError):
2882
class UnableEncodePath(BzrError):
2884
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2885
'user encoding %(user_encoding)s')
2887
def __init__(self, path, kind):
2888
from bzrlib.osutils import get_user_encoding
2891
self.user_encoding = osutils.get_user_encoding()
2894
class NoSuchAlias(BzrError):
2896
_fmt = ('The alias "%(alias_name)s" does not exist.')
2898
def __init__(self, alias_name):
2899
BzrError.__init__(self, alias_name=alias_name)
2902
class DirectoryLookupFailure(BzrError):
2903
"""Base type for lookup errors."""
2908
class InvalidLocationAlias(DirectoryLookupFailure):
2910
_fmt = '"%(alias_name)s" is not a valid location alias.'
2912
def __init__(self, alias_name):
2913
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2916
class UnsetLocationAlias(DirectoryLookupFailure):
2918
_fmt = 'No %(alias_name)s location assigned.'
2920
def __init__(self, alias_name):
2921
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2924
class CannotBindAddress(BzrError):
2926
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2928
def __init__(self, host, port, orig_error):
2929
# nb: in python2.4 socket.error doesn't have a useful repr
2930
BzrError.__init__(self, host=host, port=port,
2931
orig_error=repr(orig_error.args))
2934
class UnknownRules(BzrError):
2936
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2938
def __init__(self, unknowns):
2939
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2942
class HookFailed(BzrError):
2943
"""Raised when a pre_change_branch_tip hook function fails anything other
2944
than TipChangeRejected.
2947
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2948
"%(traceback_text)s%(exc_value)s")
2950
def __init__(self, hook_stage, hook_name, exc_info):
2952
self.hook_stage = hook_stage
2953
self.hook_name = hook_name
2954
self.exc_info = exc_info
2955
self.exc_type = exc_info[0]
2956
self.exc_value = exc_info[1]
2957
self.exc_tb = exc_info[2]
2958
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2961
class TipChangeRejected(BzrError):
2962
"""A pre_change_branch_tip hook function may raise this to cleanly and
2963
explicitly abort a change to a branch tip.
2966
_fmt = u"Tip change rejected: %(msg)s"
2968
def __init__(self, msg):
2972
class ShelfCorrupt(BzrError):
2974
_fmt = "Shelf corrupt."
2977
class NoSuchShelfId(BzrError):
2979
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2981
def __init__(self, shelf_id):
2982
BzrError.__init__(self, shelf_id=shelf_id)
2985
class InvalidShelfId(BzrError):
2987
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2989
def __init__(self, invalid_id):
2990
BzrError.__init__(self, invalid_id=invalid_id)
2993
class JailBreak(BzrError):
2995
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2997
def __init__(self, url):
2998
BzrError.__init__(self, url=url)
3001
class UserAbort(BzrError):
3003
_fmt = 'The user aborted the operation.'
3006
class MustHaveWorkingTree(BzrError):
3008
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3010
def __init__(self, format, url):
3011
BzrError.__init__(self, format=format, url=url)
3014
class NoSuchView(BzrError):
3015
"""A view does not exist.
3018
_fmt = u"No such view: %(view_name)s."
3020
def __init__(self, view_name):
3021
self.view_name = view_name
3024
class ViewsNotSupported(BzrError):
3025
"""Views are not supported by a tree format.
3028
_fmt = ("Views are not supported by %(tree)s;"
3029
" use 'bzr upgrade' to change your tree to a later format.")
3031
def __init__(self, tree):
3035
class FileOutsideView(BzrError):
3037
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3040
def __init__(self, file_name, view_files):
3041
self.file_name = file_name
3042
self.view_str = ", ".join(view_files)
3045
class UnresumableWriteGroup(BzrError):
3047
_fmt = ("Repository %(repository)s cannot resume write group "
3048
"%(write_groups)r: %(reason)s")
3050
internal_error = True
3052
def __init__(self, repository, write_groups, reason):
3053
self.repository = repository
3054
self.write_groups = write_groups
3055
self.reason = reason
3058
class UnsuspendableWriteGroup(BzrError):
3060
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3062
internal_error = True
3064
def __init__(self, repository):
3065
self.repository = repository
3068
class LossyPushToSameVCS(BzrError):
3070
_fmt = ("Lossy push not possible between %(source_branch)r and "
3071
"%(target_branch)r that are in the same VCS.")
3073
internal_error = True
3075
def __init__(self, source_branch, target_branch):
3076
self.source_branch = source_branch
3077
self.target_branch = target_branch