1714
2370
self.extra = ''
1717
class InvalidImportLine(BzrError):
2373
class InvalidImportLine(InternalBzrError):
1719
2375
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
1721
internal_error = True
1723
2377
def __init__(self, text, msg):
1724
2378
BzrError.__init__(self)
1725
2379
self.text = text
1729
class ImportNameCollision(BzrError):
1731
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
2383
class ImportNameCollision(InternalBzrError):
2385
_fmt = ("Tried to import an object to the same name as"
2386
" an existing object. %(name)s")
2388
def __init__(self, name):
2389
BzrError.__init__(self)
2393
class NotAMergeDirective(BzrError):
2394
"""File starting with %(firstline)r is not a merge directive"""
2395
def __init__(self, firstline):
2396
BzrError.__init__(self, firstline=firstline)
2399
class NoMergeSource(BzrError):
2400
"""Raise if no merge source was specified for a merge directive"""
2402
_fmt = "A merge directive must provide either a bundle or a public"\
2406
class IllegalMergeDirectivePayload(BzrError):
2407
"""A merge directive contained something other than a patch or bundle"""
2409
_fmt = "Bad merge directive payload %(start)r"
2411
def __init__(self, start):
2416
class PatchVerificationFailed(BzrError):
2417
"""A patch from a merge directive could not be verified"""
2419
_fmt = "Preview patch does not match requested changes."
2422
class PatchMissing(BzrError):
2423
"""Raise a patch type was specified but no patch supplied"""
2425
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2427
def __init__(self, patch_type):
2428
BzrError.__init__(self)
2429
self.patch_type = patch_type
2432
class TargetNotBranch(BzrError):
2433
"""A merge directive's target branch is required, but isn't a branch"""
2435
_fmt = ("Your branch does not have all of the revisions required in "
2436
"order to merge this merge directive and the target "
2437
"location specified in the merge directive is not a branch: "
2440
def __init__(self, location):
2441
BzrError.__init__(self)
2442
self.location = location
2445
class UnsupportedInventoryKind(BzrError):
2447
_fmt = """Unsupported entry kind %(kind)s"""
2449
def __init__(self, kind):
2453
class BadSubsumeSource(BzrError):
2455
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2457
def __init__(self, tree, other_tree, reason):
2459
self.other_tree = other_tree
2460
self.reason = reason
2463
class SubsumeTargetNeedsUpgrade(BzrError):
2465
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2467
def __init__(self, other_tree):
2468
self.other_tree = other_tree
2471
class BadReferenceTarget(InternalBzrError):
2473
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2476
def __init__(self, tree, other_tree, reason):
2478
self.other_tree = other_tree
2479
self.reason = reason
2482
class NoSuchTag(BzrError):
2484
_fmt = "No such tag: %(tag_name)s"
2486
def __init__(self, tag_name):
2487
self.tag_name = tag_name
2490
class TagsNotSupported(BzrError):
2492
_fmt = ("Tags not supported by %(branch)s;"
2493
" you may be able to use bzr upgrade.")
2495
def __init__(self, branch):
2496
self.branch = branch
2499
class TagAlreadyExists(BzrError):
2501
_fmt = "Tag %(tag_name)s already exists."
2503
def __init__(self, tag_name):
2504
self.tag_name = tag_name
2507
class MalformedBugIdentifier(BzrError):
2509
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2511
def __init__(self, bug_id, reason):
2512
self.bug_id = bug_id
2513
self.reason = reason
2516
class InvalidBugTrackerURL(BzrError):
2518
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2519
"contain {id}: %(url)s")
2521
def __init__(self, abbreviation, url):
2522
self.abbreviation = abbreviation
2526
class UnknownBugTrackerAbbreviation(BzrError):
2528
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2531
def __init__(self, abbreviation, branch):
2532
self.abbreviation = abbreviation
2533
self.branch = branch
2536
class UnexpectedSmartServerResponse(BzrError):
2538
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2540
def __init__(self, response_tuple):
2541
self.response_tuple = response_tuple
2544
class ErrorFromSmartServer(BzrError):
2545
"""An error was received from a smart server.
2547
:seealso: UnknownErrorFromSmartServer
2550
_fmt = "Error received from smart server: %(error_tuple)r"
1733
2552
internal_error = True
1735
def __init__(self, name):
1736
BzrError.__init__(self)
2554
def __init__(self, error_tuple):
2555
self.error_tuple = error_tuple
2557
self.error_verb = error_tuple[0]
2559
self.error_verb = None
2560
self.error_args = error_tuple[1:]
2563
class UnknownErrorFromSmartServer(BzrError):
2564
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2567
This is distinct from ErrorFromSmartServer so that it is possible to
2568
distinguish between the following two cases:
2569
- ErrorFromSmartServer was uncaught. This is logic error in the client
2570
and so should provoke a traceback to the user.
2571
- ErrorFromSmartServer was caught but its error_tuple could not be
2572
translated. This is probably because the server sent us garbage, and
2573
should not provoke a traceback.
2576
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2578
internal_error = False
2580
def __init__(self, error_from_smart_server):
2583
:param error_from_smart_server: An ErrorFromSmartServer instance.
2585
self.error_from_smart_server = error_from_smart_server
2586
self.error_tuple = error_from_smart_server.error_tuple
2589
class ContainerError(BzrError):
2590
"""Base class of container errors."""
2593
class UnknownContainerFormatError(ContainerError):
2595
_fmt = "Unrecognised container format: %(container_format)r"
2597
def __init__(self, container_format):
2598
self.container_format = container_format
2601
class UnexpectedEndOfContainerError(ContainerError):
2603
_fmt = "Unexpected end of container stream"
2606
class UnknownRecordTypeError(ContainerError):
2608
_fmt = "Unknown record type: %(record_type)r"
2610
def __init__(self, record_type):
2611
self.record_type = record_type
2614
class InvalidRecordError(ContainerError):
2616
_fmt = "Invalid record: %(reason)s"
2618
def __init__(self, reason):
2619
self.reason = reason
2622
class ContainerHasExcessDataError(ContainerError):
2624
_fmt = "Container has data after end marker: %(excess)r"
2626
def __init__(self, excess):
2627
self.excess = excess
2630
class DuplicateRecordNameError(ContainerError):
2632
_fmt = "Container has multiple records with the same name: %(name)s"
2634
def __init__(self, name):
2638
class NoDestinationAddress(InternalBzrError):
2640
_fmt = "Message does not have a destination address."
2643
class RepositoryDataStreamError(BzrError):
2645
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2647
def __init__(self, reason):
2648
self.reason = reason
2651
class SMTPError(BzrError):
2653
_fmt = "SMTP error: %(error)s"
2655
def __init__(self, error):
2659
class NoMessageSupplied(BzrError):
2661
_fmt = "No message supplied."
2664
class NoMailAddressSpecified(BzrError):
2666
_fmt = "No mail-to address specified."
2669
class UnknownMailClient(BzrError):
2671
_fmt = "Unknown mail client: %(mail_client)s"
2673
def __init__(self, mail_client):
2674
BzrError.__init__(self, mail_client=mail_client)
2677
class MailClientNotFound(BzrError):
2679
_fmt = "Unable to find mail client with the following names:"\
2680
" %(mail_command_list_string)s"
2682
def __init__(self, mail_command_list):
2683
mail_command_list_string = ', '.join(mail_command_list)
2684
BzrError.__init__(self, mail_command_list=mail_command_list,
2685
mail_command_list_string=mail_command_list_string)
2687
class SMTPConnectionRefused(SMTPError):
2689
_fmt = "SMTP connection to %(host)s refused"
2691
def __init__(self, error, host):
2696
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2698
_fmt = "Please specify smtp_server. No server at default %(host)s."
2701
class BzrDirError(BzrError):
2703
def __init__(self, bzrdir):
2704
import bzrlib.urlutils as urlutils
2705
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2707
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2710
class UnsyncedBranches(BzrDirError):
2712
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2713
" bzr help sync-for-reconfigure.")
2715
def __init__(self, bzrdir, target_branch):
2716
BzrDirError.__init__(self, bzrdir)
2717
import bzrlib.urlutils as urlutils
2718
self.target_url = urlutils.unescape_for_display(target_branch.base,
2722
class AlreadyBranch(BzrDirError):
2724
_fmt = "'%(display_url)s' is already a branch."
2727
class AlreadyTree(BzrDirError):
2729
_fmt = "'%(display_url)s' is already a tree."
2732
class AlreadyCheckout(BzrDirError):
2734
_fmt = "'%(display_url)s' is already a checkout."
2737
class AlreadyLightweightCheckout(BzrDirError):
2739
_fmt = "'%(display_url)s' is already a lightweight checkout."
2742
class AlreadyUsingShared(BzrDirError):
2744
_fmt = "'%(display_url)s' is already using a shared repository."
2747
class AlreadyStandalone(BzrDirError):
2749
_fmt = "'%(display_url)s' is already standalone."
2752
class ReconfigurationNotSupported(BzrDirError):
2754
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2757
class NoBindLocation(BzrDirError):
2759
_fmt = "No location could be found to bind to at %(display_url)s."
2762
class UncommittedChanges(BzrError):
2764
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2766
def __init__(self, tree):
2767
import bzrlib.urlutils as urlutils
2768
display_url = urlutils.unescape_for_display(
2769
tree.bzrdir.root_transport.base, 'ascii')
2770
BzrError.__init__(self, tree=tree, display_url=display_url)
2773
class MissingTemplateVariable(BzrError):
2775
_fmt = 'Variable {%(name)s} is not available.'
2777
def __init__(self, name):
2781
class NoTemplate(BzrError):
2783
_fmt = 'No template specified.'
2786
class UnableCreateSymlink(BzrError):
2788
_fmt = 'Unable to create symlink %(path_str)son this platform'
2790
def __init__(self, path=None):
2794
path_str = repr(str(path))
2795
except UnicodeEncodeError:
2796
path_str = repr(path)
2798
self.path_str = path_str
2801
class UnsupportedTimezoneFormat(BzrError):
2803
_fmt = ('Unsupported timezone format "%(timezone)s", '
2804
'options are "utc", "original", "local".')
2806
def __init__(self, timezone):
2807
self.timezone = timezone
2810
class CommandAvailableInPlugin(StandardError):
2812
internal_error = False
2814
def __init__(self, cmd_name, plugin_metadata, provider):
2816
self.plugin_metadata = plugin_metadata
2817
self.cmd_name = cmd_name
2818
self.provider = provider
2822
_fmt = ('"%s" is not a standard bzr command. \n'
2823
'However, the following official plugin provides this command: %s\n'
2824
'You can install it by going to: %s'
2825
% (self.cmd_name, self.plugin_metadata['name'],
2826
self.plugin_metadata['url']))
2831
class NoPluginAvailable(BzrError):
2835
class NotATerminal(BzrError):
2837
_fmt = 'Unable to ask for a password without real terminal.'
2840
class UnableEncodePath(BzrError):
2842
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2843
'user encoding %(user_encoding)s')
2845
def __init__(self, path, kind):
2846
from bzrlib.osutils import get_user_encoding
2849
self.user_encoding = osutils.get_user_encoding()
2852
class NoSuchAlias(BzrError):
2854
_fmt = ('The alias "%(alias_name)s" does not exist.')
2856
def __init__(self, alias_name):
2857
BzrError.__init__(self, alias_name=alias_name)
2860
class DirectoryLookupFailure(BzrError):
2861
"""Base type for lookup errors."""
2866
class InvalidLocationAlias(DirectoryLookupFailure):
2868
_fmt = '"%(alias_name)s" is not a valid location alias.'
2870
def __init__(self, alias_name):
2871
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2874
class UnsetLocationAlias(DirectoryLookupFailure):
2876
_fmt = 'No %(alias_name)s location assigned.'
2878
def __init__(self, alias_name):
2879
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2882
class CannotBindAddress(BzrError):
2884
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2886
def __init__(self, host, port, orig_error):
2887
BzrError.__init__(self, host=host, port=port,
2888
orig_error=orig_error[1])
2891
class UnknownRules(BzrError):
2893
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2895
def __init__(self, unknowns):
2896
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2899
class HookFailed(BzrError):
2900
"""Raised when a pre_change_branch_tip hook function fails anything other
2901
than TipChangeRejected.
2904
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2905
"%(traceback_text)s%(exc_value)s")
2907
def __init__(self, hook_stage, hook_name, exc_info):
2909
self.hook_stage = hook_stage
2910
self.hook_name = hook_name
2911
self.exc_info = exc_info
2912
self.exc_type = exc_info[0]
2913
self.exc_value = exc_info[1]
2914
self.exc_tb = exc_info[2]
2915
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2918
class TipChangeRejected(BzrError):
2919
"""A pre_change_branch_tip hook function may raise this to cleanly and
2920
explicitly abort a change to a branch tip.
2923
_fmt = u"Tip change rejected: %(msg)s"
2925
def __init__(self, msg):
2929
class ShelfCorrupt(BzrError):
2931
_fmt = "Shelf corrupt."
2934
class NoSuchShelfId(BzrError):
2936
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2938
def __init__(self, shelf_id):
2939
BzrError.__init__(self, shelf_id=shelf_id)
2942
class UserAbort(BzrError):
2944
_fmt = 'The user aborted the operation.'