2476
2028
def __init__(self, branch):
2477
2029
self.branch = branch
2480
2032
class TagAlreadyExists(BzrError):
2482
2034
_fmt = "Tag %(tag_name)s already exists."
2484
2036
def __init__(self, tag_name):
2485
2037
self.tag_name = tag_name
2488
class MalformedBugIdentifier(BzrError):
2490
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2491
'See "bzr help bugs" for more information on this feature.')
2493
def __init__(self, bug_id, reason):
2494
self.bug_id = bug_id
2495
self.reason = reason
2498
class InvalidBugTrackerURL(BzrError):
2500
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2501
"contain {id}: %(url)s")
2503
def __init__(self, abbreviation, url):
2504
self.abbreviation = abbreviation
2508
class UnknownBugTrackerAbbreviation(BzrError):
2510
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2513
def __init__(self, abbreviation, branch):
2514
self.abbreviation = abbreviation
2515
self.branch = branch
2518
class InvalidLineInBugsProperty(BzrError):
2520
_fmt = ("Invalid line in bugs property: '%(line)s'")
2522
def __init__(self, line):
2526
class InvalidBugStatus(BzrError):
2528
_fmt = ("Invalid bug status: '%(status)s'")
2530
def __init__(self, status):
2531
self.status = status
2534
class UnexpectedSmartServerResponse(BzrError):
2536
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2538
def __init__(self, response_tuple):
2539
self.response_tuple = response_tuple
2542
class ErrorFromSmartServer(BzrError):
2543
"""An error was received from a smart server.
2545
:seealso: UnknownErrorFromSmartServer
2548
_fmt = "Error received from smart server: %(error_tuple)r"
2550
internal_error = True
2552
def __init__(self, error_tuple):
2553
self.error_tuple = error_tuple
2555
self.error_verb = error_tuple[0]
2557
self.error_verb = None
2558
self.error_args = error_tuple[1:]
2561
class UnknownErrorFromSmartServer(BzrError):
2562
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2565
This is distinct from ErrorFromSmartServer so that it is possible to
2566
distinguish between the following two cases:
2567
- ErrorFromSmartServer was uncaught. This is logic error in the client
2568
and so should provoke a traceback to the user.
2569
- ErrorFromSmartServer was caught but its error_tuple could not be
2570
translated. This is probably because the server sent us garbage, and
2571
should not provoke a traceback.
2574
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2576
internal_error = False
2578
def __init__(self, error_from_smart_server):
2581
:param error_from_smart_server: An ErrorFromSmartServer instance.
2583
self.error_from_smart_server = error_from_smart_server
2584
self.error_tuple = error_from_smart_server.error_tuple
2587
class ContainerError(BzrError):
2588
"""Base class of container errors."""
2591
class UnknownContainerFormatError(ContainerError):
2593
_fmt = "Unrecognised container format: %(container_format)r"
2595
def __init__(self, container_format):
2596
self.container_format = container_format
2599
class UnexpectedEndOfContainerError(ContainerError):
2601
_fmt = "Unexpected end of container stream"
2604
class UnknownRecordTypeError(ContainerError):
2606
_fmt = "Unknown record type: %(record_type)r"
2608
def __init__(self, record_type):
2609
self.record_type = record_type
2612
class InvalidRecordError(ContainerError):
2614
_fmt = "Invalid record: %(reason)s"
2616
def __init__(self, reason):
2617
self.reason = reason
2620
class ContainerHasExcessDataError(ContainerError):
2622
_fmt = "Container has data after end marker: %(excess)r"
2624
def __init__(self, excess):
2625
self.excess = excess
2628
class DuplicateRecordNameError(ContainerError):
2630
_fmt = "Container has multiple records with the same name: %(name)s"
2632
def __init__(self, name):
2636
class NoDestinationAddress(InternalBzrError):
2638
_fmt = "Message does not have a destination address."
2641
class RepositoryDataStreamError(BzrError):
2643
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2645
def __init__(self, reason):
2646
self.reason = reason
2649
class SMTPError(BzrError):
2651
_fmt = "SMTP error: %(error)s"
2653
def __init__(self, error):
2657
class NoMessageSupplied(BzrError):
2659
_fmt = "No message supplied."
2662
class NoMailAddressSpecified(BzrError):
2664
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2667
class UnknownMailClient(BzrError):
2669
_fmt = "Unknown mail client: %(mail_client)s"
2671
def __init__(self, mail_client):
2672
BzrError.__init__(self, mail_client=mail_client)
2675
class MailClientNotFound(BzrError):
2677
_fmt = "Unable to find mail client with the following names:"\
2678
" %(mail_command_list_string)s"
2680
def __init__(self, mail_command_list):
2681
mail_command_list_string = ', '.join(mail_command_list)
2682
BzrError.__init__(self, mail_command_list=mail_command_list,
2683
mail_command_list_string=mail_command_list_string)
2685
class SMTPConnectionRefused(SMTPError):
2687
_fmt = "SMTP connection to %(host)s refused"
2689
def __init__(self, error, host):
2694
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2696
_fmt = "Please specify smtp_server. No server at default %(host)s."
2699
class BzrDirError(BzrError):
2701
def __init__(self, bzrdir):
2702
import bzrlib.urlutils as urlutils
2703
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2705
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2708
class UnsyncedBranches(BzrDirError):
2710
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2711
" bzr help sync-for-reconfigure.")
2713
def __init__(self, bzrdir, target_branch):
2714
BzrDirError.__init__(self, bzrdir)
2715
import bzrlib.urlutils as urlutils
2716
self.target_url = urlutils.unescape_for_display(target_branch.base,
2720
class AlreadyBranch(BzrDirError):
2722
_fmt = "'%(display_url)s' is already a branch."
2725
class AlreadyTree(BzrDirError):
2727
_fmt = "'%(display_url)s' is already a tree."
2730
class AlreadyCheckout(BzrDirError):
2732
_fmt = "'%(display_url)s' is already a checkout."
2735
class AlreadyLightweightCheckout(BzrDirError):
2737
_fmt = "'%(display_url)s' is already a lightweight checkout."
2740
class AlreadyUsingShared(BzrDirError):
2742
_fmt = "'%(display_url)s' is already using a shared repository."
2745
class AlreadyStandalone(BzrDirError):
2747
_fmt = "'%(display_url)s' is already standalone."
2750
class AlreadyWithTrees(BzrDirError):
2752
_fmt = ("Shared repository '%(display_url)s' already creates "
2756
class AlreadyWithNoTrees(BzrDirError):
2758
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2762
class ReconfigurationNotSupported(BzrDirError):
2764
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2767
class NoBindLocation(BzrDirError):
2769
_fmt = "No location could be found to bind to at %(display_url)s."
2772
class UncommittedChanges(BzrError):
2774
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2776
def __init__(self, tree):
2777
import bzrlib.urlutils as urlutils
2778
display_url = urlutils.unescape_for_display(
2779
tree.bzrdir.root_transport.base, 'ascii')
2780
BzrError.__init__(self, tree=tree, display_url=display_url)
2783
class MissingTemplateVariable(BzrError):
2785
_fmt = 'Variable {%(name)s} is not available.'
2787
def __init__(self, name):
2791
class NoTemplate(BzrError):
2793
_fmt = 'No template specified.'
2796
class UnableCreateSymlink(BzrError):
2798
_fmt = 'Unable to create symlink %(path_str)son this platform'
2800
def __init__(self, path=None):
2804
path_str = repr(str(path))
2805
except UnicodeEncodeError:
2806
path_str = repr(path)
2808
self.path_str = path_str
2811
class UnsupportedTimezoneFormat(BzrError):
2813
_fmt = ('Unsupported timezone format "%(timezone)s", '
2814
'options are "utc", "original", "local".')
2816
def __init__(self, timezone):
2817
self.timezone = timezone
2820
class CommandAvailableInPlugin(StandardError):
2822
internal_error = False
2824
def __init__(self, cmd_name, plugin_metadata, provider):
2826
self.plugin_metadata = plugin_metadata
2827
self.cmd_name = cmd_name
2828
self.provider = provider
2832
_fmt = ('"%s" is not a standard bzr command. \n'
2833
'However, the following official plugin provides this command: %s\n'
2834
'You can install it by going to: %s'
2835
% (self.cmd_name, self.plugin_metadata['name'],
2836
self.plugin_metadata['url']))
2841
class NoPluginAvailable(BzrError):
2845
class UnableEncodePath(BzrError):
2847
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2848
'user encoding %(user_encoding)s')
2850
def __init__(self, path, kind):
2851
from bzrlib.osutils import get_user_encoding
2854
self.user_encoding = osutils.get_user_encoding()
2857
class NoSuchAlias(BzrError):
2859
_fmt = ('The alias "%(alias_name)s" does not exist.')
2861
def __init__(self, alias_name):
2862
BzrError.__init__(self, alias_name=alias_name)
2865
class DirectoryLookupFailure(BzrError):
2866
"""Base type for lookup errors."""
2871
class InvalidLocationAlias(DirectoryLookupFailure):
2873
_fmt = '"%(alias_name)s" is not a valid location alias.'
2875
def __init__(self, alias_name):
2876
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2879
class UnsetLocationAlias(DirectoryLookupFailure):
2881
_fmt = 'No %(alias_name)s location assigned.'
2883
def __init__(self, alias_name):
2884
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2887
class CannotBindAddress(BzrError):
2889
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2891
def __init__(self, host, port, orig_error):
2892
BzrError.__init__(self, host=host, port=port,
2893
orig_error=orig_error[1])
2896
class UnknownRules(BzrError):
2898
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2900
def __init__(self, unknowns):
2901
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2904
class HookFailed(BzrError):
2905
"""Raised when a pre_change_branch_tip hook function fails anything other
2906
than TipChangeRejected.
2909
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2910
"%(traceback_text)s%(exc_value)s")
2912
def __init__(self, hook_stage, hook_name, exc_info):
2914
self.hook_stage = hook_stage
2915
self.hook_name = hook_name
2916
self.exc_info = exc_info
2917
self.exc_type = exc_info[0]
2918
self.exc_value = exc_info[1]
2919
self.exc_tb = exc_info[2]
2920
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2923
class TipChangeRejected(BzrError):
2924
"""A pre_change_branch_tip hook function may raise this to cleanly and
2925
explicitly abort a change to a branch tip.
2928
_fmt = u"Tip change rejected: %(msg)s"
2930
def __init__(self, msg):
2934
class ShelfCorrupt(BzrError):
2936
_fmt = "Shelf corrupt."
2939
class NoSuchShelfId(BzrError):
2941
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2943
def __init__(self, shelf_id):
2944
BzrError.__init__(self, shelf_id=shelf_id)
2947
class InvalidShelfId(BzrError):
2949
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2951
def __init__(self, invalid_id):
2952
BzrError.__init__(self, invalid_id=invalid_id)
2955
class JailBreak(BzrError):
2957
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2959
def __init__(self, url):
2960
BzrError.__init__(self, url=url)
2963
class UserAbort(BzrError):
2965
_fmt = 'The user aborted the operation.'
2968
class MustHaveWorkingTree(BzrError):
2970
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
2972
def __init__(self, format, url):
2973
BzrError.__init__(self, format=format, url=url)
2976
class NoSuchView(BzrError):
2977
"""A view does not exist.
2980
_fmt = u"No such view: %(view_name)s."
2982
def __init__(self, view_name):
2983
self.view_name = view_name
2986
class ViewsNotSupported(BzrError):
2987
"""Views are not supported by a tree format.
2990
_fmt = ("Views are not supported by %(tree)s;"
2991
" use 'bzr upgrade' to change your tree to a later format.")
2993
def __init__(self, tree):
2997
class FileOutsideView(BzrError):
2999
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3002
def __init__(self, file_name, view_files):
3003
self.file_name = file_name
3004
self.view_str = ", ".join(view_files)
3007
class UnresumableWriteGroup(BzrError):
3009
_fmt = ("Repository %(repository)s cannot resume write group "
3010
"%(write_groups)r: %(reason)s")
3012
internal_error = True
3014
def __init__(self, repository, write_groups, reason):
3015
self.repository = repository
3016
self.write_groups = write_groups
3017
self.reason = reason
3020
class UnsuspendableWriteGroup(BzrError):
3022
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3024
internal_error = True
3026
def __init__(self, repository):
3027
self.repository = repository