1430
class SHA1KnitCorrupt(KnitCorrupt):
1432
_fmt = ("Knit %(filename)s corrupt: sha-1 of reconstructed text does not "
1433
"match expected sha-1. key %(key)s expected sha %(expected)s actual "
1436
def __init__(self, filename, actual, expected, key, content):
1437
KnitError.__init__(self)
1438
self.filename = filename
1439
self.actual = actual
1440
self.expected = expected
1442
self.content = content
1445
class KnitDataStreamIncompatible(KnitError):
1446
# Not raised anymore, as we can convert data streams. In future we may
1447
# need it again for more exotic cases, so we're keeping it around for now.
1449
_fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
1451
def __init__(self, stream_format, target_format):
1452
self.stream_format = stream_format
1453
self.target_format = target_format
1456
class KnitDataStreamUnknown(KnitError):
1457
# Indicates a data stream we don't know how to handle.
1459
_fmt = "Cannot parse knit data stream of format \"%(stream_format)s\"."
1461
def __init__(self, stream_format):
1462
self.stream_format = stream_format
1465
class KnitHeaderError(KnitError):
1467
_fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
1469
def __init__(self, badline, filename):
1470
KnitError.__init__(self)
1471
self.badline = badline
1472
self.filename = filename
1474
class KnitIndexUnknownMethod(KnitError):
1475
"""Raised when we don't understand the storage method.
1477
Currently only 'fulltext' and 'line-delta' are supported.
1480
_fmt = ("Knit index %(filename)s does not have a known method"
1481
" in options: %(options)r")
1483
def __init__(self, filename, options):
1484
KnitError.__init__(self)
1485
self.filename = filename
1486
self.options = options
1489
class RetryWithNewPacks(BzrError):
1490
"""Raised when we realize that the packs on disk have changed.
1492
This is meant as more of a signaling exception, to trap between where a
1493
local error occurred and the code that can actually handle the error and
1494
code that can retry appropriately.
1497
internal_error = True
1499
_fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1502
def __init__(self, context, reload_occurred, exc_info):
1503
"""create a new RetryWithNewPacks error.
1505
:param reload_occurred: Set to True if we know that the packs have
1506
already been reloaded, and we are failing because of an in-memory
1507
cache miss. If set to True then we will ignore if a reload says
1508
nothing has changed, because we assume it has already reloaded. If
1509
False, then a reload with nothing changed will force an error.
1510
:param exc_info: The original exception traceback, so if there is a
1511
problem we can raise the original error (value from sys.exc_info())
1513
BzrError.__init__(self)
1514
self.reload_occurred = reload_occurred
1515
self.exc_info = exc_info
1516
self.orig_error = exc_info[1]
1517
# TODO: The global error handler should probably treat this by
1518
# raising/printing the original exception with a bit about
1519
# RetryWithNewPacks also not being caught
1522
class RetryAutopack(RetryWithNewPacks):
1523
"""Raised when we are autopacking and we find a missing file.
1525
Meant as a signaling exception, to tell the autopack code it should try
1529
internal_error = True
1531
_fmt = ("Pack files have changed, reload and try autopack again."
1532
" context: %(context)s %(orig_error)s")
1535
953
class NoSuchExportFormat(BzrError):
1537
955
_fmt = "Export format %(format)r not supported"
1539
957
def __init__(self, format):
2359
1564
self.extra = ''
2362
class InvalidImportLine(InternalBzrError):
1567
class InvalidImportLine(BzrError):
2364
1569
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
1571
internal_error = True
2366
1573
def __init__(self, text, msg):
2367
1574
BzrError.__init__(self)
2368
1575
self.text = text
2372
class ImportNameCollision(InternalBzrError):
2374
_fmt = ("Tried to import an object to the same name as"
2375
" an existing object. %(name)s")
2377
def __init__(self, name):
2378
BzrError.__init__(self)
2382
class NotAMergeDirective(BzrError):
2383
"""File starting with %(firstline)r is not a merge directive"""
2384
def __init__(self, firstline):
2385
BzrError.__init__(self, firstline=firstline)
2388
class NoMergeSource(BzrError):
2389
"""Raise if no merge source was specified for a merge directive"""
2391
_fmt = "A merge directive must provide either a bundle or a public"\
2395
class IllegalMergeDirectivePayload(BzrError):
2396
"""A merge directive contained something other than a patch or bundle"""
2398
_fmt = "Bad merge directive payload %(start)r"
2400
def __init__(self, start):
2405
class PatchVerificationFailed(BzrError):
2406
"""A patch from a merge directive could not be verified"""
2408
_fmt = "Preview patch does not match requested changes."
2411
class PatchMissing(BzrError):
2412
"""Raise a patch type was specified but no patch supplied"""
2414
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2416
def __init__(self, patch_type):
2417
BzrError.__init__(self)
2418
self.patch_type = patch_type
2421
class TargetNotBranch(BzrError):
2422
"""A merge directive's target branch is required, but isn't a branch"""
2424
_fmt = ("Your branch does not have all of the revisions required in "
2425
"order to merge this merge directive and the target "
2426
"location specified in the merge directive is not a branch: "
2429
def __init__(self, location):
2430
BzrError.__init__(self)
2431
self.location = location
2434
class UnsupportedInventoryKind(BzrError):
2436
_fmt = """Unsupported entry kind %(kind)s"""
2438
def __init__(self, kind):
2442
class BadSubsumeSource(BzrError):
2444
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2446
def __init__(self, tree, other_tree, reason):
2448
self.other_tree = other_tree
2449
self.reason = reason
2452
class SubsumeTargetNeedsUpgrade(BzrError):
2454
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2456
def __init__(self, other_tree):
2457
self.other_tree = other_tree
2460
class BadReferenceTarget(InternalBzrError):
2462
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2465
def __init__(self, tree, other_tree, reason):
2467
self.other_tree = other_tree
2468
self.reason = reason
2471
class NoSuchTag(BzrError):
2473
_fmt = "No such tag: %(tag_name)s"
2475
def __init__(self, tag_name):
2476
self.tag_name = tag_name
2479
class TagsNotSupported(BzrError):
2481
_fmt = ("Tags not supported by %(branch)s;"
2482
" you may be able to use bzr upgrade.")
2484
def __init__(self, branch):
2485
self.branch = branch
2488
class TagAlreadyExists(BzrError):
2490
_fmt = "Tag %(tag_name)s already exists."
2492
def __init__(self, tag_name):
2493
self.tag_name = tag_name
2496
class MalformedBugIdentifier(BzrError):
2498
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2499
'See "bzr help bugs" for more information on this feature.')
2501
def __init__(self, bug_id, reason):
2502
self.bug_id = bug_id
2503
self.reason = reason
2506
class InvalidBugTrackerURL(BzrError):
2508
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2509
"contain {id}: %(url)s")
2511
def __init__(self, abbreviation, url):
2512
self.abbreviation = abbreviation
2516
class UnknownBugTrackerAbbreviation(BzrError):
2518
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2521
def __init__(self, abbreviation, branch):
2522
self.abbreviation = abbreviation
2523
self.branch = branch
2526
class InvalidLineInBugsProperty(BzrError):
2528
_fmt = ("Invalid line in bugs property: '%(line)s'")
2530
def __init__(self, line):
2534
class InvalidBugStatus(BzrError):
2536
_fmt = ("Invalid bug status: '%(status)s'")
2538
def __init__(self, status):
2539
self.status = status
2542
class UnexpectedSmartServerResponse(BzrError):
2544
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2546
def __init__(self, response_tuple):
2547
self.response_tuple = response_tuple
2550
class ErrorFromSmartServer(BzrError):
2551
"""An error was received from a smart server.
2553
:seealso: UnknownErrorFromSmartServer
2556
_fmt = "Error received from smart server: %(error_tuple)r"
2558
internal_error = True
2560
def __init__(self, error_tuple):
2561
self.error_tuple = error_tuple
2563
self.error_verb = error_tuple[0]
2565
self.error_verb = None
2566
self.error_args = error_tuple[1:]
2569
class UnknownErrorFromSmartServer(BzrError):
2570
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2573
This is distinct from ErrorFromSmartServer so that it is possible to
2574
distinguish between the following two cases:
2575
- ErrorFromSmartServer was uncaught. This is logic error in the client
2576
and so should provoke a traceback to the user.
2577
- ErrorFromSmartServer was caught but its error_tuple could not be
2578
translated. This is probably because the server sent us garbage, and
2579
should not provoke a traceback.
2582
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2584
internal_error = False
2586
def __init__(self, error_from_smart_server):
2589
:param error_from_smart_server: An ErrorFromSmartServer instance.
2591
self.error_from_smart_server = error_from_smart_server
2592
self.error_tuple = error_from_smart_server.error_tuple
2595
class ContainerError(BzrError):
2596
"""Base class of container errors."""
2599
class UnknownContainerFormatError(ContainerError):
2601
_fmt = "Unrecognised container format: %(container_format)r"
2603
def __init__(self, container_format):
2604
self.container_format = container_format
2607
class UnexpectedEndOfContainerError(ContainerError):
2609
_fmt = "Unexpected end of container stream"
2612
class UnknownRecordTypeError(ContainerError):
2614
_fmt = "Unknown record type: %(record_type)r"
2616
def __init__(self, record_type):
2617
self.record_type = record_type
2620
class InvalidRecordError(ContainerError):
2622
_fmt = "Invalid record: %(reason)s"
2624
def __init__(self, reason):
2625
self.reason = reason
2628
class ContainerHasExcessDataError(ContainerError):
2630
_fmt = "Container has data after end marker: %(excess)r"
2632
def __init__(self, excess):
2633
self.excess = excess
2636
class DuplicateRecordNameError(ContainerError):
2638
_fmt = "Container has multiple records with the same name: %(name)s"
2640
def __init__(self, name):
2644
class NoDestinationAddress(InternalBzrError):
2646
_fmt = "Message does not have a destination address."
2649
class RepositoryDataStreamError(BzrError):
2651
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2653
def __init__(self, reason):
2654
self.reason = reason
2657
class SMTPError(BzrError):
2659
_fmt = "SMTP error: %(error)s"
2661
def __init__(self, error):
2665
class NoMessageSupplied(BzrError):
2667
_fmt = "No message supplied."
2670
class NoMailAddressSpecified(BzrError):
2672
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2675
class UnknownMailClient(BzrError):
2677
_fmt = "Unknown mail client: %(mail_client)s"
2679
def __init__(self, mail_client):
2680
BzrError.__init__(self, mail_client=mail_client)
2683
class MailClientNotFound(BzrError):
2685
_fmt = "Unable to find mail client with the following names:"\
2686
" %(mail_command_list_string)s"
2688
def __init__(self, mail_command_list):
2689
mail_command_list_string = ', '.join(mail_command_list)
2690
BzrError.__init__(self, mail_command_list=mail_command_list,
2691
mail_command_list_string=mail_command_list_string)
2693
class SMTPConnectionRefused(SMTPError):
2695
_fmt = "SMTP connection to %(host)s refused"
2697
def __init__(self, error, host):
2702
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2704
_fmt = "Please specify smtp_server. No server at default %(host)s."
2707
class BzrDirError(BzrError):
2709
def __init__(self, bzrdir):
2710
import bzrlib.urlutils as urlutils
2711
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2713
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2716
class UnsyncedBranches(BzrDirError):
2718
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2719
" bzr help sync-for-reconfigure.")
2721
def __init__(self, bzrdir, target_branch):
2722
BzrDirError.__init__(self, bzrdir)
2723
import bzrlib.urlutils as urlutils
2724
self.target_url = urlutils.unescape_for_display(target_branch.base,
2728
class AlreadyBranch(BzrDirError):
2730
_fmt = "'%(display_url)s' is already a branch."
2733
class AlreadyTree(BzrDirError):
2735
_fmt = "'%(display_url)s' is already a tree."
2738
class AlreadyCheckout(BzrDirError):
2740
_fmt = "'%(display_url)s' is already a checkout."
2743
class AlreadyLightweightCheckout(BzrDirError):
2745
_fmt = "'%(display_url)s' is already a lightweight checkout."
2748
class AlreadyUsingShared(BzrDirError):
2750
_fmt = "'%(display_url)s' is already using a shared repository."
2753
class AlreadyStandalone(BzrDirError):
2755
_fmt = "'%(display_url)s' is already standalone."
2758
class AlreadyWithTrees(BzrDirError):
2760
_fmt = ("Shared repository '%(display_url)s' already creates "
2764
class AlreadyWithNoTrees(BzrDirError):
2766
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2770
class ReconfigurationNotSupported(BzrDirError):
2772
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2775
class NoBindLocation(BzrDirError):
2777
_fmt = "No location could be found to bind to at %(display_url)s."
2780
class UncommittedChanges(BzrError):
2782
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2784
def __init__(self, tree):
2785
import bzrlib.urlutils as urlutils
2786
display_url = urlutils.unescape_for_display(
2787
tree.bzrdir.root_transport.base, 'ascii')
2788
BzrError.__init__(self, tree=tree, display_url=display_url)
2791
class MissingTemplateVariable(BzrError):
2793
_fmt = 'Variable {%(name)s} is not available.'
2795
def __init__(self, name):
2799
class NoTemplate(BzrError):
2801
_fmt = 'No template specified.'
2804
class UnableCreateSymlink(BzrError):
2806
_fmt = 'Unable to create symlink %(path_str)son this platform'
2808
def __init__(self, path=None):
2812
path_str = repr(str(path))
2813
except UnicodeEncodeError:
2814
path_str = repr(path)
2816
self.path_str = path_str
2819
class UnsupportedTimezoneFormat(BzrError):
2821
_fmt = ('Unsupported timezone format "%(timezone)s", '
2822
'options are "utc", "original", "local".')
2824
def __init__(self, timezone):
2825
self.timezone = timezone
2828
class CommandAvailableInPlugin(StandardError):
2830
internal_error = False
2832
def __init__(self, cmd_name, plugin_metadata, provider):
2834
self.plugin_metadata = plugin_metadata
2835
self.cmd_name = cmd_name
2836
self.provider = provider
2840
_fmt = ('"%s" is not a standard bzr command. \n'
2841
'However, the following official plugin provides this command: %s\n'
2842
'You can install it by going to: %s'
2843
% (self.cmd_name, self.plugin_metadata['name'],
2844
self.plugin_metadata['url']))
2849
class NoPluginAvailable(BzrError):
2853
class UnableEncodePath(BzrError):
2855
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2856
'user encoding %(user_encoding)s')
2858
def __init__(self, path, kind):
2859
from bzrlib.osutils import get_user_encoding
2862
self.user_encoding = osutils.get_user_encoding()
2865
class NoSuchAlias(BzrError):
2867
_fmt = ('The alias "%(alias_name)s" does not exist.')
2869
def __init__(self, alias_name):
2870
BzrError.__init__(self, alias_name=alias_name)
2873
class DirectoryLookupFailure(BzrError):
2874
"""Base type for lookup errors."""
2879
class InvalidLocationAlias(DirectoryLookupFailure):
2881
_fmt = '"%(alias_name)s" is not a valid location alias.'
2883
def __init__(self, alias_name):
2884
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2887
class UnsetLocationAlias(DirectoryLookupFailure):
2889
_fmt = 'No %(alias_name)s location assigned.'
2891
def __init__(self, alias_name):
2892
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2895
class CannotBindAddress(BzrError):
2897
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2899
def __init__(self, host, port, orig_error):
2900
BzrError.__init__(self, host=host, port=port,
2901
orig_error=orig_error[1])
2904
class UnknownRules(BzrError):
2906
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2908
def __init__(self, unknowns):
2909
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2912
class HookFailed(BzrError):
2913
"""Raised when a pre_change_branch_tip hook function fails anything other
2914
than TipChangeRejected.
2917
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2918
"%(traceback_text)s%(exc_value)s")
2920
def __init__(self, hook_stage, hook_name, exc_info):
2922
self.hook_stage = hook_stage
2923
self.hook_name = hook_name
2924
self.exc_info = exc_info
2925
self.exc_type = exc_info[0]
2926
self.exc_value = exc_info[1]
2927
self.exc_tb = exc_info[2]
2928
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2931
class TipChangeRejected(BzrError):
2932
"""A pre_change_branch_tip hook function may raise this to cleanly and
2933
explicitly abort a change to a branch tip.
2936
_fmt = u"Tip change rejected: %(msg)s"
2938
def __init__(self, msg):
2942
class ShelfCorrupt(BzrError):
2944
_fmt = "Shelf corrupt."
2947
class NoSuchShelfId(BzrError):
2949
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2951
def __init__(self, shelf_id):
2952
BzrError.__init__(self, shelf_id=shelf_id)
2955
class InvalidShelfId(BzrError):
2957
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2959
def __init__(self, invalid_id):
2960
BzrError.__init__(self, invalid_id=invalid_id)
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
1579
class ImportNameCollision(BzrError):
1581
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
1583
internal_error = True
1585
def __init__(self, name):
1586
BzrError.__init__(self)