395
532
class NotADirectory(PathError):
397
_fmt = "%(path)r is not a directory %(extra)s"
534
_fmt = '"%(path)s" is not a directory %(extra)s'
400
537
class NotInWorkingDirectory(PathError):
402
_fmt = "%(path)r is not in the working directory %(extra)s"
539
_fmt = '"%(path)s" is not in the working directory %(extra)s'
405
542
class DirectoryNotEmpty(PathError):
407
_fmt = "Directory not empty: %(path)r%(extra)s"
410
class ReadingCompleted(BzrError):
544
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
547
class HardLinkNotSupported(PathError):
549
_fmt = 'Hard-linking "%(path)s" is not supported'
552
class ReadingCompleted(InternalBzrError):
412
554
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
413
555
"called upon it - the request has been completed and no more "
414
556
"data may be read.")
416
internal_error = True
418
558
def __init__(self, request):
419
559
self.request = request
422
562
class ResourceBusy(PathError):
424
_fmt = "Device or resource busy: %(path)r%(extra)s"
564
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
427
567
class PermissionDenied(PathError):
429
_fmt = "Permission denied: %(path)r%(extra)s"
569
_fmt = 'Permission denied: "%(path)s"%(extra)s'
432
572
class InvalidURL(PathError):
434
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
574
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
437
577
class InvalidURLJoin(PathError):
439
_fmt = "Invalid URL join request: %(args)s%(extra)s"
441
def __init__(self, msg, base, args):
442
PathError.__init__(self, base, msg)
443
self.args = [base] + list(args)
579
_fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r"
581
def __init__(self, reason, base, join_args):
584
self.join_args = join_args
585
PathError.__init__(self, base, reason)
588
class InvalidRebaseURLs(PathError):
590
_fmt = "URLs differ by more than path: %(from_)r and %(to)r"
592
def __init__(self, from_, to):
595
PathError.__init__(self, from_, 'URLs differ by more than path.')
598
class UnavailableRepresentation(InternalBzrError):
600
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
601
"is encoded as '%(native)s'.")
603
def __init__(self, key, wanted, native):
604
InternalBzrError.__init__(self)
446
610
class UnknownHook(BzrError):
2159
2507
self.response_tuple = response_tuple
2510
class ErrorFromSmartServer(BzrError):
2511
"""An error was received from a smart server.
2513
:seealso: UnknownErrorFromSmartServer
2516
_fmt = "Error received from smart server: %(error_tuple)r"
2518
internal_error = True
2520
def __init__(self, error_tuple):
2521
self.error_tuple = error_tuple
2523
self.error_verb = error_tuple[0]
2525
self.error_verb = None
2526
self.error_args = error_tuple[1:]
2529
class UnknownErrorFromSmartServer(BzrError):
2530
"""An ErrorFromSmartServer could not be translated into a typical bzrlib
2533
This is distinct from ErrorFromSmartServer so that it is possible to
2534
distinguish between the following two cases:
2535
- ErrorFromSmartServer was uncaught. This is logic error in the client
2536
and so should provoke a traceback to the user.
2537
- ErrorFromSmartServer was caught but its error_tuple could not be
2538
translated. This is probably because the server sent us garbage, and
2539
should not provoke a traceback.
2542
_fmt = "Server sent an unexpected error: %(error_tuple)r"
2544
internal_error = False
2546
def __init__(self, error_from_smart_server):
2549
:param error_from_smart_server: An ErrorFromSmartServer instance.
2551
self.error_from_smart_server = error_from_smart_server
2552
self.error_tuple = error_from_smart_server.error_tuple
2162
2555
class ContainerError(BzrError):
2163
2556
"""Base class of container errors."""
2224
2621
def __init__(self, error):
2225
2622
self.error = error
2625
class NoMessageSupplied(BzrError):
2627
_fmt = "No message supplied."
2630
class NoMailAddressSpecified(BzrError):
2632
_fmt = "No mail-to address specified."
2635
class UnknownMailClient(BzrError):
2637
_fmt = "Unknown mail client: %(mail_client)s"
2639
def __init__(self, mail_client):
2640
BzrError.__init__(self, mail_client=mail_client)
2643
class MailClientNotFound(BzrError):
2645
_fmt = "Unable to find mail client with the following names:"\
2646
" %(mail_command_list_string)s"
2648
def __init__(self, mail_command_list):
2649
mail_command_list_string = ', '.join(mail_command_list)
2650
BzrError.__init__(self, mail_command_list=mail_command_list,
2651
mail_command_list_string=mail_command_list_string)
2653
class SMTPConnectionRefused(SMTPError):
2655
_fmt = "SMTP connection to %(host)s refused"
2657
def __init__(self, error, host):
2662
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2664
_fmt = "Please specify smtp_server. No server at default %(host)s."
2667
class BzrDirError(BzrError):
2669
def __init__(self, bzrdir):
2670
import bzrlib.urlutils as urlutils
2671
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2673
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2676
class UnsyncedBranches(BzrDirError):
2678
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2679
" bzr help sync-for-reconfigure.")
2681
def __init__(self, bzrdir, target_branch):
2682
BzrDirError.__init__(self, bzrdir)
2683
import bzrlib.urlutils as urlutils
2684
self.target_url = urlutils.unescape_for_display(target_branch.base,
2688
class AlreadyBranch(BzrDirError):
2690
_fmt = "'%(display_url)s' is already a branch."
2693
class AlreadyTree(BzrDirError):
2695
_fmt = "'%(display_url)s' is already a tree."
2698
class AlreadyCheckout(BzrDirError):
2700
_fmt = "'%(display_url)s' is already a checkout."
2703
class AlreadyLightweightCheckout(BzrDirError):
2705
_fmt = "'%(display_url)s' is already a lightweight checkout."
2708
class AlreadyUsingShared(BzrDirError):
2710
_fmt = "'%(display_url)s' is already using a shared repository."
2713
class AlreadyStandalone(BzrDirError):
2715
_fmt = "'%(display_url)s' is already standalone."
2718
class ReconfigurationNotSupported(BzrDirError):
2720
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2723
class NoBindLocation(BzrDirError):
2725
_fmt = "No location could be found to bind to at %(display_url)s."
2728
class UncommittedChanges(BzrError):
2730
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2732
def __init__(self, tree):
2733
import bzrlib.urlutils as urlutils
2734
display_url = urlutils.unescape_for_display(
2735
tree.bzrdir.root_transport.base, 'ascii')
2736
BzrError.__init__(self, tree=tree, display_url=display_url)
2739
class MissingTemplateVariable(BzrError):
2741
_fmt = 'Variable {%(name)s} is not available.'
2743
def __init__(self, name):
2747
class NoTemplate(BzrError):
2749
_fmt = 'No template specified.'
2752
class UnableCreateSymlink(BzrError):
2754
_fmt = 'Unable to create symlink %(path_str)son this platform'
2756
def __init__(self, path=None):
2760
path_str = repr(str(path))
2761
except UnicodeEncodeError:
2762
path_str = repr(path)
2764
self.path_str = path_str
2767
class UnsupportedTimezoneFormat(BzrError):
2769
_fmt = ('Unsupported timezone format "%(timezone)s", '
2770
'options are "utc", "original", "local".')
2772
def __init__(self, timezone):
2773
self.timezone = timezone
2776
class CommandAvailableInPlugin(StandardError):
2778
internal_error = False
2780
def __init__(self, cmd_name, plugin_metadata, provider):
2782
self.plugin_metadata = plugin_metadata
2783
self.cmd_name = cmd_name
2784
self.provider = provider
2788
_fmt = ('"%s" is not a standard bzr command. \n'
2789
'However, the following official plugin provides this command: %s\n'
2790
'You can install it by going to: %s'
2791
% (self.cmd_name, self.plugin_metadata['name'],
2792
self.plugin_metadata['url']))
2797
class NoPluginAvailable(BzrError):
2801
class NotATerminal(BzrError):
2803
_fmt = 'Unable to ask for a password without real terminal.'
2806
class UnableEncodePath(BzrError):
2808
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2809
'user encoding %(user_encoding)s')
2811
def __init__(self, path, kind):
2814
self.user_encoding = osutils.get_user_encoding()
2817
class NoSuchAlias(BzrError):
2819
_fmt = ('The alias "%(alias_name)s" does not exist.')
2821
def __init__(self, alias_name):
2822
BzrError.__init__(self, alias_name=alias_name)
2825
class DirectoryLookupFailure(BzrError):
2826
"""Base type for lookup errors."""
2831
class InvalidLocationAlias(DirectoryLookupFailure):
2833
_fmt = '"%(alias_name)s" is not a valid location alias.'
2835
def __init__(self, alias_name):
2836
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2839
class UnsetLocationAlias(DirectoryLookupFailure):
2841
_fmt = 'No %(alias_name)s location assigned.'
2843
def __init__(self, alias_name):
2844
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2847
class CannotBindAddress(BzrError):
2849
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2851
def __init__(self, host, port, orig_error):
2852
BzrError.__init__(self, host=host, port=port,
2853
orig_error=orig_error[1])
2856
class UnknownRules(BzrError):
2858
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2860
def __init__(self, unknowns):
2861
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2864
class HookFailed(BzrError):
2865
"""Raised when a pre_change_branch_tip hook function fails anything other
2866
than TipChangeRejected.
2869
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2870
"%(traceback_text)s%(exc_value)s")
2872
def __init__(self, hook_stage, hook_name, exc_info):
2874
self.hook_stage = hook_stage
2875
self.hook_name = hook_name
2876
self.exc_info = exc_info
2877
self.exc_type = exc_info[0]
2878
self.exc_value = exc_info[1]
2879
self.exc_tb = exc_info[2]
2880
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2883
class TipChangeRejected(BzrError):
2884
"""A pre_change_branch_tip hook function may raise this to cleanly and
2885
explicitly abort a change to a branch tip.
2888
_fmt = u"Tip change rejected: %(msg)s"
2890
def __init__(self, msg):