1791
2365
self.extra = ''
1794
class InvalidImportLine(BzrError):
2368
class InvalidImportLine(InternalBzrError):
1796
2370
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
1798
internal_error = True
1800
2372
def __init__(self, text, msg):
1801
2373
BzrError.__init__(self)
1802
2374
self.text = text
1806
class ImportNameCollision(BzrError):
1808
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
2378
class ImportNameCollision(InternalBzrError):
2380
_fmt = ("Tried to import an object to the same name as"
2381
" an existing object. %(name)s")
2383
def __init__(self, name):
2384
BzrError.__init__(self)
2388
class NotAMergeDirective(BzrError):
2389
"""File starting with %(firstline)r is not a merge directive"""
2390
def __init__(self, firstline):
2391
BzrError.__init__(self, firstline=firstline)
2394
class NoMergeSource(BzrError):
2395
"""Raise if no merge source was specified for a merge directive"""
2397
_fmt = "A merge directive must provide either a bundle or a public"\
2401
class IllegalMergeDirectivePayload(BzrError):
2402
"""A merge directive contained something other than a patch or bundle"""
2404
_fmt = "Bad merge directive payload %(start)r"
2406
def __init__(self, start):
2411
class PatchVerificationFailed(BzrError):
2412
"""A patch from a merge directive could not be verified"""
2414
_fmt = "Preview patch does not match requested changes."
2417
class PatchMissing(BzrError):
2418
"""Raise a patch type was specified but no patch supplied"""
2420
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2422
def __init__(self, patch_type):
2423
BzrError.__init__(self)
2424
self.patch_type = patch_type
2427
class TargetNotBranch(BzrError):
2428
"""A merge directive's target branch is required, but isn't a branch"""
2430
_fmt = ("Your branch does not have all of the revisions required in "
2431
"order to merge this merge directive and the target "
2432
"location specified in the merge directive is not a branch: "
2435
def __init__(self, location):
2436
BzrError.__init__(self)
2437
self.location = location
2440
class UnsupportedInventoryKind(BzrError):
2442
_fmt = """Unsupported entry kind %(kind)s"""
2444
def __init__(self, kind):
2448
class BadSubsumeSource(BzrError):
2450
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2452
def __init__(self, tree, other_tree, reason):
2454
self.other_tree = other_tree
2455
self.reason = reason
2458
class SubsumeTargetNeedsUpgrade(BzrError):
2460
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2462
def __init__(self, other_tree):
2463
self.other_tree = other_tree
2466
class BadReferenceTarget(InternalBzrError):
2468
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2471
def __init__(self, tree, other_tree, reason):
2473
self.other_tree = other_tree
2474
self.reason = reason
2477
class NoSuchTag(BzrError):
2479
_fmt = "No such tag: %(tag_name)s"
2481
def __init__(self, tag_name):
2482
self.tag_name = tag_name
2485
class TagsNotSupported(BzrError):
2487
_fmt = ("Tags not supported by %(branch)s;"
2488
" you may be able to use bzr upgrade.")
2490
def __init__(self, branch):
2491
self.branch = branch
2494
class TagAlreadyExists(BzrError):
2496
_fmt = "Tag %(tag_name)s already exists."
2498
def __init__(self, tag_name):
2499
self.tag_name = tag_name
2502
class MalformedBugIdentifier(BzrError):
2504
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2506
def __init__(self, bug_id, reason):
2507
self.bug_id = bug_id
2508
self.reason = reason
2511
class InvalidBugTrackerURL(BzrError):
2513
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2514
"contain {id}: %(url)s")
2516
def __init__(self, abbreviation, url):
2517
self.abbreviation = abbreviation
2521
class UnknownBugTrackerAbbreviation(BzrError):
2523
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2526
def __init__(self, abbreviation, branch):
2527
self.abbreviation = abbreviation
2528
self.branch = branch
2531
class UnexpectedSmartServerResponse(BzrError):
2533
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2535
def __init__(self, response_tuple):
2536
self.response_tuple = response_tuple
2539
class ErrorFromSmartServer(BzrError):
2540
"""An error was received from a smart server.
2542
:seealso: UnknownErrorFromSmartServer
2545
_fmt = "Error received from smart server: %(error_tuple)r"
1810
2547
internal_error = True
1812
def __init__(self, name):
1813
BzrError.__init__(self)
2549
def __init__(self, error_tuple):
2550
self.error_tuple = error_tuple
2552
self.error_verb = error_tuple[0]
2554
self.error_verb = None
2555
self.error_args = error_tuple[1:]
2558
class UnknownErrorFromSmartServer(BzrError):
2559
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2562
This is distinct from ErrorFromSmartServer so that it is possible to
2563
distinguish between the following two cases:
2564
- ErrorFromSmartServer was uncaught. This is logic error in the client
2565
and so should provoke a traceback to the user.
2566
- ErrorFromSmartServer was caught but its error_tuple could not be
2567
translated. This is probably because the server sent us garbage, and
2568
should not provoke a traceback.
2571
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2573
internal_error = False
2575
def __init__(self, error_from_smart_server):
2578
:param error_from_smart_server: An ErrorFromSmartServer instance.
2580
self.error_from_smart_server = error_from_smart_server
2581
self.error_tuple = error_from_smart_server.error_tuple
2584
class ContainerError(BzrError):
2585
"""Base class of container errors."""
2588
class UnknownContainerFormatError(ContainerError):
2590
_fmt = "Unrecognised container format: %(container_format)r"
2592
def __init__(self, container_format):
2593
self.container_format = container_format
2596
class UnexpectedEndOfContainerError(ContainerError):
2598
_fmt = "Unexpected end of container stream"
2601
class UnknownRecordTypeError(ContainerError):
2603
_fmt = "Unknown record type: %(record_type)r"
2605
def __init__(self, record_type):
2606
self.record_type = record_type
2609
class InvalidRecordError(ContainerError):
2611
_fmt = "Invalid record: %(reason)s"
2613
def __init__(self, reason):
2614
self.reason = reason
2617
class ContainerHasExcessDataError(ContainerError):
2619
_fmt = "Container has data after end marker: %(excess)r"
2621
def __init__(self, excess):
2622
self.excess = excess
2625
class DuplicateRecordNameError(ContainerError):
2627
_fmt = "Container has multiple records with the same name: %(name)s"
2629
def __init__(self, name):
2633
class NoDestinationAddress(InternalBzrError):
2635
_fmt = "Message does not have a destination address."
2638
class RepositoryDataStreamError(BzrError):
2640
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2642
def __init__(self, reason):
2643
self.reason = reason
2646
class SMTPError(BzrError):
2648
_fmt = "SMTP error: %(error)s"
2650
def __init__(self, error):
2654
class NoMessageSupplied(BzrError):
2656
_fmt = "No message supplied."
2659
class NoMailAddressSpecified(BzrError):
2661
_fmt = "No mail-to address specified."
2664
class UnknownMailClient(BzrError):
2666
_fmt = "Unknown mail client: %(mail_client)s"
2668
def __init__(self, mail_client):
2669
BzrError.__init__(self, mail_client=mail_client)
2672
class MailClientNotFound(BzrError):
2674
_fmt = "Unable to find mail client with the following names:"\
2675
" %(mail_command_list_string)s"
2677
def __init__(self, mail_command_list):
2678
mail_command_list_string = ', '.join(mail_command_list)
2679
BzrError.__init__(self, mail_command_list=mail_command_list,
2680
mail_command_list_string=mail_command_list_string)
2682
class SMTPConnectionRefused(SMTPError):
2684
_fmt = "SMTP connection to %(host)s refused"
2686
def __init__(self, error, host):
2691
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2693
_fmt = "Please specify smtp_server. No server at default %(host)s."
2696
class BzrDirError(BzrError):
2698
def __init__(self, bzrdir):
2699
import bzrlib.urlutils as urlutils
2700
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2702
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2705
class UnsyncedBranches(BzrDirError):
2707
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2708
" bzr help sync-for-reconfigure.")
2710
def __init__(self, bzrdir, target_branch):
2711
BzrDirError.__init__(self, bzrdir)
2712
import bzrlib.urlutils as urlutils
2713
self.target_url = urlutils.unescape_for_display(target_branch.base,
2717
class AlreadyBranch(BzrDirError):
2719
_fmt = "'%(display_url)s' is already a branch."
2722
class AlreadyTree(BzrDirError):
2724
_fmt = "'%(display_url)s' is already a tree."
2727
class AlreadyCheckout(BzrDirError):
2729
_fmt = "'%(display_url)s' is already a checkout."
2732
class AlreadyLightweightCheckout(BzrDirError):
2734
_fmt = "'%(display_url)s' is already a lightweight checkout."
2737
class AlreadyUsingShared(BzrDirError):
2739
_fmt = "'%(display_url)s' is already using a shared repository."
2742
class AlreadyStandalone(BzrDirError):
2744
_fmt = "'%(display_url)s' is already standalone."
2747
class ReconfigurationNotSupported(BzrDirError):
2749
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2752
class NoBindLocation(BzrDirError):
2754
_fmt = "No location could be found to bind to at %(display_url)s."
2757
class UncommittedChanges(BzrError):
2759
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2761
def __init__(self, tree):
2762
import bzrlib.urlutils as urlutils
2763
display_url = urlutils.unescape_for_display(
2764
tree.bzrdir.root_transport.base, 'ascii')
2765
BzrError.__init__(self, tree=tree, display_url=display_url)
2768
class MissingTemplateVariable(BzrError):
2770
_fmt = 'Variable {%(name)s} is not available.'
2772
def __init__(self, name):
2776
class NoTemplate(BzrError):
2778
_fmt = 'No template specified.'
2781
class UnableCreateSymlink(BzrError):
2783
_fmt = 'Unable to create symlink %(path_str)son this platform'
2785
def __init__(self, path=None):
2789
path_str = repr(str(path))
2790
except UnicodeEncodeError:
2791
path_str = repr(path)
2793
self.path_str = path_str
2796
class UnsupportedTimezoneFormat(BzrError):
2798
_fmt = ('Unsupported timezone format "%(timezone)s", '
2799
'options are "utc", "original", "local".')
2801
def __init__(self, timezone):
2802
self.timezone = timezone
2805
class CommandAvailableInPlugin(StandardError):
2807
internal_error = False
2809
def __init__(self, cmd_name, plugin_metadata, provider):
2811
self.plugin_metadata = plugin_metadata
2812
self.cmd_name = cmd_name
2813
self.provider = provider
2817
_fmt = ('"%s" is not a standard bzr command. \n'
2818
'However, the following official plugin provides this command: %s\n'
2819
'You can install it by going to: %s'
2820
% (self.cmd_name, self.plugin_metadata['name'],
2821
self.plugin_metadata['url']))
2826
class NoPluginAvailable(BzrError):
2830
class NotATerminal(BzrError):
2832
_fmt = 'Unable to ask for a password without real terminal.'
2835
class UnableEncodePath(BzrError):
2837
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2838
'user encoding %(user_encoding)s')
2840
def __init__(self, path, kind):
2841
from bzrlib.osutils import get_user_encoding
2844
self.user_encoding = osutils.get_user_encoding()
2847
class NoSuchAlias(BzrError):
2849
_fmt = ('The alias "%(alias_name)s" does not exist.')
2851
def __init__(self, alias_name):
2852
BzrError.__init__(self, alias_name=alias_name)
2855
class DirectoryLookupFailure(BzrError):
2856
"""Base type for lookup errors."""
2861
class InvalidLocationAlias(DirectoryLookupFailure):
2863
_fmt = '"%(alias_name)s" is not a valid location alias.'
2865
def __init__(self, alias_name):
2866
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2869
class UnsetLocationAlias(DirectoryLookupFailure):
2871
_fmt = 'No %(alias_name)s location assigned.'
2873
def __init__(self, alias_name):
2874
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2877
class CannotBindAddress(BzrError):
2879
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2881
def __init__(self, host, port, orig_error):
2882
BzrError.__init__(self, host=host, port=port,
2883
orig_error=orig_error[1])
2886
class UnknownRules(BzrError):
2888
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2890
def __init__(self, unknowns):
2891
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2894
class HookFailed(BzrError):
2895
"""Raised when a pre_change_branch_tip hook function fails anything other
2896
than TipChangeRejected.
2899
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2900
"%(traceback_text)s%(exc_value)s")
2902
def __init__(self, hook_stage, hook_name, exc_info):
2904
self.hook_stage = hook_stage
2905
self.hook_name = hook_name
2906
self.exc_info = exc_info
2907
self.exc_type = exc_info[0]
2908
self.exc_value = exc_info[1]
2909
self.exc_tb = exc_info[2]
2910
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2913
class TipChangeRejected(BzrError):
2914
"""A pre_change_branch_tip hook function may raise this to cleanly and
2915
explicitly abort a change to a branch tip.
2918
_fmt = u"Tip change rejected: %(msg)s"
2920
def __init__(self, msg):
2924
class ShelfCorrupt(BzrError):
2926
_fmt = "Shelf corrupt."
2929
class NoSuchShelfId(BzrError):
2931
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2933
def __init__(self, shelf_id):
2934
BzrError.__init__(self, shelf_id=shelf_id)
2937
class UserAbort(BzrError):
2939
_fmt = 'The user aborted the operation.'