2548
2055
class TagsNotSupported(BzrError):
2550
2057
_fmt = ("Tags not supported by %(branch)s;"
2551
" you may be able to use bzr upgrade.")
2058
" you may be able to use bzr upgrade --dirstate-tags.")
2553
2060
def __init__(self, branch):
2554
2061
self.branch = branch
2557
2064
class TagAlreadyExists(BzrError):
2559
2066
_fmt = "Tag %(tag_name)s already exists."
2561
2068
def __init__(self, tag_name):
2562
2069
self.tag_name = tag_name
2565
class MalformedBugIdentifier(BzrError):
2567
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2568
'See "bzr help bugs" for more information on this feature.')
2570
def __init__(self, bug_id, reason):
2571
self.bug_id = bug_id
2572
self.reason = reason
2575
class InvalidBugTrackerURL(BzrError):
2577
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2578
"contain {id}: %(url)s")
2580
def __init__(self, abbreviation, url):
2581
self.abbreviation = abbreviation
2585
class UnknownBugTrackerAbbreviation(BzrError):
2587
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2590
def __init__(self, abbreviation, branch):
2591
self.abbreviation = abbreviation
2592
self.branch = branch
2595
class InvalidLineInBugsProperty(BzrError):
2597
_fmt = ("Invalid line in bugs property: '%(line)s'")
2599
def __init__(self, line):
2603
class InvalidBugStatus(BzrError):
2605
_fmt = ("Invalid bug status: '%(status)s'")
2607
def __init__(self, status):
2608
self.status = status
2611
class UnexpectedSmartServerResponse(BzrError):
2613
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2615
def __init__(self, response_tuple):
2616
self.response_tuple = response_tuple
2619
class ErrorFromSmartServer(BzrError):
2620
"""An error was received from a smart server.
2622
:seealso: UnknownErrorFromSmartServer
2625
_fmt = "Error received from smart server: %(error_tuple)r"
2627
internal_error = True
2629
def __init__(self, error_tuple):
2630
self.error_tuple = error_tuple
2632
self.error_verb = error_tuple[0]
2634
self.error_verb = None
2635
self.error_args = error_tuple[1:]
2638
class UnknownErrorFromSmartServer(BzrError):
2639
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2642
This is distinct from ErrorFromSmartServer so that it is possible to
2643
distinguish between the following two cases:
2644
- ErrorFromSmartServer was uncaught. This is logic error in the client
2645
and so should provoke a traceback to the user.
2646
- ErrorFromSmartServer was caught but its error_tuple could not be
2647
translated. This is probably because the server sent us garbage, and
2648
should not provoke a traceback.
2651
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2653
internal_error = False
2655
def __init__(self, error_from_smart_server):
2658
:param error_from_smart_server: An ErrorFromSmartServer instance.
2660
self.error_from_smart_server = error_from_smart_server
2661
self.error_tuple = error_from_smart_server.error_tuple
2664
class ContainerError(BzrError):
2665
"""Base class of container errors."""
2668
class UnknownContainerFormatError(ContainerError):
2670
_fmt = "Unrecognised container format: %(container_format)r"
2672
def __init__(self, container_format):
2673
self.container_format = container_format
2676
class UnexpectedEndOfContainerError(ContainerError):
2678
_fmt = "Unexpected end of container stream"
2681
class UnknownRecordTypeError(ContainerError):
2683
_fmt = "Unknown record type: %(record_type)r"
2685
def __init__(self, record_type):
2686
self.record_type = record_type
2689
class InvalidRecordError(ContainerError):
2691
_fmt = "Invalid record: %(reason)s"
2693
def __init__(self, reason):
2694
self.reason = reason
2697
class ContainerHasExcessDataError(ContainerError):
2699
_fmt = "Container has data after end marker: %(excess)r"
2701
def __init__(self, excess):
2702
self.excess = excess
2705
class DuplicateRecordNameError(ContainerError):
2707
_fmt = "Container has multiple records with the same name: %(name)s"
2709
def __init__(self, name):
2713
class NoDestinationAddress(InternalBzrError):
2715
_fmt = "Message does not have a destination address."
2718
class RepositoryDataStreamError(BzrError):
2720
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2722
def __init__(self, reason):
2723
self.reason = reason
2726
class SMTPError(BzrError):
2728
_fmt = "SMTP error: %(error)s"
2730
def __init__(self, error):
2734
class NoMessageSupplied(BzrError):
2736
_fmt = "No message supplied."
2739
class NoMailAddressSpecified(BzrError):
2741
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2744
class UnknownMailClient(BzrError):
2746
_fmt = "Unknown mail client: %(mail_client)s"
2748
def __init__(self, mail_client):
2749
BzrError.__init__(self, mail_client=mail_client)
2752
class MailClientNotFound(BzrError):
2754
_fmt = "Unable to find mail client with the following names:"\
2755
" %(mail_command_list_string)s"
2757
def __init__(self, mail_command_list):
2758
mail_command_list_string = ', '.join(mail_command_list)
2759
BzrError.__init__(self, mail_command_list=mail_command_list,
2760
mail_command_list_string=mail_command_list_string)
2762
class SMTPConnectionRefused(SMTPError):
2764
_fmt = "SMTP connection to %(host)s refused"
2766
def __init__(self, error, host):
2771
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2773
_fmt = "Please specify smtp_server. No server at default %(host)s."
2776
class BzrDirError(BzrError):
2778
def __init__(self, bzrdir):
2779
import bzrlib.urlutils as urlutils
2780
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2782
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2785
class UnsyncedBranches(BzrDirError):
2787
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2788
" bzr help sync-for-reconfigure.")
2790
def __init__(self, bzrdir, target_branch):
2791
BzrDirError.__init__(self, bzrdir)
2792
import bzrlib.urlutils as urlutils
2793
self.target_url = urlutils.unescape_for_display(target_branch.base,
2797
class AlreadyBranch(BzrDirError):
2799
_fmt = "'%(display_url)s' is already a branch."
2802
class AlreadyTree(BzrDirError):
2804
_fmt = "'%(display_url)s' is already a tree."
2807
class AlreadyCheckout(BzrDirError):
2809
_fmt = "'%(display_url)s' is already a checkout."
2812
class AlreadyLightweightCheckout(BzrDirError):
2814
_fmt = "'%(display_url)s' is already a lightweight checkout."
2817
class AlreadyUsingShared(BzrDirError):
2819
_fmt = "'%(display_url)s' is already using a shared repository."
2822
class AlreadyStandalone(BzrDirError):
2824
_fmt = "'%(display_url)s' is already standalone."
2827
class AlreadyWithTrees(BzrDirError):
2829
_fmt = ("Shared repository '%(display_url)s' already creates "
2833
class AlreadyWithNoTrees(BzrDirError):
2835
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2839
class ReconfigurationNotSupported(BzrDirError):
2841
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2844
class NoBindLocation(BzrDirError):
2846
_fmt = "No location could be found to bind to at %(display_url)s."
2849
class UncommittedChanges(BzrError):
2851
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2852
' (See bzr status).%(more)s')
2854
def __init__(self, tree, more=None):
2859
import bzrlib.urlutils as urlutils
2860
user_url = getattr(tree, "user_url", None)
2861
if user_url is None:
2862
display_url = str(tree)
2864
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2865
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2868
class ShelvedChanges(UncommittedChanges):
2870
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2871
' (See bzr shelve --list).%(more)s')
2874
class MissingTemplateVariable(BzrError):
2876
_fmt = 'Variable {%(name)s} is not available.'
2878
def __init__(self, name):
2882
class NoTemplate(BzrError):
2884
_fmt = 'No template specified.'
2887
class UnableCreateSymlink(BzrError):
2889
_fmt = 'Unable to create symlink %(path_str)son this platform'
2891
def __init__(self, path=None):
2895
path_str = repr(str(path))
2896
except UnicodeEncodeError:
2897
path_str = repr(path)
2899
self.path_str = path_str
2902
class UnsupportedTimezoneFormat(BzrError):
2904
_fmt = ('Unsupported timezone format "%(timezone)s", '
2905
'options are "utc", "original", "local".')
2907
def __init__(self, timezone):
2908
self.timezone = timezone
2911
class CommandAvailableInPlugin(StandardError):
2913
internal_error = False
2915
def __init__(self, cmd_name, plugin_metadata, provider):
2917
self.plugin_metadata = plugin_metadata
2918
self.cmd_name = cmd_name
2919
self.provider = provider
2923
_fmt = ('"%s" is not a standard bzr command. \n'
2924
'However, the following official plugin provides this command: %s\n'
2925
'You can install it by going to: %s'
2926
% (self.cmd_name, self.plugin_metadata['name'],
2927
self.plugin_metadata['url']))
2932
class NoPluginAvailable(BzrError):
2936
class UnableEncodePath(BzrError):
2938
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2939
'user encoding %(user_encoding)s')
2941
def __init__(self, path, kind):
2942
from bzrlib.osutils import get_user_encoding
2945
self.user_encoding = osutils.get_user_encoding()
2948
class NoSuchAlias(BzrError):
2950
_fmt = ('The alias "%(alias_name)s" does not exist.')
2952
def __init__(self, alias_name):
2953
BzrError.__init__(self, alias_name=alias_name)
2956
class DirectoryLookupFailure(BzrError):
2957
"""Base type for lookup errors."""
2962
class InvalidLocationAlias(DirectoryLookupFailure):
2964
_fmt = '"%(alias_name)s" is not a valid location alias.'
2966
def __init__(self, alias_name):
2967
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2970
class UnsetLocationAlias(DirectoryLookupFailure):
2972
_fmt = 'No %(alias_name)s location assigned.'
2974
def __init__(self, alias_name):
2975
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2978
class CannotBindAddress(BzrError):
2980
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2982
def __init__(self, host, port, orig_error):
2983
# nb: in python2.4 socket.error doesn't have a useful repr
2984
BzrError.__init__(self, host=host, port=port,
2985
orig_error=repr(orig_error.args))
2988
class UnknownRules(BzrError):
2990
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2992
def __init__(self, unknowns):
2993
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2996
class HookFailed(BzrError):
2997
"""Raised when a pre_change_branch_tip hook function fails anything other
2998
than TipChangeRejected.
3000
Note that this exception is no longer raised, and the import is only left
3001
to be nice to code which might catch it in a plugin.
3004
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
3005
"%(traceback_text)s%(exc_value)s")
3007
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
3009
symbol_versioning.warn("BzrError HookFailed has been deprecated "
3010
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
3012
self.hook_stage = hook_stage
3013
self.hook_name = hook_name
3014
self.exc_info = exc_info
3015
self.exc_type = exc_info[0]
3016
self.exc_value = exc_info[1]
3017
self.exc_tb = exc_info[2]
3018
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3021
class TipChangeRejected(BzrError):
3022
"""A pre_change_branch_tip hook function may raise this to cleanly and
3023
explicitly abort a change to a branch tip.
3026
_fmt = u"Tip change rejected: %(msg)s"
3028
def __init__(self, msg):
3032
class ShelfCorrupt(BzrError):
3034
_fmt = "Shelf corrupt."
3037
class NoSuchShelfId(BzrError):
3039
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3041
def __init__(self, shelf_id):
3042
BzrError.__init__(self, shelf_id=shelf_id)
3045
class InvalidShelfId(BzrError):
3047
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3049
def __init__(self, invalid_id):
3050
BzrError.__init__(self, invalid_id=invalid_id)
3053
class JailBreak(BzrError):
3055
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3057
def __init__(self, url):
3058
BzrError.__init__(self, url=url)
3061
class UserAbort(BzrError):
3063
_fmt = 'The user aborted the operation.'
3066
class MustHaveWorkingTree(BzrError):
3068
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3070
def __init__(self, format, url):
3071
BzrError.__init__(self, format=format, url=url)
3074
class NoSuchView(BzrError):
3075
"""A view does not exist.
3078
_fmt = u"No such view: %(view_name)s."
3080
def __init__(self, view_name):
3081
self.view_name = view_name
3084
class ViewsNotSupported(BzrError):
3085
"""Views are not supported by a tree format.
3088
_fmt = ("Views are not supported by %(tree)s;"
3089
" use 'bzr upgrade' to change your tree to a later format.")
3091
def __init__(self, tree):
3095
class FileOutsideView(BzrError):
3097
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3100
def __init__(self, file_name, view_files):
3101
self.file_name = file_name
3102
self.view_str = ", ".join(view_files)
3105
class UnresumableWriteGroup(BzrError):
3107
_fmt = ("Repository %(repository)s cannot resume write group "
3108
"%(write_groups)r: %(reason)s")
3110
internal_error = True
3112
def __init__(self, repository, write_groups, reason):
3113
self.repository = repository
3114
self.write_groups = write_groups
3115
self.reason = reason
3118
class UnsuspendableWriteGroup(BzrError):
3120
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3122
internal_error = True
3124
def __init__(self, repository):
3125
self.repository = repository
3128
class LossyPushToSameVCS(BzrError):
3130
_fmt = ("Lossy push not possible between %(source_branch)r and "
3131
"%(target_branch)r that are in the same VCS.")
3133
internal_error = True
3135
def __init__(self, source_branch, target_branch):
3136
self.source_branch = source_branch
3137
self.target_branch = target_branch
3140
class NoRoundtrippingSupport(BzrError):
3142
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3143
"%(target_branch)r.")
3145
internal_error = True
3147
def __init__(self, source_branch, target_branch):
3148
self.source_branch = source_branch
3149
self.target_branch = target_branch
3152
class FileTimestampUnavailable(BzrError):
3154
_fmt = "The filestamp for %(path)s is not available."
3156
internal_error = True
3158
def __init__(self, path):
3162
class NoColocatedBranchSupport(BzrError):
3164
_fmt = ("%(bzrdir)r does not support co-located branches.")
3166
def __init__(self, bzrdir):
3167
self.bzrdir = bzrdir
3170
class NoWhoami(BzrError):
3172
_fmt = ('Unable to determine your name.\n'
3173
"Please, set your name with the 'whoami' command.\n"
3174
'E.g. bzr whoami "Your Name <name@example.com>"')
3177
class InvalidPattern(BzrError):
3179
_fmt = ('Invalid pattern(s) found. %(msg)s')
3181
def __init__(self, msg):
3185
class RecursiveBind(BzrError):
3187
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3188
'Please use `bzr unbind` to fix.')
3190
def __init__(self, branch_url):
3191
self.branch_url = branch_url