2524
2034
class TagsNotSupported(BzrError):
2526
2036
_fmt = ("Tags not supported by %(branch)s;"
2527
" you may be able to use bzr upgrade.")
2037
" you may be able to use bzr upgrade --dirstate-tags.")
2529
2039
def __init__(self, branch):
2530
2040
self.branch = branch
2533
2043
class TagAlreadyExists(BzrError):
2535
2045
_fmt = "Tag %(tag_name)s already exists."
2537
2047
def __init__(self, tag_name):
2538
2048
self.tag_name = tag_name
2541
class MalformedBugIdentifier(BzrError):
2543
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2544
'See "bzr help bugs" for more information on this feature.')
2546
def __init__(self, bug_id, reason):
2547
self.bug_id = bug_id
2548
self.reason = reason
2551
class InvalidBugTrackerURL(BzrError):
2553
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2554
"contain {id}: %(url)s")
2556
def __init__(self, abbreviation, url):
2557
self.abbreviation = abbreviation
2561
class UnknownBugTrackerAbbreviation(BzrError):
2563
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2566
def __init__(self, abbreviation, branch):
2567
self.abbreviation = abbreviation
2568
self.branch = branch
2571
class InvalidLineInBugsProperty(BzrError):
2573
_fmt = ("Invalid line in bugs property: '%(line)s'")
2575
def __init__(self, line):
2579
class InvalidBugStatus(BzrError):
2581
_fmt = ("Invalid bug status: '%(status)s'")
2583
def __init__(self, status):
2584
self.status = status
2587
class UnexpectedSmartServerResponse(BzrError):
2589
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2591
def __init__(self, response_tuple):
2592
self.response_tuple = response_tuple
2595
class ErrorFromSmartServer(BzrError):
2596
"""An error was received from a smart server.
2598
:seealso: UnknownErrorFromSmartServer
2601
_fmt = "Error received from smart server: %(error_tuple)r"
2603
internal_error = True
2605
def __init__(self, error_tuple):
2606
self.error_tuple = error_tuple
2608
self.error_verb = error_tuple[0]
2610
self.error_verb = None
2611
self.error_args = error_tuple[1:]
2614
class UnknownErrorFromSmartServer(BzrError):
2615
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2618
This is distinct from ErrorFromSmartServer so that it is possible to
2619
distinguish between the following two cases:
2620
- ErrorFromSmartServer was uncaught. This is logic error in the client
2621
and so should provoke a traceback to the user.
2622
- ErrorFromSmartServer was caught but its error_tuple could not be
2623
translated. This is probably because the server sent us garbage, and
2624
should not provoke a traceback.
2627
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2629
internal_error = False
2631
def __init__(self, error_from_smart_server):
2634
:param error_from_smart_server: An ErrorFromSmartServer instance.
2636
self.error_from_smart_server = error_from_smart_server
2637
self.error_tuple = error_from_smart_server.error_tuple
2640
class ContainerError(BzrError):
2641
"""Base class of container errors."""
2644
class UnknownContainerFormatError(ContainerError):
2646
_fmt = "Unrecognised container format: %(container_format)r"
2648
def __init__(self, container_format):
2649
self.container_format = container_format
2652
class UnexpectedEndOfContainerError(ContainerError):
2654
_fmt = "Unexpected end of container stream"
2657
class UnknownRecordTypeError(ContainerError):
2659
_fmt = "Unknown record type: %(record_type)r"
2661
def __init__(self, record_type):
2662
self.record_type = record_type
2665
class InvalidRecordError(ContainerError):
2667
_fmt = "Invalid record: %(reason)s"
2669
def __init__(self, reason):
2670
self.reason = reason
2673
class ContainerHasExcessDataError(ContainerError):
2675
_fmt = "Container has data after end marker: %(excess)r"
2677
def __init__(self, excess):
2678
self.excess = excess
2681
class DuplicateRecordNameError(ContainerError):
2683
_fmt = "Container has multiple records with the same name: %(name)s"
2685
def __init__(self, name):
2689
class NoDestinationAddress(InternalBzrError):
2691
_fmt = "Message does not have a destination address."
2694
class RepositoryDataStreamError(BzrError):
2696
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2698
def __init__(self, reason):
2699
self.reason = reason
2702
class SMTPError(BzrError):
2704
_fmt = "SMTP error: %(error)s"
2706
def __init__(self, error):
2710
class NoMessageSupplied(BzrError):
2712
_fmt = "No message supplied."
2715
class NoMailAddressSpecified(BzrError):
2717
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2720
class UnknownMailClient(BzrError):
2722
_fmt = "Unknown mail client: %(mail_client)s"
2724
def __init__(self, mail_client):
2725
BzrError.__init__(self, mail_client=mail_client)
2728
class MailClientNotFound(BzrError):
2730
_fmt = "Unable to find mail client with the following names:"\
2731
" %(mail_command_list_string)s"
2733
def __init__(self, mail_command_list):
2734
mail_command_list_string = ', '.join(mail_command_list)
2735
BzrError.__init__(self, mail_command_list=mail_command_list,
2736
mail_command_list_string=mail_command_list_string)
2738
class SMTPConnectionRefused(SMTPError):
2740
_fmt = "SMTP connection to %(host)s refused"
2742
def __init__(self, error, host):
2747
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2749
_fmt = "Please specify smtp_server. No server at default %(host)s."
2752
class BzrDirError(BzrError):
2754
def __init__(self, bzrdir):
2755
import bzrlib.urlutils as urlutils
2756
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2758
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2761
class UnsyncedBranches(BzrDirError):
2763
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2764
" bzr help sync-for-reconfigure.")
2766
def __init__(self, bzrdir, target_branch):
2767
BzrDirError.__init__(self, bzrdir)
2768
import bzrlib.urlutils as urlutils
2769
self.target_url = urlutils.unescape_for_display(target_branch.base,
2773
class AlreadyBranch(BzrDirError):
2775
_fmt = "'%(display_url)s' is already a branch."
2778
class AlreadyTree(BzrDirError):
2780
_fmt = "'%(display_url)s' is already a tree."
2783
class AlreadyCheckout(BzrDirError):
2785
_fmt = "'%(display_url)s' is already a checkout."
2788
class AlreadyLightweightCheckout(BzrDirError):
2790
_fmt = "'%(display_url)s' is already a lightweight checkout."
2793
class AlreadyUsingShared(BzrDirError):
2795
_fmt = "'%(display_url)s' is already using a shared repository."
2798
class AlreadyStandalone(BzrDirError):
2800
_fmt = "'%(display_url)s' is already standalone."
2803
class AlreadyWithTrees(BzrDirError):
2805
_fmt = ("Shared repository '%(display_url)s' already creates "
2809
class AlreadyWithNoTrees(BzrDirError):
2811
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2815
class ReconfigurationNotSupported(BzrDirError):
2817
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2820
class NoBindLocation(BzrDirError):
2822
_fmt = "No location could be found to bind to at %(display_url)s."
2825
class UncommittedChanges(BzrError):
2827
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2828
' (See bzr status).%(more)s')
2830
def __init__(self, tree, more=None):
2835
import bzrlib.urlutils as urlutils
2836
display_url = urlutils.unescape_for_display(
2837
tree.bzrdir.root_transport.base, 'ascii')
2838
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2841
class MissingTemplateVariable(BzrError):
2843
_fmt = 'Variable {%(name)s} is not available.'
2845
def __init__(self, name):
2849
class NoTemplate(BzrError):
2851
_fmt = 'No template specified.'
2854
class UnableCreateSymlink(BzrError):
2856
_fmt = 'Unable to create symlink %(path_str)son this platform'
2858
def __init__(self, path=None):
2862
path_str = repr(str(path))
2863
except UnicodeEncodeError:
2864
path_str = repr(path)
2866
self.path_str = path_str
2869
class UnsupportedTimezoneFormat(BzrError):
2871
_fmt = ('Unsupported timezone format "%(timezone)s", '
2872
'options are "utc", "original", "local".')
2874
def __init__(self, timezone):
2875
self.timezone = timezone
2878
class CommandAvailableInPlugin(StandardError):
2880
internal_error = False
2882
def __init__(self, cmd_name, plugin_metadata, provider):
2884
self.plugin_metadata = plugin_metadata
2885
self.cmd_name = cmd_name
2886
self.provider = provider
2890
_fmt = ('"%s" is not a standard bzr command. \n'
2891
'However, the following official plugin provides this command: %s\n'
2892
'You can install it by going to: %s'
2893
% (self.cmd_name, self.plugin_metadata['name'],
2894
self.plugin_metadata['url']))
2899
class NoPluginAvailable(BzrError):
2903
class UnableEncodePath(BzrError):
2905
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2906
'user encoding %(user_encoding)s')
2908
def __init__(self, path, kind):
2909
from bzrlib.osutils import get_user_encoding
2912
self.user_encoding = osutils.get_user_encoding()
2915
class NoSuchAlias(BzrError):
2917
_fmt = ('The alias "%(alias_name)s" does not exist.')
2919
def __init__(self, alias_name):
2920
BzrError.__init__(self, alias_name=alias_name)
2923
class DirectoryLookupFailure(BzrError):
2924
"""Base type for lookup errors."""
2929
class InvalidLocationAlias(DirectoryLookupFailure):
2931
_fmt = '"%(alias_name)s" is not a valid location alias.'
2933
def __init__(self, alias_name):
2934
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2937
class UnsetLocationAlias(DirectoryLookupFailure):
2939
_fmt = 'No %(alias_name)s location assigned.'
2941
def __init__(self, alias_name):
2942
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2945
class CannotBindAddress(BzrError):
2947
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2949
def __init__(self, host, port, orig_error):
2950
# nb: in python2.4 socket.error doesn't have a useful repr
2951
BzrError.__init__(self, host=host, port=port,
2952
orig_error=repr(orig_error.args))
2955
class UnknownRules(BzrError):
2957
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2959
def __init__(self, unknowns):
2960
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2963
class HookFailed(BzrError):
2964
"""Raised when a pre_change_branch_tip hook function fails anything other
2965
than TipChangeRejected.
2967
Note that this exception is no longer raised, and the import is only left
2968
to be nice to code which might catch it in a plugin.
2971
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2972
"%(traceback_text)s%(exc_value)s")
2974
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
2976
symbol_versioning.warn("BzrError HookFailed has been deprecated "
2977
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
2979
self.hook_stage = hook_stage
2980
self.hook_name = hook_name
2981
self.exc_info = exc_info
2982
self.exc_type = exc_info[0]
2983
self.exc_value = exc_info[1]
2984
self.exc_tb = exc_info[2]
2985
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2988
class TipChangeRejected(BzrError):
2989
"""A pre_change_branch_tip hook function may raise this to cleanly and
2990
explicitly abort a change to a branch tip.
2993
_fmt = u"Tip change rejected: %(msg)s"
2995
def __init__(self, msg):
2999
class ShelfCorrupt(BzrError):
3001
_fmt = "Shelf corrupt."
3004
class NoSuchShelfId(BzrError):
3006
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3008
def __init__(self, shelf_id):
3009
BzrError.__init__(self, shelf_id=shelf_id)
3012
class InvalidShelfId(BzrError):
3014
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3016
def __init__(self, invalid_id):
3017
BzrError.__init__(self, invalid_id=invalid_id)
3020
class JailBreak(BzrError):
3022
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3024
def __init__(self, url):
3025
BzrError.__init__(self, url=url)
3028
class UserAbort(BzrError):
3030
_fmt = 'The user aborted the operation.'
3033
class MustHaveWorkingTree(BzrError):
3035
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3037
def __init__(self, format, url):
3038
BzrError.__init__(self, format=format, url=url)
3041
class NoSuchView(BzrError):
3042
"""A view does not exist.
3045
_fmt = u"No such view: %(view_name)s."
3047
def __init__(self, view_name):
3048
self.view_name = view_name
3051
class ViewsNotSupported(BzrError):
3052
"""Views are not supported by a tree format.
3055
_fmt = ("Views are not supported by %(tree)s;"
3056
" use 'bzr upgrade' to change your tree to a later format.")
3058
def __init__(self, tree):
3062
class FileOutsideView(BzrError):
3064
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3067
def __init__(self, file_name, view_files):
3068
self.file_name = file_name
3069
self.view_str = ", ".join(view_files)
3072
class UnresumableWriteGroup(BzrError):
3074
_fmt = ("Repository %(repository)s cannot resume write group "
3075
"%(write_groups)r: %(reason)s")
3077
internal_error = True
3079
def __init__(self, repository, write_groups, reason):
3080
self.repository = repository
3081
self.write_groups = write_groups
3082
self.reason = reason
3085
class UnsuspendableWriteGroup(BzrError):
3087
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3089
internal_error = True
3091
def __init__(self, repository):
3092
self.repository = repository
3095
class LossyPushToSameVCS(BzrError):
3097
_fmt = ("Lossy push not possible between %(source_branch)r and "
3098
"%(target_branch)r that are in the same VCS.")
3100
internal_error = True
3102
def __init__(self, source_branch, target_branch):
3103
self.source_branch = source_branch
3104
self.target_branch = target_branch
3107
class NoRoundtrippingSupport(BzrError):
3109
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3110
"%(target_branch)r.")
3112
internal_error = True
3114
def __init__(self, source_branch, target_branch):
3115
self.source_branch = source_branch
3116
self.target_branch = target_branch
3119
class FileTimestampUnavailable(BzrError):
3121
_fmt = "The filestamp for %(path)s is not available."
3123
internal_error = True
3125
def __init__(self, path):