87
82
for key, value in kwds.items():
88
83
setattr(self, key, value)
91
86
s = getattr(self, '_preformatted_string', None)
93
# contains a preformatted message; must be cast to plain str
88
# contains a preformatted message
96
91
fmt = self._get_format_string()
98
s = fmt % self.__dict__
93
d = dict(self.__dict__)
99
95
# __str__() should always return a 'str' object
100
96
# never a 'unicode' object.
101
if isinstance(s, unicode):
102
return s.encode('utf8')
104
except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
105
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%s' \
106
% (self.__class__.__name__,
108
getattr(self, '_fmt', None),
99
pass # just bind to 'e' for formatting below
102
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
103
% (self.__class__.__name__,
105
getattr(self, '_fmt', None),
108
def __unicode__(self):
110
if isinstance(u, str):
111
# Try decoding the str using the default encoding.
113
elif not isinstance(u, unicode):
114
# Try to make a unicode object from it, because __unicode__ must
115
# return a unicode object.
121
if isinstance(s, unicode):
124
# __str__ must return a str.
129
return '%s(%s)' % (self.__class__.__name__, str(self))
111
131
def _get_format_string(self):
112
132
"""Return format string for this exception or None"""
113
133
fmt = getattr(self, '_fmt', None)
114
134
if fmt is not None:
116
fmt = getattr(self, '__doc__', None)
118
symbol_versioning.warn("%s uses its docstring as a format, "
119
"it should use _fmt instead" % self.__class__.__name__,
122
return 'Unprintable exception %s: dict=%r, fmt=%r' \
123
% (self.__class__.__name__,
125
getattr(self, '_fmt', None),
129
class BzrNewError(BzrError):
130
"""Deprecated error base class."""
131
# base classes should override the docstring with their human-
132
# readable explanation
134
def __init__(self, *args, **kwds):
135
# XXX: Use the underlying BzrError to always generate the args attribute
136
# if it doesn't exist. We can't use super here, because exceptions are
137
# old-style classes in python2.4 (but new in 2.5). --bmc, 20060426
138
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
139
'please convert %s to use BzrError instead'
140
% self.__class__.__name__,
143
BzrError.__init__(self, *args)
144
for key, value in kwds.items():
145
setattr(self, key, value)
149
# __str__() should always return a 'str' object
150
# never a 'unicode' object.
151
s = self.__doc__ % self.__dict__
152
if isinstance(s, unicode):
153
return s.encode('utf8')
155
except (TypeError, NameError, ValueError, KeyError), e:
156
return 'Unprintable exception %s(%r): %s' \
157
% (self.__class__.__name__,
158
self.__dict__, str(e))
135
from bzrlib.i18n import gettext
136
return gettext(unicode(fmt)) # _fmt strings should be ascii
138
def __eq__(self, other):
139
if self.__class__ is not other.__class__:
140
return NotImplemented
141
return self.__dict__ == other.__dict__
144
class InternalBzrError(BzrError):
145
"""Base class for errors that are internal in nature.
147
This is a convenience class for errors that are internal. The
148
internal_error attribute can still be altered in subclasses, if needed.
149
Using this class is simply an easy way to get internal errors.
152
internal_error = True
161
155
class AlreadyBuilding(BzrError):
163
157
_fmt = "The tree builder is already building a tree."
166
class BzrCheckError(BzrError):
168
_fmt = "Internal check failed: %(message)s"
170
internal_error = True
172
def __init__(self, message):
173
BzrError.__init__(self)
174
self.message = message
177
class InvalidEntryName(BzrError):
160
class BranchError(BzrError):
161
"""Base class for concrete 'errors about a branch'."""
163
def __init__(self, branch):
164
BzrError.__init__(self, branch=branch)
167
class BzrCheckError(InternalBzrError):
169
_fmt = "Internal check failed: %(msg)s"
171
def __init__(self, msg):
172
BzrError.__init__(self)
176
class DirstateCorrupt(BzrError):
178
_fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s"
180
def __init__(self, state, msg):
181
BzrError.__init__(self)
186
class DisabledMethod(InternalBzrError):
188
_fmt = "The smart server method '%(class_name)s' is disabled."
190
def __init__(self, class_name):
191
BzrError.__init__(self)
192
self.class_name = class_name
195
class IncompatibleAPI(BzrError):
197
_fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
198
'It supports versions "%(minimum)s" to "%(current)s".'
200
def __init__(self, api, wanted, minimum, current):
203
self.minimum = minimum
204
self.current = current
207
class InProcessTransport(BzrError):
209
_fmt = "The transport '%(transport)s' is only accessible within this " \
212
def __init__(self, transport):
213
self.transport = transport
216
class InvalidEntryName(InternalBzrError):
179
218
_fmt = "Invalid entry name: %(name)s"
181
internal_error = True
183
220
def __init__(self, name):
184
221
BzrError.__init__(self)
188
225
class InvalidRevisionNumber(BzrError):
190
227
_fmt = "Invalid revision number %(revno)s"
192
229
def __init__(self, revno):
1771
2448
self.extra = ''
1774
class InvalidImportLine(BzrError):
2451
class InvalidImportLine(InternalBzrError):
1776
2453
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
1778
internal_error = True
1780
2455
def __init__(self, text, msg):
1781
2456
BzrError.__init__(self)
1782
2457
self.text = text
1786
class ImportNameCollision(BzrError):
1788
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
1790
internal_error = True
1792
def __init__(self, name):
1793
BzrError.__init__(self)
2461
class ImportNameCollision(InternalBzrError):
2463
_fmt = ("Tried to import an object to the same name as"
2464
" an existing object. %(name)s")
2466
def __init__(self, name):
2467
BzrError.__init__(self)
2471
class NotAMergeDirective(BzrError):
2472
"""File starting with %(firstline)r is not a merge directive"""
2473
def __init__(self, firstline):
2474
BzrError.__init__(self, firstline=firstline)
2477
class NoMergeSource(BzrError):
2478
"""Raise if no merge source was specified for a merge directive"""
2480
_fmt = "A merge directive must provide either a bundle or a public"\
2484
class IllegalMergeDirectivePayload(BzrError):
2485
"""A merge directive contained something other than a patch or bundle"""
2487
_fmt = "Bad merge directive payload %(start)r"
2489
def __init__(self, start):
2494
class PatchVerificationFailed(BzrError):
2495
"""A patch from a merge directive could not be verified"""
2497
_fmt = "Preview patch does not match requested changes."
2500
class PatchMissing(BzrError):
2501
"""Raise a patch type was specified but no patch supplied"""
2503
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2505
def __init__(self, patch_type):
2506
BzrError.__init__(self)
2507
self.patch_type = patch_type
2510
class TargetNotBranch(BzrError):
2511
"""A merge directive's target branch is required, but isn't a branch"""
2513
_fmt = ("Your branch does not have all of the revisions required in "
2514
"order to merge this merge directive and the target "
2515
"location specified in the merge directive is not a branch: "
2518
def __init__(self, location):
2519
BzrError.__init__(self)
2520
self.location = location
2523
class UnsupportedInventoryKind(BzrError):
2525
_fmt = """Unsupported entry kind %(kind)s"""
2527
def __init__(self, kind):
2531
class BadSubsumeSource(BzrError):
2533
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2535
def __init__(self, tree, other_tree, reason):
2537
self.other_tree = other_tree
2538
self.reason = reason
2541
class SubsumeTargetNeedsUpgrade(BzrError):
2543
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2545
def __init__(self, other_tree):
2546
self.other_tree = other_tree
2549
class BadReferenceTarget(InternalBzrError):
2551
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2554
def __init__(self, tree, other_tree, reason):
2556
self.other_tree = other_tree
2557
self.reason = reason
2560
class NoSuchTag(BzrError):
2562
_fmt = "No such tag: %(tag_name)s"
2564
def __init__(self, tag_name):
2565
self.tag_name = tag_name
2568
class TagsNotSupported(BzrError):
2570
_fmt = ("Tags not supported by %(branch)s;"
2571
" you may be able to use bzr upgrade.")
2573
def __init__(self, branch):
2574
self.branch = branch
2577
class TagAlreadyExists(BzrError):
2579
_fmt = "Tag %(tag_name)s already exists."
2581
def __init__(self, tag_name):
2582
self.tag_name = tag_name
2585
class MalformedBugIdentifier(BzrError):
2587
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2588
'See "bzr help bugs" for more information on this feature.')
2590
def __init__(self, bug_id, reason):
2591
self.bug_id = bug_id
2592
self.reason = reason
2595
class InvalidBugTrackerURL(BzrError):
2597
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2598
"contain {id}: %(url)s")
2600
def __init__(self, abbreviation, url):
2601
self.abbreviation = abbreviation
2605
class UnknownBugTrackerAbbreviation(BzrError):
2607
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2610
def __init__(self, abbreviation, branch):
2611
self.abbreviation = abbreviation
2612
self.branch = branch
2615
class InvalidLineInBugsProperty(BzrError):
2617
_fmt = ("Invalid line in bugs property: '%(line)s'")
2619
def __init__(self, line):
2623
class InvalidBugStatus(BzrError):
2625
_fmt = ("Invalid bug status: '%(status)s'")
2627
def __init__(self, status):
2628
self.status = status
2631
class UnexpectedSmartServerResponse(BzrError):
2633
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2635
def __init__(self, response_tuple):
2636
self.response_tuple = response_tuple
2639
class ErrorFromSmartServer(BzrError):
2640
"""An error was received from a smart server.
2642
:seealso: UnknownErrorFromSmartServer
2645
_fmt = "Error received from smart server: %(error_tuple)r"
2647
internal_error = True
2649
def __init__(self, error_tuple):
2650
self.error_tuple = error_tuple
2652
self.error_verb = error_tuple[0]
2654
self.error_verb = None
2655
self.error_args = error_tuple[1:]
2658
class UnknownErrorFromSmartServer(BzrError):
2659
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2662
This is distinct from ErrorFromSmartServer so that it is possible to
2663
distinguish between the following two cases:
2665
- ErrorFromSmartServer was uncaught. This is logic error in the client
2666
and so should provoke a traceback to the user.
2667
- ErrorFromSmartServer was caught but its error_tuple could not be
2668
translated. This is probably because the server sent us garbage, and
2669
should not provoke a traceback.
2672
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2674
internal_error = False
2676
def __init__(self, error_from_smart_server):
2679
:param error_from_smart_server: An ErrorFromSmartServer instance.
2681
self.error_from_smart_server = error_from_smart_server
2682
self.error_tuple = error_from_smart_server.error_tuple
2685
class ContainerError(BzrError):
2686
"""Base class of container errors."""
2689
class UnknownContainerFormatError(ContainerError):
2691
_fmt = "Unrecognised container format: %(container_format)r"
2693
def __init__(self, container_format):
2694
self.container_format = container_format
2697
class UnexpectedEndOfContainerError(ContainerError):
2699
_fmt = "Unexpected end of container stream"
2702
class UnknownRecordTypeError(ContainerError):
2704
_fmt = "Unknown record type: %(record_type)r"
2706
def __init__(self, record_type):
2707
self.record_type = record_type
2710
class InvalidRecordError(ContainerError):
2712
_fmt = "Invalid record: %(reason)s"
2714
def __init__(self, reason):
2715
self.reason = reason
2718
class ContainerHasExcessDataError(ContainerError):
2720
_fmt = "Container has data after end marker: %(excess)r"
2722
def __init__(self, excess):
2723
self.excess = excess
2726
class DuplicateRecordNameError(ContainerError):
2728
_fmt = "Container has multiple records with the same name: %(name)s"
2730
def __init__(self, name):
2731
self.name = name.decode("utf-8")
2734
class NoDestinationAddress(InternalBzrError):
2736
_fmt = "Message does not have a destination address."
2739
class RepositoryDataStreamError(BzrError):
2741
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2743
def __init__(self, reason):
2744
self.reason = reason
2747
class SMTPError(BzrError):
2749
_fmt = "SMTP error: %(error)s"
2751
def __init__(self, error):
2755
class NoMessageSupplied(BzrError):
2757
_fmt = "No message supplied."
2760
class NoMailAddressSpecified(BzrError):
2762
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2765
class UnknownMailClient(BzrError):
2767
_fmt = "Unknown mail client: %(mail_client)s"
2769
def __init__(self, mail_client):
2770
BzrError.__init__(self, mail_client=mail_client)
2773
class MailClientNotFound(BzrError):
2775
_fmt = "Unable to find mail client with the following names:"\
2776
" %(mail_command_list_string)s"
2778
def __init__(self, mail_command_list):
2779
mail_command_list_string = ', '.join(mail_command_list)
2780
BzrError.__init__(self, mail_command_list=mail_command_list,
2781
mail_command_list_string=mail_command_list_string)
2783
class SMTPConnectionRefused(SMTPError):
2785
_fmt = "SMTP connection to %(host)s refused"
2787
def __init__(self, error, host):
2792
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2794
_fmt = "Please specify smtp_server. No server at default %(host)s."
2797
class BzrDirError(BzrError):
2799
def __init__(self, bzrdir):
2800
import bzrlib.urlutils as urlutils
2801
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2803
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2806
class UnsyncedBranches(BzrDirError):
2808
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2809
" bzr help sync-for-reconfigure.")
2811
def __init__(self, bzrdir, target_branch):
2812
BzrDirError.__init__(self, bzrdir)
2813
import bzrlib.urlutils as urlutils
2814
self.target_url = urlutils.unescape_for_display(target_branch.base,
2818
class AlreadyBranch(BzrDirError):
2820
_fmt = "'%(display_url)s' is already a branch."
2823
class AlreadyTree(BzrDirError):
2825
_fmt = "'%(display_url)s' is already a tree."
2828
class AlreadyCheckout(BzrDirError):
2830
_fmt = "'%(display_url)s' is already a checkout."
2833
class AlreadyLightweightCheckout(BzrDirError):
2835
_fmt = "'%(display_url)s' is already a lightweight checkout."
2838
class AlreadyUsingShared(BzrDirError):
2840
_fmt = "'%(display_url)s' is already using a shared repository."
2843
class AlreadyStandalone(BzrDirError):
2845
_fmt = "'%(display_url)s' is already standalone."
2848
class AlreadyWithTrees(BzrDirError):
2850
_fmt = ("Shared repository '%(display_url)s' already creates "
2854
class AlreadyWithNoTrees(BzrDirError):
2856
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2860
class ReconfigurationNotSupported(BzrDirError):
2862
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2865
class NoBindLocation(BzrDirError):
2867
_fmt = "No location could be found to bind to at %(display_url)s."
2870
class UncommittedChanges(BzrError):
2872
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2873
' (See bzr status).%(more)s')
2875
def __init__(self, tree, more=None):
2880
import bzrlib.urlutils as urlutils
2881
user_url = getattr(tree, "user_url", None)
2882
if user_url is None:
2883
display_url = str(tree)
2885
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2886
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2889
class ShelvedChanges(UncommittedChanges):
2891
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2892
' (See bzr shelve --list).%(more)s')
2895
class MissingTemplateVariable(BzrError):
2897
_fmt = 'Variable {%(name)s} is not available.'
2899
def __init__(self, name):
2903
class NoTemplate(BzrError):
2905
_fmt = 'No template specified.'
2908
class UnableCreateSymlink(BzrError):
2910
_fmt = 'Unable to create symlink %(path_str)son this platform'
2912
def __init__(self, path=None):
2916
path_str = repr(str(path))
2917
except UnicodeEncodeError:
2918
path_str = repr(path)
2920
self.path_str = path_str
2923
class UnsupportedTimezoneFormat(BzrError):
2925
_fmt = ('Unsupported timezone format "%(timezone)s", '
2926
'options are "utc", "original", "local".')
2928
def __init__(self, timezone):
2929
self.timezone = timezone
2932
class CommandAvailableInPlugin(StandardError):
2934
internal_error = False
2936
def __init__(self, cmd_name, plugin_metadata, provider):
2938
self.plugin_metadata = plugin_metadata
2939
self.cmd_name = cmd_name
2940
self.provider = provider
2944
_fmt = ('"%s" is not a standard bzr command. \n'
2945
'However, the following official plugin provides this command: %s\n'
2946
'You can install it by going to: %s'
2947
% (self.cmd_name, self.plugin_metadata['name'],
2948
self.plugin_metadata['url']))
2953
class NoPluginAvailable(BzrError):
2957
class UnableEncodePath(BzrError):
2959
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2960
'user encoding %(user_encoding)s')
2962
def __init__(self, path, kind):
2963
from bzrlib.osutils import get_user_encoding
2966
self.user_encoding = get_user_encoding()
2969
class NoSuchConfig(BzrError):
2971
_fmt = ('The "%(config_id)s" configuration does not exist.')
2973
def __init__(self, config_id):
2974
BzrError.__init__(self, config_id=config_id)
2977
class NoSuchConfigOption(BzrError):
2979
_fmt = ('The "%(option_name)s" configuration option does not exist.')
2981
def __init__(self, option_name):
2982
BzrError.__init__(self, option_name=option_name)
2985
class NoSuchAlias(BzrError):
2987
_fmt = ('The alias "%(alias_name)s" does not exist.')
2989
def __init__(self, alias_name):
2990
BzrError.__init__(self, alias_name=alias_name)
2993
class DirectoryLookupFailure(BzrError):
2994
"""Base type for lookup errors."""
2999
class InvalidLocationAlias(DirectoryLookupFailure):
3001
_fmt = '"%(alias_name)s" is not a valid location alias.'
3003
def __init__(self, alias_name):
3004
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
3007
class UnsetLocationAlias(DirectoryLookupFailure):
3009
_fmt = 'No %(alias_name)s location assigned.'
3011
def __init__(self, alias_name):
3012
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
3015
class CannotBindAddress(BzrError):
3017
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
3019
def __init__(self, host, port, orig_error):
3020
# nb: in python2.4 socket.error doesn't have a useful repr
3021
BzrError.__init__(self, host=host, port=port,
3022
orig_error=repr(orig_error.args))
3025
class UnknownRules(BzrError):
3027
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
3029
def __init__(self, unknowns):
3030
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
3033
class TipChangeRejected(BzrError):
3034
"""A pre_change_branch_tip hook function may raise this to cleanly and
3035
explicitly abort a change to a branch tip.
3038
_fmt = u"Tip change rejected: %(msg)s"
3040
def __init__(self, msg):
3044
class ShelfCorrupt(BzrError):
3046
_fmt = "Shelf corrupt."
3049
class DecompressCorruption(BzrError):
3051
_fmt = "Corruption while decompressing repository file%(orig_error)s"
3053
def __init__(self, orig_error=None):
3054
if orig_error is not None:
3055
self.orig_error = ", %s" % (orig_error,)
3057
self.orig_error = ""
3058
BzrError.__init__(self)
3061
class NoSuchShelfId(BzrError):
3063
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3065
def __init__(self, shelf_id):
3066
BzrError.__init__(self, shelf_id=shelf_id)
3069
class InvalidShelfId(BzrError):
3071
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3073
def __init__(self, invalid_id):
3074
BzrError.__init__(self, invalid_id=invalid_id)
3077
class JailBreak(BzrError):
3079
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3081
def __init__(self, url):
3082
BzrError.__init__(self, url=url)
3085
class UserAbort(BzrError):
3087
_fmt = 'The user aborted the operation.'
3090
class MustHaveWorkingTree(BzrError):
3092
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3094
def __init__(self, format, url):
3095
BzrError.__init__(self, format=format, url=url)
3098
class NoSuchView(BzrError):
3099
"""A view does not exist.
3102
_fmt = u"No such view: %(view_name)s."
3104
def __init__(self, view_name):
3105
self.view_name = view_name
3108
class ViewsNotSupported(BzrError):
3109
"""Views are not supported by a tree format.
3112
_fmt = ("Views are not supported by %(tree)s;"
3113
" use 'bzr upgrade' to change your tree to a later format.")
3115
def __init__(self, tree):
3119
class FileOutsideView(BzrError):
3121
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3124
def __init__(self, file_name, view_files):
3125
self.file_name = file_name
3126
self.view_str = ", ".join(view_files)
3129
class UnresumableWriteGroup(BzrError):
3131
_fmt = ("Repository %(repository)s cannot resume write group "
3132
"%(write_groups)r: %(reason)s")
3134
internal_error = True
3136
def __init__(self, repository, write_groups, reason):
3137
self.repository = repository
3138
self.write_groups = write_groups
3139
self.reason = reason
3142
class UnsuspendableWriteGroup(BzrError):
3144
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3146
internal_error = True
3148
def __init__(self, repository):
3149
self.repository = repository
3152
class LossyPushToSameVCS(BzrError):
3154
_fmt = ("Lossy push not possible between %(source_branch)r and "
3155
"%(target_branch)r that are in the same VCS.")
3157
internal_error = True
3159
def __init__(self, source_branch, target_branch):
3160
self.source_branch = source_branch
3161
self.target_branch = target_branch
3164
class NoRoundtrippingSupport(BzrError):
3166
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3167
"%(target_branch)r.")
3169
internal_error = True
3171
def __init__(self, source_branch, target_branch):
3172
self.source_branch = source_branch
3173
self.target_branch = target_branch
3176
class FileTimestampUnavailable(BzrError):
3178
_fmt = "The filestamp for %(path)s is not available."
3180
internal_error = True
3182
def __init__(self, path):
3186
class NoColocatedBranchSupport(BzrError):
3188
_fmt = ("%(bzrdir)r does not support co-located branches.")
3190
def __init__(self, bzrdir):
3191
self.bzrdir = bzrdir
3194
class NoWhoami(BzrError):
3196
_fmt = ('Unable to determine your name.\n'
3197
"Please, set your name with the 'whoami' command.\n"
3198
'E.g. bzr whoami "Your Name <name@example.com>"')
3201
class InvalidPattern(BzrError):
3203
_fmt = ('Invalid pattern(s) found. %(msg)s')
3205
def __init__(self, msg):
3209
class RecursiveBind(BzrError):
3211
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3212
'Please use `bzr unbind` to fix.')
3214
def __init__(self, branch_url):
3215
self.branch_url = branch_url
3218
# FIXME: I would prefer to define the config related exception classes in
3219
# config.py but the lazy import mechanism proscribes this -- vila 20101222
3220
class OptionExpansionLoop(BzrError):
3222
_fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
3224
def __init__(self, string, refs):
3225
self.string = string
3226
self.refs = '->'.join(refs)
3229
class ExpandingUnknownOption(BzrError):
3231
_fmt = 'Option %(name)s is not defined while expanding "%(string)s".'
3233
def __init__(self, name, string):
3235
self.string = string
3238
class NoCompatibleInter(BzrError):
3240
_fmt = ('No compatible object available for operations from %(source)r '
3243
def __init__(self, source, target):
3244
self.source = source
3245
self.target = target
3248
class HpssVfsRequestNotAllowed(BzrError):
3250
_fmt = ("VFS requests over the smart server are not allowed. Encountered: "
3251
"%(method)s, %(arguments)s.")
3253
def __init__(self, method, arguments):
3254
self.method = method
3255
self.arguments = arguments
3258
class UnsupportedKindChange(BzrError):
3260
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
3261
"%(path)s not supported by format %(format)r")
3263
def __init__(self, path, from_kind, to_kind, format):
3265
self.from_kind = from_kind
3266
self.to_kind = to_kind
3267
self.format = format
3270
class MissingFeature(BzrError):
3272
_fmt = ("Missing feature %(feature)s not provided by this "
3273
"version of Bazaar or any plugin.")
3275
def __init__(self, feature):
3276
self.feature = feature
3279
class PatchSyntax(BzrError):
3280
"""Base class for patch syntax errors."""
3283
class BinaryFiles(BzrError):
3285
_fmt = 'Binary files section encountered.'
3287
def __init__(self, orig_name, mod_name):
3288
self.orig_name = orig_name
3289
self.mod_name = mod_name
3292
class MalformedPatchHeader(PatchSyntax):
3294
_fmt = "Malformed patch header. %(desc)s\n%(line)r"
3296
def __init__(self, desc, line):
3301
class MalformedHunkHeader(PatchSyntax):
3303
_fmt = "Malformed hunk header. %(desc)s\n%(line)r"
3305
def __init__(self, desc, line):
3310
class MalformedLine(PatchSyntax):
3312
_fmt = "Malformed line. %(desc)s\n%(line)r"
3314
def __init__(self, desc, line):
3319
class PatchConflict(BzrError):
3321
_fmt = ('Text contents mismatch at line %(line_no)d. Original has '
3322
'"%(orig_line)s", but patch says it should be "%(patch_line)s"')
3324
def __init__(self, line_no, orig_line, patch_line):
3325
self.line_no = line_no
3326
self.orig_line = orig_line.rstrip('\n')
3327
self.patch_line = patch_line.rstrip('\n')
3330
class FeatureAlreadyRegistered(BzrError):
3332
_fmt = 'The feature %(feature)s has already been registered.'
3334
def __init__(self, feature):
3335
self.feature = feature