2563
2055
class TagsNotSupported(BzrError):
2565
2057
_fmt = ("Tags not supported by %(branch)s;"
2566
" you may be able to use bzr upgrade.")
2058
" you may be able to use bzr upgrade --dirstate-tags.")
2568
2060
def __init__(self, branch):
2569
2061
self.branch = branch
2572
2064
class TagAlreadyExists(BzrError):
2574
2066
_fmt = "Tag %(tag_name)s already exists."
2576
2068
def __init__(self, tag_name):
2577
2069
self.tag_name = tag_name
2580
class MalformedBugIdentifier(BzrError):
2582
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2583
'See "bzr help bugs" for more information on this feature.')
2585
def __init__(self, bug_id, reason):
2586
self.bug_id = bug_id
2587
self.reason = reason
2590
class InvalidBugTrackerURL(BzrError):
2592
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2593
"contain {id}: %(url)s")
2595
def __init__(self, abbreviation, url):
2596
self.abbreviation = abbreviation
2600
class UnknownBugTrackerAbbreviation(BzrError):
2602
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2605
def __init__(self, abbreviation, branch):
2606
self.abbreviation = abbreviation
2607
self.branch = branch
2610
class InvalidLineInBugsProperty(BzrError):
2612
_fmt = ("Invalid line in bugs property: '%(line)s'")
2614
def __init__(self, line):
2618
class InvalidBugStatus(BzrError):
2620
_fmt = ("Invalid bug status: '%(status)s'")
2622
def __init__(self, status):
2623
self.status = status
2626
class UnexpectedSmartServerResponse(BzrError):
2628
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2630
def __init__(self, response_tuple):
2631
self.response_tuple = response_tuple
2634
class ErrorFromSmartServer(BzrError):
2635
"""An error was received from a smart server.
2637
:seealso: UnknownErrorFromSmartServer
2640
_fmt = "Error received from smart server: %(error_tuple)r"
2642
internal_error = True
2644
def __init__(self, error_tuple):
2645
self.error_tuple = error_tuple
2647
self.error_verb = error_tuple[0]
2649
self.error_verb = None
2650
self.error_args = error_tuple[1:]
2653
class UnknownErrorFromSmartServer(BzrError):
2654
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2657
This is distinct from ErrorFromSmartServer so that it is possible to
2658
distinguish between the following two cases:
2659
- ErrorFromSmartServer was uncaught. This is logic error in the client
2660
and so should provoke a traceback to the user.
2661
- ErrorFromSmartServer was caught but its error_tuple could not be
2662
translated. This is probably because the server sent us garbage, and
2663
should not provoke a traceback.
2666
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2668
internal_error = False
2670
def __init__(self, error_from_smart_server):
2673
:param error_from_smart_server: An ErrorFromSmartServer instance.
2675
self.error_from_smart_server = error_from_smart_server
2676
self.error_tuple = error_from_smart_server.error_tuple
2679
class ContainerError(BzrError):
2680
"""Base class of container errors."""
2683
class UnknownContainerFormatError(ContainerError):
2685
_fmt = "Unrecognised container format: %(container_format)r"
2687
def __init__(self, container_format):
2688
self.container_format = container_format
2691
class UnexpectedEndOfContainerError(ContainerError):
2693
_fmt = "Unexpected end of container stream"
2696
class UnknownRecordTypeError(ContainerError):
2698
_fmt = "Unknown record type: %(record_type)r"
2700
def __init__(self, record_type):
2701
self.record_type = record_type
2704
class InvalidRecordError(ContainerError):
2706
_fmt = "Invalid record: %(reason)s"
2708
def __init__(self, reason):
2709
self.reason = reason
2712
class ContainerHasExcessDataError(ContainerError):
2714
_fmt = "Container has data after end marker: %(excess)r"
2716
def __init__(self, excess):
2717
self.excess = excess
2720
class DuplicateRecordNameError(ContainerError):
2722
_fmt = "Container has multiple records with the same name: %(name)s"
2724
def __init__(self, name):
2728
class NoDestinationAddress(InternalBzrError):
2730
_fmt = "Message does not have a destination address."
2733
class RepositoryDataStreamError(BzrError):
2735
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2737
def __init__(self, reason):
2738
self.reason = reason
2741
class SMTPError(BzrError):
2743
_fmt = "SMTP error: %(error)s"
2745
def __init__(self, error):
2749
class NoMessageSupplied(BzrError):
2751
_fmt = "No message supplied."
2754
class NoMailAddressSpecified(BzrError):
2756
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2759
class UnknownMailClient(BzrError):
2761
_fmt = "Unknown mail client: %(mail_client)s"
2763
def __init__(self, mail_client):
2764
BzrError.__init__(self, mail_client=mail_client)
2767
class MailClientNotFound(BzrError):
2769
_fmt = "Unable to find mail client with the following names:"\
2770
" %(mail_command_list_string)s"
2772
def __init__(self, mail_command_list):
2773
mail_command_list_string = ', '.join(mail_command_list)
2774
BzrError.__init__(self, mail_command_list=mail_command_list,
2775
mail_command_list_string=mail_command_list_string)
2777
class SMTPConnectionRefused(SMTPError):
2779
_fmt = "SMTP connection to %(host)s refused"
2781
def __init__(self, error, host):
2786
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2788
_fmt = "Please specify smtp_server. No server at default %(host)s."
2791
class BzrDirError(BzrError):
2793
def __init__(self, bzrdir):
2794
import bzrlib.urlutils as urlutils
2795
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2797
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2800
class UnsyncedBranches(BzrDirError):
2802
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2803
" bzr help sync-for-reconfigure.")
2805
def __init__(self, bzrdir, target_branch):
2806
BzrDirError.__init__(self, bzrdir)
2807
import bzrlib.urlutils as urlutils
2808
self.target_url = urlutils.unescape_for_display(target_branch.base,
2812
class AlreadyBranch(BzrDirError):
2814
_fmt = "'%(display_url)s' is already a branch."
2817
class AlreadyTree(BzrDirError):
2819
_fmt = "'%(display_url)s' is already a tree."
2822
class AlreadyCheckout(BzrDirError):
2824
_fmt = "'%(display_url)s' is already a checkout."
2827
class AlreadyLightweightCheckout(BzrDirError):
2829
_fmt = "'%(display_url)s' is already a lightweight checkout."
2832
class AlreadyUsingShared(BzrDirError):
2834
_fmt = "'%(display_url)s' is already using a shared repository."
2837
class AlreadyStandalone(BzrDirError):
2839
_fmt = "'%(display_url)s' is already standalone."
2842
class AlreadyWithTrees(BzrDirError):
2844
_fmt = ("Shared repository '%(display_url)s' already creates "
2848
class AlreadyWithNoTrees(BzrDirError):
2850
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2854
class ReconfigurationNotSupported(BzrDirError):
2856
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2859
class NoBindLocation(BzrDirError):
2861
_fmt = "No location could be found to bind to at %(display_url)s."
2864
class UncommittedChanges(BzrError):
2866
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2867
' (See bzr status).%(more)s')
2869
def __init__(self, tree, more=None):
2874
import bzrlib.urlutils as urlutils
2875
user_url = getattr(tree, "user_url", None)
2876
if user_url is None:
2877
display_url = str(tree)
2879
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2880
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2883
class ShelvedChanges(UncommittedChanges):
2885
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2886
' (See bzr shelve --list).%(more)s')
2889
class MissingTemplateVariable(BzrError):
2891
_fmt = 'Variable {%(name)s} is not available.'
2893
def __init__(self, name):
2897
class NoTemplate(BzrError):
2899
_fmt = 'No template specified.'
2902
class UnableCreateSymlink(BzrError):
2904
_fmt = 'Unable to create symlink %(path_str)son this platform'
2906
def __init__(self, path=None):
2910
path_str = repr(str(path))
2911
except UnicodeEncodeError:
2912
path_str = repr(path)
2914
self.path_str = path_str
2917
class UnsupportedTimezoneFormat(BzrError):
2919
_fmt = ('Unsupported timezone format "%(timezone)s", '
2920
'options are "utc", "original", "local".')
2922
def __init__(self, timezone):
2923
self.timezone = timezone
2926
class CommandAvailableInPlugin(StandardError):
2928
internal_error = False
2930
def __init__(self, cmd_name, plugin_metadata, provider):
2932
self.plugin_metadata = plugin_metadata
2933
self.cmd_name = cmd_name
2934
self.provider = provider
2938
_fmt = ('"%s" is not a standard bzr command. \n'
2939
'However, the following official plugin provides this command: %s\n'
2940
'You can install it by going to: %s'
2941
% (self.cmd_name, self.plugin_metadata['name'],
2942
self.plugin_metadata['url']))
2947
class NoPluginAvailable(BzrError):
2951
class UnableEncodePath(BzrError):
2953
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2954
'user encoding %(user_encoding)s')
2956
def __init__(self, path, kind):
2957
from bzrlib.osutils import get_user_encoding
2960
self.user_encoding = osutils.get_user_encoding()
2963
class NoSuchConfig(BzrError):
2965
_fmt = ('The "%(config_id)s" configuration does not exist.')
2967
def __init__(self, config_id):
2968
BzrError.__init__(self, config_id=config_id)
2971
class NoSuchConfigOption(BzrError):
2973
_fmt = ('The "%(option_name)s" configuration option does not exist.')
2975
def __init__(self, option_name):
2976
BzrError.__init__(self, option_name=option_name)
2979
class NoSuchAlias(BzrError):
2981
_fmt = ('The alias "%(alias_name)s" does not exist.')
2983
def __init__(self, alias_name):
2984
BzrError.__init__(self, alias_name=alias_name)
2987
class DirectoryLookupFailure(BzrError):
2988
"""Base type for lookup errors."""
2993
class InvalidLocationAlias(DirectoryLookupFailure):
2995
_fmt = '"%(alias_name)s" is not a valid location alias.'
2997
def __init__(self, alias_name):
2998
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
3001
class UnsetLocationAlias(DirectoryLookupFailure):
3003
_fmt = 'No %(alias_name)s location assigned.'
3005
def __init__(self, alias_name):
3006
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
3009
class CannotBindAddress(BzrError):
3011
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
3013
def __init__(self, host, port, orig_error):
3014
# nb: in python2.4 socket.error doesn't have a useful repr
3015
BzrError.__init__(self, host=host, port=port,
3016
orig_error=repr(orig_error.args))
3019
class UnknownRules(BzrError):
3021
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
3023
def __init__(self, unknowns):
3024
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
3027
class HookFailed(BzrError):
3028
"""Raised when a pre_change_branch_tip hook function fails anything other
3029
than TipChangeRejected.
3031
Note that this exception is no longer raised, and the import is only left
3032
to be nice to code which might catch it in a plugin.
3035
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
3036
"%(traceback_text)s%(exc_value)s")
3038
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
3040
symbol_versioning.warn("BzrError HookFailed has been deprecated "
3041
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
3043
self.hook_stage = hook_stage
3044
self.hook_name = hook_name
3045
self.exc_info = exc_info
3046
self.exc_type = exc_info[0]
3047
self.exc_value = exc_info[1]
3048
self.exc_tb = exc_info[2]
3049
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3052
class TipChangeRejected(BzrError):
3053
"""A pre_change_branch_tip hook function may raise this to cleanly and
3054
explicitly abort a change to a branch tip.
3057
_fmt = u"Tip change rejected: %(msg)s"
3059
def __init__(self, msg):
3063
class ShelfCorrupt(BzrError):
3065
_fmt = "Shelf corrupt."
3068
class NoSuchShelfId(BzrError):
3070
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3072
def __init__(self, shelf_id):
3073
BzrError.__init__(self, shelf_id=shelf_id)
3076
class InvalidShelfId(BzrError):
3078
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3080
def __init__(self, invalid_id):
3081
BzrError.__init__(self, invalid_id=invalid_id)
3084
class JailBreak(BzrError):
3086
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3088
def __init__(self, url):
3089
BzrError.__init__(self, url=url)
3092
class UserAbort(BzrError):
3094
_fmt = 'The user aborted the operation.'
3097
class MustHaveWorkingTree(BzrError):
3099
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3101
def __init__(self, format, url):
3102
BzrError.__init__(self, format=format, url=url)
3105
class NoSuchView(BzrError):
3106
"""A view does not exist.
3109
_fmt = u"No such view: %(view_name)s."
3111
def __init__(self, view_name):
3112
self.view_name = view_name
3115
class ViewsNotSupported(BzrError):
3116
"""Views are not supported by a tree format.
3119
_fmt = ("Views are not supported by %(tree)s;"
3120
" use 'bzr upgrade' to change your tree to a later format.")
3122
def __init__(self, tree):
3126
class FileOutsideView(BzrError):
3128
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3131
def __init__(self, file_name, view_files):
3132
self.file_name = file_name
3133
self.view_str = ", ".join(view_files)
3136
class UnresumableWriteGroup(BzrError):
3138
_fmt = ("Repository %(repository)s cannot resume write group "
3139
"%(write_groups)r: %(reason)s")
3141
internal_error = True
3143
def __init__(self, repository, write_groups, reason):
3144
self.repository = repository
3145
self.write_groups = write_groups
3146
self.reason = reason
3149
class UnsuspendableWriteGroup(BzrError):
3151
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3153
internal_error = True
3155
def __init__(self, repository):
3156
self.repository = repository
3159
class LossyPushToSameVCS(BzrError):
3161
_fmt = ("Lossy push not possible between %(source_branch)r and "
3162
"%(target_branch)r that are in the same VCS.")
3164
internal_error = True
3166
def __init__(self, source_branch, target_branch):
3167
self.source_branch = source_branch
3168
self.target_branch = target_branch
3171
class NoRoundtrippingSupport(BzrError):
3173
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3174
"%(target_branch)r.")
3176
internal_error = True
3178
def __init__(self, source_branch, target_branch):
3179
self.source_branch = source_branch
3180
self.target_branch = target_branch
3183
class FileTimestampUnavailable(BzrError):
3185
_fmt = "The filestamp for %(path)s is not available."
3187
internal_error = True
3189
def __init__(self, path):
3193
class NoColocatedBranchSupport(BzrError):
3195
_fmt = ("%(bzrdir)r does not support co-located branches.")
3197
def __init__(self, bzrdir):
3198
self.bzrdir = bzrdir
3201
class NoWhoami(BzrError):
3203
_fmt = ('Unable to determine your name.\n'
3204
"Please, set your name with the 'whoami' command.\n"
3205
'E.g. bzr whoami "Your Name <name@example.com>"')
3208
class InvalidPattern(BzrError):
3210
_fmt = ('Invalid pattern(s) found. %(msg)s')
3212
def __init__(self, msg):
3216
class RecursiveBind(BzrError):
3218
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3219
'Please use `bzr unbind` to fix.')
3221
def __init__(self, branch_url):
3222
self.branch_url = branch_url
3225
# FIXME: I would prefer to define the config related exception classes in
3226
# config.py but the lazy import mechanism proscribes this -- vila 20101222
3227
class InterpolationLoop(BzrError):
3229
_fmt = 'Loop involving %(refs)r while evaluating "%(string)s".'
3231
def __init__(self, string, refs):
3232
self.string = string
3233
self.refs = '->'.join(refs)
3236
class InterpolationUnknownOption(BzrError):
3238
_fmt = 'Option %(name)s is not defined while interpolating "%(string)s".'
3240
def __init__(self, name, string):
3242
self.string = string