532
460
class NotADirectory(PathError):
534
_fmt = '"%(path)s" is not a directory %(extra)s'
462
_fmt = "%(path)r is not a directory %(extra)s"
537
465
class NotInWorkingDirectory(PathError):
539
_fmt = '"%(path)s" is not in the working directory %(extra)s'
467
_fmt = "%(path)r is not in the working directory %(extra)s"
542
470
class DirectoryNotEmpty(PathError):
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):
472
_fmt = "Directory not empty: %(path)r%(extra)s"
475
class ReadingCompleted(BzrError):
554
477
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
555
478
"called upon it - the request has been completed and no more "
556
479
"data may be read.")
481
internal_error = True
558
483
def __init__(self, request):
559
484
self.request = request
562
487
class ResourceBusy(PathError):
564
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
489
_fmt = "Device or resource busy: %(path)r%(extra)s"
567
492
class PermissionDenied(PathError):
569
_fmt = 'Permission denied: "%(path)s"%(extra)s'
494
_fmt = "Permission denied: %(path)r%(extra)s"
572
497
class InvalidURL(PathError):
574
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
499
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
577
502
class InvalidURLJoin(PathError):
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)
504
_fmt = "Invalid URL join request: %(args)s%(extra)s"
506
def __init__(self, msg, base, args):
507
PathError.__init__(self, base, msg)
508
self.args = [base] + list(args)
610
511
class UnknownHook(BzrError):
2713
2309
def __init__(self, error):
2714
2310
self.error = error
2717
class NoMessageSupplied(BzrError):
2719
_fmt = "No message supplied."
2722
class NoMailAddressSpecified(BzrError):
2724
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2727
class UnknownMailClient(BzrError):
2729
_fmt = "Unknown mail client: %(mail_client)s"
2731
def __init__(self, mail_client):
2732
BzrError.__init__(self, mail_client=mail_client)
2735
class MailClientNotFound(BzrError):
2737
_fmt = "Unable to find mail client with the following names:"\
2738
" %(mail_command_list_string)s"
2740
def __init__(self, mail_command_list):
2741
mail_command_list_string = ', '.join(mail_command_list)
2742
BzrError.__init__(self, mail_command_list=mail_command_list,
2743
mail_command_list_string=mail_command_list_string)
2745
class SMTPConnectionRefused(SMTPError):
2747
_fmt = "SMTP connection to %(host)s refused"
2749
def __init__(self, error, host):
2754
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2756
_fmt = "Please specify smtp_server. No server at default %(host)s."
2759
class BzrDirError(BzrError):
2761
def __init__(self, bzrdir):
2762
import bzrlib.urlutils as urlutils
2763
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2765
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2768
class UnsyncedBranches(BzrDirError):
2770
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2771
" bzr help sync-for-reconfigure.")
2773
def __init__(self, bzrdir, target_branch):
2774
BzrDirError.__init__(self, bzrdir)
2775
import bzrlib.urlutils as urlutils
2776
self.target_url = urlutils.unescape_for_display(target_branch.base,
2780
class AlreadyBranch(BzrDirError):
2782
_fmt = "'%(display_url)s' is already a branch."
2785
class AlreadyTree(BzrDirError):
2787
_fmt = "'%(display_url)s' is already a tree."
2790
class AlreadyCheckout(BzrDirError):
2792
_fmt = "'%(display_url)s' is already a checkout."
2795
class AlreadyLightweightCheckout(BzrDirError):
2797
_fmt = "'%(display_url)s' is already a lightweight checkout."
2800
class AlreadyUsingShared(BzrDirError):
2802
_fmt = "'%(display_url)s' is already using a shared repository."
2805
class AlreadyStandalone(BzrDirError):
2807
_fmt = "'%(display_url)s' is already standalone."
2810
class AlreadyWithTrees(BzrDirError):
2812
_fmt = ("Shared repository '%(display_url)s' already creates "
2816
class AlreadyWithNoTrees(BzrDirError):
2818
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2822
class ReconfigurationNotSupported(BzrDirError):
2824
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2827
class NoBindLocation(BzrDirError):
2829
_fmt = "No location could be found to bind to at %(display_url)s."
2832
class UncommittedChanges(BzrError):
2834
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2835
' (See bzr status).%(more)s')
2837
def __init__(self, tree, more=None):
2842
import bzrlib.urlutils as urlutils
2843
display_url = urlutils.unescape_for_display(
2844
tree.user_url, 'ascii')
2845
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2848
class ShelvedChanges(UncommittedChanges):
2850
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2851
' (See bzr shelve --list).%(more)s')
2854
class MissingTemplateVariable(BzrError):
2856
_fmt = 'Variable {%(name)s} is not available.'
2858
def __init__(self, name):
2862
class NoTemplate(BzrError):
2864
_fmt = 'No template specified.'
2867
class UnableCreateSymlink(BzrError):
2869
_fmt = 'Unable to create symlink %(path_str)son this platform'
2871
def __init__(self, path=None):
2875
path_str = repr(str(path))
2876
except UnicodeEncodeError:
2877
path_str = repr(path)
2879
self.path_str = path_str
2882
class UnsupportedTimezoneFormat(BzrError):
2884
_fmt = ('Unsupported timezone format "%(timezone)s", '
2885
'options are "utc", "original", "local".')
2887
def __init__(self, timezone):
2888
self.timezone = timezone
2891
class CommandAvailableInPlugin(StandardError):
2893
internal_error = False
2895
def __init__(self, cmd_name, plugin_metadata, provider):
2897
self.plugin_metadata = plugin_metadata
2898
self.cmd_name = cmd_name
2899
self.provider = provider
2903
_fmt = ('"%s" is not a standard bzr command. \n'
2904
'However, the following official plugin provides this command: %s\n'
2905
'You can install it by going to: %s'
2906
% (self.cmd_name, self.plugin_metadata['name'],
2907
self.plugin_metadata['url']))
2912
class NoPluginAvailable(BzrError):
2916
class UnableEncodePath(BzrError):
2918
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2919
'user encoding %(user_encoding)s')
2921
def __init__(self, path, kind):
2922
from bzrlib.osutils import get_user_encoding
2925
self.user_encoding = osutils.get_user_encoding()
2928
class NoSuchAlias(BzrError):
2930
_fmt = ('The alias "%(alias_name)s" does not exist.')
2932
def __init__(self, alias_name):
2933
BzrError.__init__(self, alias_name=alias_name)
2936
class DirectoryLookupFailure(BzrError):
2937
"""Base type for lookup errors."""
2942
class InvalidLocationAlias(DirectoryLookupFailure):
2944
_fmt = '"%(alias_name)s" is not a valid location alias.'
2946
def __init__(self, alias_name):
2947
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2950
class UnsetLocationAlias(DirectoryLookupFailure):
2952
_fmt = 'No %(alias_name)s location assigned.'
2954
def __init__(self, alias_name):
2955
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2958
class CannotBindAddress(BzrError):
2960
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2962
def __init__(self, host, port, orig_error):
2963
# nb: in python2.4 socket.error doesn't have a useful repr
2964
BzrError.__init__(self, host=host, port=port,
2965
orig_error=repr(orig_error.args))
2968
class UnknownRules(BzrError):
2970
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2972
def __init__(self, unknowns):
2973
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2976
class HookFailed(BzrError):
2977
"""Raised when a pre_change_branch_tip hook function fails anything other
2978
than TipChangeRejected.
2980
Note that this exception is no longer raised, and the import is only left
2981
to be nice to code which might catch it in a plugin.
2984
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2985
"%(traceback_text)s%(exc_value)s")
2987
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
2989
symbol_versioning.warn("BzrError HookFailed has been deprecated "
2990
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
2992
self.hook_stage = hook_stage
2993
self.hook_name = hook_name
2994
self.exc_info = exc_info
2995
self.exc_type = exc_info[0]
2996
self.exc_value = exc_info[1]
2997
self.exc_tb = exc_info[2]
2998
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
3001
class TipChangeRejected(BzrError):
3002
"""A pre_change_branch_tip hook function may raise this to cleanly and
3003
explicitly abort a change to a branch tip.
3006
_fmt = u"Tip change rejected: %(msg)s"
3008
def __init__(self, msg):
3012
class ShelfCorrupt(BzrError):
3014
_fmt = "Shelf corrupt."
3017
class NoSuchShelfId(BzrError):
3019
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3021
def __init__(self, shelf_id):
3022
BzrError.__init__(self, shelf_id=shelf_id)
3025
class InvalidShelfId(BzrError):
3027
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3029
def __init__(self, invalid_id):
3030
BzrError.__init__(self, invalid_id=invalid_id)
3033
class JailBreak(BzrError):
3035
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3037
def __init__(self, url):
3038
BzrError.__init__(self, url=url)
3041
class UserAbort(BzrError):
3043
_fmt = 'The user aborted the operation.'
3046
class MustHaveWorkingTree(BzrError):
3048
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3050
def __init__(self, format, url):
3051
BzrError.__init__(self, format=format, url=url)
3054
class NoSuchView(BzrError):
3055
"""A view does not exist.
3058
_fmt = u"No such view: %(view_name)s."
3060
def __init__(self, view_name):
3061
self.view_name = view_name
3064
class ViewsNotSupported(BzrError):
3065
"""Views are not supported by a tree format.
3068
_fmt = ("Views are not supported by %(tree)s;"
3069
" use 'bzr upgrade' to change your tree to a later format.")
3071
def __init__(self, tree):
3075
class FileOutsideView(BzrError):
3077
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3080
def __init__(self, file_name, view_files):
3081
self.file_name = file_name
3082
self.view_str = ", ".join(view_files)
3085
class UnresumableWriteGroup(BzrError):
3087
_fmt = ("Repository %(repository)s cannot resume write group "
3088
"%(write_groups)r: %(reason)s")
3090
internal_error = True
3092
def __init__(self, repository, write_groups, reason):
3093
self.repository = repository
3094
self.write_groups = write_groups
3095
self.reason = reason
3098
class UnsuspendableWriteGroup(BzrError):
3100
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3102
internal_error = True
3104
def __init__(self, repository):
3105
self.repository = repository
3108
class LossyPushToSameVCS(BzrError):
3110
_fmt = ("Lossy push not possible between %(source_branch)r and "
3111
"%(target_branch)r that are in the same VCS.")
3113
internal_error = True
3115
def __init__(self, source_branch, target_branch):
3116
self.source_branch = source_branch
3117
self.target_branch = target_branch
3120
class NoRoundtrippingSupport(BzrError):
3122
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3123
"%(target_branch)r.")
3125
internal_error = True
3127
def __init__(self, source_branch, target_branch):
3128
self.source_branch = source_branch
3129
self.target_branch = target_branch
3132
class FileTimestampUnavailable(BzrError):
3134
_fmt = "The filestamp for %(path)s is not available."
3136
internal_error = True
3138
def __init__(self, path):
3142
class NoColocatedBranchSupport(BzrError):
3144
_fmt = ("%(bzrdir)r does not support co-located branches.")
3146
def __init__(self, bzrdir):
3147
self.bzrdir = bzrdir
3150
class NoWhoami(BzrError):
3152
_fmt = ('Unable to determine your name.\n'
3153
"Please, set your name with the 'whoami' command.\n"
3154
'E.g. bzr whoami "Your Name <name@example.com>"')
3157
class InvalidPattern(BzrError):
3159
_fmt = ('Invalid pattern(s) found. %(msg)s')
3161
def __init__(self, msg):
3165
class RecursiveBind(BzrError):
3167
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3168
'Please use `bzr unbind` to fix.')
3170
def __init__(self, branch_url):
3171
self.branch_url = branch_url