2534
2055
class TagsNotSupported(BzrError):
2536
2057
_fmt = ("Tags not supported by %(branch)s;"
2537
" you may be able to use bzr upgrade.")
2058
" you may be able to use bzr upgrade --dirstate-tags.")
2539
2060
def __init__(self, branch):
2540
2061
self.branch = branch
2543
2064
class TagAlreadyExists(BzrError):
2545
2066
_fmt = "Tag %(tag_name)s already exists."
2547
2068
def __init__(self, tag_name):
2548
2069
self.tag_name = tag_name
2551
class MalformedBugIdentifier(BzrError):
2553
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2554
'See "bzr help bugs" for more information on this feature.')
2556
def __init__(self, bug_id, reason):
2557
self.bug_id = bug_id
2558
self.reason = reason
2561
class InvalidBugTrackerURL(BzrError):
2563
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2564
"contain {id}: %(url)s")
2566
def __init__(self, abbreviation, url):
2567
self.abbreviation = abbreviation
2571
class UnknownBugTrackerAbbreviation(BzrError):
2573
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2576
def __init__(self, abbreviation, branch):
2577
self.abbreviation = abbreviation
2578
self.branch = branch
2581
class InvalidLineInBugsProperty(BzrError):
2583
_fmt = ("Invalid line in bugs property: '%(line)s'")
2585
def __init__(self, line):
2589
class InvalidBugStatus(BzrError):
2591
_fmt = ("Invalid bug status: '%(status)s'")
2593
def __init__(self, status):
2594
self.status = status
2597
class UnexpectedSmartServerResponse(BzrError):
2599
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2601
def __init__(self, response_tuple):
2602
self.response_tuple = response_tuple
2605
class ErrorFromSmartServer(BzrError):
2606
"""An error was received from a smart server.
2608
:seealso: UnknownErrorFromSmartServer
2611
_fmt = "Error received from smart server: %(error_tuple)r"
2613
internal_error = True
2615
def __init__(self, error_tuple):
2616
self.error_tuple = error_tuple
2618
self.error_verb = error_tuple[0]
2620
self.error_verb = None
2621
self.error_args = error_tuple[1:]
2624
class UnknownErrorFromSmartServer(BzrError):
2625
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2628
This is distinct from ErrorFromSmartServer so that it is possible to
2629
distinguish between the following two cases:
2630
- ErrorFromSmartServer was uncaught. This is logic error in the client
2631
and so should provoke a traceback to the user.
2632
- ErrorFromSmartServer was caught but its error_tuple could not be
2633
translated. This is probably because the server sent us garbage, and
2634
should not provoke a traceback.
2637
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2639
internal_error = False
2641
def __init__(self, error_from_smart_server):
2644
:param error_from_smart_server: An ErrorFromSmartServer instance.
2646
self.error_from_smart_server = error_from_smart_server
2647
self.error_tuple = error_from_smart_server.error_tuple
2650
class ContainerError(BzrError):
2651
"""Base class of container errors."""
2654
class UnknownContainerFormatError(ContainerError):
2656
_fmt = "Unrecognised container format: %(container_format)r"
2658
def __init__(self, container_format):
2659
self.container_format = container_format
2662
class UnexpectedEndOfContainerError(ContainerError):
2664
_fmt = "Unexpected end of container stream"
2667
class UnknownRecordTypeError(ContainerError):
2669
_fmt = "Unknown record type: %(record_type)r"
2671
def __init__(self, record_type):
2672
self.record_type = record_type
2675
class InvalidRecordError(ContainerError):
2677
_fmt = "Invalid record: %(reason)s"
2679
def __init__(self, reason):
2680
self.reason = reason
2683
class ContainerHasExcessDataError(ContainerError):
2685
_fmt = "Container has data after end marker: %(excess)r"
2687
def __init__(self, excess):
2688
self.excess = excess
2691
class DuplicateRecordNameError(ContainerError):
2693
_fmt = "Container has multiple records with the same name: %(name)s"
2695
def __init__(self, name):
2699
class NoDestinationAddress(InternalBzrError):
2701
_fmt = "Message does not have a destination address."
2704
class RepositoryDataStreamError(BzrError):
2706
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2708
def __init__(self, reason):
2709
self.reason = reason
2712
class SMTPError(BzrError):
2714
_fmt = "SMTP error: %(error)s"
2716
def __init__(self, error):
2720
class NoMessageSupplied(BzrError):
2722
_fmt = "No message supplied."
2725
class NoMailAddressSpecified(BzrError):
2727
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2730
class UnknownMailClient(BzrError):
2732
_fmt = "Unknown mail client: %(mail_client)s"
2734
def __init__(self, mail_client):
2735
BzrError.__init__(self, mail_client=mail_client)
2738
class MailClientNotFound(BzrError):
2740
_fmt = "Unable to find mail client with the following names:"\
2741
" %(mail_command_list_string)s"
2743
def __init__(self, mail_command_list):
2744
mail_command_list_string = ', '.join(mail_command_list)
2745
BzrError.__init__(self, mail_command_list=mail_command_list,
2746
mail_command_list_string=mail_command_list_string)
2748
class SMTPConnectionRefused(SMTPError):
2750
_fmt = "SMTP connection to %(host)s refused"
2752
def __init__(self, error, host):
2757
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2759
_fmt = "Please specify smtp_server. No server at default %(host)s."
2762
class BzrDirError(BzrError):
2764
def __init__(self, bzrdir):
2765
import bzrlib.urlutils as urlutils
2766
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2768
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2771
class UnsyncedBranches(BzrDirError):
2773
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2774
" bzr help sync-for-reconfigure.")
2776
def __init__(self, bzrdir, target_branch):
2777
BzrDirError.__init__(self, bzrdir)
2778
import bzrlib.urlutils as urlutils
2779
self.target_url = urlutils.unescape_for_display(target_branch.base,
2783
class AlreadyBranch(BzrDirError):
2785
_fmt = "'%(display_url)s' is already a branch."
2788
class AlreadyTree(BzrDirError):
2790
_fmt = "'%(display_url)s' is already a tree."
2793
class AlreadyCheckout(BzrDirError):
2795
_fmt = "'%(display_url)s' is already a checkout."
2798
class AlreadyLightweightCheckout(BzrDirError):
2800
_fmt = "'%(display_url)s' is already a lightweight checkout."
2803
class AlreadyUsingShared(BzrDirError):
2805
_fmt = "'%(display_url)s' is already using a shared repository."
2808
class AlreadyStandalone(BzrDirError):
2810
_fmt = "'%(display_url)s' is already standalone."
2813
class AlreadyWithTrees(BzrDirError):
2815
_fmt = ("Shared repository '%(display_url)s' already creates "
2819
class AlreadyWithNoTrees(BzrDirError):
2821
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2825
class ReconfigurationNotSupported(BzrDirError):
2827
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2830
class NoBindLocation(BzrDirError):
2832
_fmt = "No location could be found to bind to at %(display_url)s."
2835
class UncommittedChanges(BzrError):
2837
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2838
' (See bzr status).%(more)s')
2840
def __init__(self, tree, more=None):
2845
import bzrlib.urlutils as urlutils
2846
user_url = getattr(tree, "user_url", None)
2847
if user_url is None:
2848
display_url = str(tree)
2850
display_url = urlutils.unescape_for_display(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
3156
class NoWhoami(BzrError):
3158
_fmt = ('Unable to determine your name.\n'
3159
"Please, set your name with the 'whoami' command.\n"
3160
'E.g. bzr whoami "Your Name <name@example.com>"')
3163
class InvalidPattern(BzrError):
3165
_fmt = ('Invalid pattern(s) found. %(msg)s')
3167
def __init__(self, msg):
3171
class RecursiveBind(BzrError):
3173
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3174
'Please use `bzr unbind` to fix.')
3176
def __init__(self, branch_url):
3177
self.branch_url = branch_url