1771
2414
self.extra = ''
1774
class InvalidImportLine(BzrError):
2417
class InvalidImportLine(InternalBzrError):
1776
2419
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
1778
internal_error = True
1780
2421
def __init__(self, text, msg):
1781
2422
BzrError.__init__(self)
1782
2423
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)
2427
class ImportNameCollision(InternalBzrError):
2429
_fmt = ("Tried to import an object to the same name as"
2430
" an existing object. %(name)s")
2432
def __init__(self, name):
2433
BzrError.__init__(self)
2437
class NotAMergeDirective(BzrError):
2438
"""File starting with %(firstline)r is not a merge directive"""
2439
def __init__(self, firstline):
2440
BzrError.__init__(self, firstline=firstline)
2443
class NoMergeSource(BzrError):
2444
"""Raise if no merge source was specified for a merge directive"""
2446
_fmt = "A merge directive must provide either a bundle or a public"\
2450
class IllegalMergeDirectivePayload(BzrError):
2451
"""A merge directive contained something other than a patch or bundle"""
2453
_fmt = "Bad merge directive payload %(start)r"
2455
def __init__(self, start):
2460
class PatchVerificationFailed(BzrError):
2461
"""A patch from a merge directive could not be verified"""
2463
_fmt = "Preview patch does not match requested changes."
2466
class PatchMissing(BzrError):
2467
"""Raise a patch type was specified but no patch supplied"""
2469
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2471
def __init__(self, patch_type):
2472
BzrError.__init__(self)
2473
self.patch_type = patch_type
2476
class TargetNotBranch(BzrError):
2477
"""A merge directive's target branch is required, but isn't a branch"""
2479
_fmt = ("Your branch does not have all of the revisions required in "
2480
"order to merge this merge directive and the target "
2481
"location specified in the merge directive is not a branch: "
2484
def __init__(self, location):
2485
BzrError.__init__(self)
2486
self.location = location
2489
class UnsupportedInventoryKind(BzrError):
2491
_fmt = """Unsupported entry kind %(kind)s"""
2493
def __init__(self, kind):
2497
class BadSubsumeSource(BzrError):
2499
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2501
def __init__(self, tree, other_tree, reason):
2503
self.other_tree = other_tree
2504
self.reason = reason
2507
class SubsumeTargetNeedsUpgrade(BzrError):
2509
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2511
def __init__(self, other_tree):
2512
self.other_tree = other_tree
2515
class BadReferenceTarget(InternalBzrError):
2517
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2520
def __init__(self, tree, other_tree, reason):
2522
self.other_tree = other_tree
2523
self.reason = reason
2526
class NoSuchTag(BzrError):
2528
_fmt = "No such tag: %(tag_name)s"
2530
def __init__(self, tag_name):
2531
self.tag_name = tag_name
2534
class TagsNotSupported(BzrError):
2536
_fmt = ("Tags not supported by %(branch)s;"
2537
" you may be able to use bzr upgrade.")
2539
def __init__(self, branch):
2540
self.branch = branch
2543
class TagAlreadyExists(BzrError):
2545
_fmt = "Tag %(tag_name)s already exists."
2547
def __init__(self, tag_name):
2548
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
display_url = urlutils.unescape_for_display(
2847
tree.user_url, 'ascii')
2848
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2851
class ShelvedChanges(UncommittedChanges):
2853
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2854
' (See bzr shelve --list).%(more)s')
2857
class MissingTemplateVariable(BzrError):
2859
_fmt = 'Variable {%(name)s} is not available.'
2861
def __init__(self, name):
2865
class NoTemplate(BzrError):
2867
_fmt = 'No template specified.'
2870
class UnableCreateSymlink(BzrError):
2872
_fmt = 'Unable to create symlink %(path_str)son this platform'
2874
def __init__(self, path=None):
2878
path_str = repr(str(path))
2879
except UnicodeEncodeError:
2880
path_str = repr(path)
2882
self.path_str = path_str
2885
class UnsupportedTimezoneFormat(BzrError):
2887
_fmt = ('Unsupported timezone format "%(timezone)s", '
2888
'options are "utc", "original", "local".')
2890
def __init__(self, timezone):
2891
self.timezone = timezone
2894
class CommandAvailableInPlugin(StandardError):
2896
internal_error = False
2898
def __init__(self, cmd_name, plugin_metadata, provider):
2900
self.plugin_metadata = plugin_metadata
2901
self.cmd_name = cmd_name
2902
self.provider = provider
2906
_fmt = ('"%s" is not a standard bzr command. \n'
2907
'However, the following official plugin provides this command: %s\n'
2908
'You can install it by going to: %s'
2909
% (self.cmd_name, self.plugin_metadata['name'],
2910
self.plugin_metadata['url']))
2915
class NoPluginAvailable(BzrError):
2919
class UnableEncodePath(BzrError):
2921
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2922
'user encoding %(user_encoding)s')
2924
def __init__(self, path, kind):
2925
from bzrlib.osutils import get_user_encoding
2928
self.user_encoding = osutils.get_user_encoding()
2931
class NoSuchAlias(BzrError):
2933
_fmt = ('The alias "%(alias_name)s" does not exist.')
2935
def __init__(self, alias_name):
2936
BzrError.__init__(self, alias_name=alias_name)
2939
class DirectoryLookupFailure(BzrError):
2940
"""Base type for lookup errors."""
2945
class InvalidLocationAlias(DirectoryLookupFailure):
2947
_fmt = '"%(alias_name)s" is not a valid location alias.'
2949
def __init__(self, alias_name):
2950
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2953
class UnsetLocationAlias(DirectoryLookupFailure):
2955
_fmt = 'No %(alias_name)s location assigned.'
2957
def __init__(self, alias_name):
2958
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2961
class CannotBindAddress(BzrError):
2963
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2965
def __init__(self, host, port, orig_error):
2966
# nb: in python2.4 socket.error doesn't have a useful repr
2967
BzrError.__init__(self, host=host, port=port,
2968
orig_error=repr(orig_error.args))
2971
class UnknownRules(BzrError):
2973
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2975
def __init__(self, unknowns):
2976
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2979
class HookFailed(BzrError):
2980
"""Raised when a pre_change_branch_tip hook function fails anything other
2981
than TipChangeRejected.
2983
Note that this exception is no longer raised, and the import is only left
2984
to be nice to code which might catch it in a plugin.
2987
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2988
"%(traceback_text)s%(exc_value)s")
2990
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
2992
symbol_versioning.warn("BzrError HookFailed has been deprecated "
2993
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
2995
self.hook_stage = hook_stage
2996
self.hook_name = hook_name
2997
self.exc_info = exc_info
2998
self.exc_type = exc_info[0]
2999
self.exc_value = exc_info[1]
3000
self.exc_tb = exc_info[2]
3001
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3004
class TipChangeRejected(BzrError):
3005
"""A pre_change_branch_tip hook function may raise this to cleanly and
3006
explicitly abort a change to a branch tip.
3009
_fmt = u"Tip change rejected: %(msg)s"
3011
def __init__(self, msg):
3015
class ShelfCorrupt(BzrError):
3017
_fmt = "Shelf corrupt."
3020
class NoSuchShelfId(BzrError):
3022
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3024
def __init__(self, shelf_id):
3025
BzrError.__init__(self, shelf_id=shelf_id)
3028
class InvalidShelfId(BzrError):
3030
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3032
def __init__(self, invalid_id):
3033
BzrError.__init__(self, invalid_id=invalid_id)
3036
class JailBreak(BzrError):
3038
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3040
def __init__(self, url):
3041
BzrError.__init__(self, url=url)
3044
class UserAbort(BzrError):
3046
_fmt = 'The user aborted the operation.'
3049
class MustHaveWorkingTree(BzrError):
3051
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3053
def __init__(self, format, url):
3054
BzrError.__init__(self, format=format, url=url)
3057
class NoSuchView(BzrError):
3058
"""A view does not exist.
3061
_fmt = u"No such view: %(view_name)s."
3063
def __init__(self, view_name):
3064
self.view_name = view_name
3067
class ViewsNotSupported(BzrError):
3068
"""Views are not supported by a tree format.
3071
_fmt = ("Views are not supported by %(tree)s;"
3072
" use 'bzr upgrade' to change your tree to a later format.")
3074
def __init__(self, tree):
3078
class FileOutsideView(BzrError):
3080
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3083
def __init__(self, file_name, view_files):
3084
self.file_name = file_name
3085
self.view_str = ", ".join(view_files)
3088
class UnresumableWriteGroup(BzrError):
3090
_fmt = ("Repository %(repository)s cannot resume write group "
3091
"%(write_groups)r: %(reason)s")
3093
internal_error = True
3095
def __init__(self, repository, write_groups, reason):
3096
self.repository = repository
3097
self.write_groups = write_groups
3098
self.reason = reason
3101
class UnsuspendableWriteGroup(BzrError):
3103
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3105
internal_error = True
3107
def __init__(self, repository):
3108
self.repository = repository
3111
class LossyPushToSameVCS(BzrError):
3113
_fmt = ("Lossy push not possible between %(source_branch)r and "
3114
"%(target_branch)r that are in the same VCS.")
3116
internal_error = True
3118
def __init__(self, source_branch, target_branch):
3119
self.source_branch = source_branch
3120
self.target_branch = target_branch
3123
class NoRoundtrippingSupport(BzrError):
3125
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3126
"%(target_branch)r.")
3128
internal_error = True
3130
def __init__(self, source_branch, target_branch):
3131
self.source_branch = source_branch
3132
self.target_branch = target_branch
3135
class FileTimestampUnavailable(BzrError):
3137
_fmt = "The filestamp for %(path)s is not available."
3139
internal_error = True
3141
def __init__(self, path):
3145
class NoColocatedBranchSupport(BzrError):
3147
_fmt = ("%(bzrdir)r does not support co-located branches.")
3149
def __init__(self, bzrdir):
3150
self.bzrdir = bzrdir
3152
class NoWhoami(BzrError):
3154
_fmt = ('Unable to determine your name.\n'
3155
"Please, set your name with the 'whoami' command.\n"
3156
'E.g. bzr whoami "Your Name <name@example.com>"')