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):
1372
1713
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1374
def __init__(self, source, target, is_permament=False, qual_proto=None):
1715
def __init__(self, source, target, is_permanent=False):
1375
1716
self.source = source
1376
1717
self.target = target
1378
1719
self.permanently = ' permanently'
1380
1721
self.permanently = ''
1381
self.is_permament = is_permament
1382
self._qualified_proto = qual_proto
1383
1722
TransportError.__init__(self)
1385
def _requalify_url(self, url):
1386
"""Restore the qualified proto in front of the url"""
1387
# When this exception is raised, source and target are in
1388
# user readable format. But some transports may use a
1389
# different proto (http+urllib:// will present http:// to
1390
# the user. If a qualified proto is specified, the code
1391
# trapping the exception can get the qualified urls to
1392
# properly handle the redirection themself (creating a
1393
# new transport object from the target url for example).
1394
# But checking that the scheme of the original and
1395
# redirected urls are the same can be tricky. (see the
1396
# FIXME in BzrDir.open_from_transport for the unique use
1398
if self._qualified_proto is None:
1401
# The TODO related to NotBranchError mention that doing
1402
# that kind of manipulation on the urls may not be the
1403
# exception object job. On the other hand, this object is
1404
# the interface between the code and the user so
1405
# presenting the urls in different ways is indeed its
1408
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1409
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1412
def get_source_url(self):
1413
return self._requalify_url(self.source)
1415
def get_target_url(self):
1416
return self._requalify_url(self.target)
1419
1725
class TooManyRedirections(TransportError):
1421
1727
_fmt = "Too many redirections"
1423
1730
class ConflictsInTree(BzrError):
1425
1732
_fmt = "Working tree has conflicts."
2224
2706
def __init__(self, error):
2225
2707
self.error = error
2710
class NoMessageSupplied(BzrError):
2712
_fmt = "No message supplied."
2715
class NoMailAddressSpecified(BzrError):
2717
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2720
class UnknownMailClient(BzrError):
2722
_fmt = "Unknown mail client: %(mail_client)s"
2724
def __init__(self, mail_client):
2725
BzrError.__init__(self, mail_client=mail_client)
2728
class MailClientNotFound(BzrError):
2730
_fmt = "Unable to find mail client with the following names:"\
2731
" %(mail_command_list_string)s"
2733
def __init__(self, mail_command_list):
2734
mail_command_list_string = ', '.join(mail_command_list)
2735
BzrError.__init__(self, mail_command_list=mail_command_list,
2736
mail_command_list_string=mail_command_list_string)
2738
class SMTPConnectionRefused(SMTPError):
2740
_fmt = "SMTP connection to %(host)s refused"
2742
def __init__(self, error, host):
2747
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2749
_fmt = "Please specify smtp_server. No server at default %(host)s."
2752
class BzrDirError(BzrError):
2754
def __init__(self, bzrdir):
2755
import bzrlib.urlutils as urlutils
2756
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2758
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2761
class UnsyncedBranches(BzrDirError):
2763
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2764
" bzr help sync-for-reconfigure.")
2766
def __init__(self, bzrdir, target_branch):
2767
BzrDirError.__init__(self, bzrdir)
2768
import bzrlib.urlutils as urlutils
2769
self.target_url = urlutils.unescape_for_display(target_branch.base,
2773
class AlreadyBranch(BzrDirError):
2775
_fmt = "'%(display_url)s' is already a branch."
2778
class AlreadyTree(BzrDirError):
2780
_fmt = "'%(display_url)s' is already a tree."
2783
class AlreadyCheckout(BzrDirError):
2785
_fmt = "'%(display_url)s' is already a checkout."
2788
class AlreadyLightweightCheckout(BzrDirError):
2790
_fmt = "'%(display_url)s' is already a lightweight checkout."
2793
class AlreadyUsingShared(BzrDirError):
2795
_fmt = "'%(display_url)s' is already using a shared repository."
2798
class AlreadyStandalone(BzrDirError):
2800
_fmt = "'%(display_url)s' is already standalone."
2803
class AlreadyWithTrees(BzrDirError):
2805
_fmt = ("Shared repository '%(display_url)s' already creates "
2809
class AlreadyWithNoTrees(BzrDirError):
2811
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2815
class ReconfigurationNotSupported(BzrDirError):
2817
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2820
class NoBindLocation(BzrDirError):
2822
_fmt = "No location could be found to bind to at %(display_url)s."
2825
class UncommittedChanges(BzrError):
2827
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2828
' (See bzr status).%(more)s')
2830
def __init__(self, tree, more=None):
2835
import bzrlib.urlutils as urlutils
2836
display_url = urlutils.unescape_for_display(
2837
tree.bzrdir.root_transport.base, 'ascii')
2838
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2841
class MissingTemplateVariable(BzrError):
2843
_fmt = 'Variable {%(name)s} is not available.'
2845
def __init__(self, name):
2849
class NoTemplate(BzrError):
2851
_fmt = 'No template specified.'
2854
class UnableCreateSymlink(BzrError):
2856
_fmt = 'Unable to create symlink %(path_str)son this platform'
2858
def __init__(self, path=None):
2862
path_str = repr(str(path))
2863
except UnicodeEncodeError:
2864
path_str = repr(path)
2866
self.path_str = path_str
2869
class UnsupportedTimezoneFormat(BzrError):
2871
_fmt = ('Unsupported timezone format "%(timezone)s", '
2872
'options are "utc", "original", "local".')
2874
def __init__(self, timezone):
2875
self.timezone = timezone
2878
class CommandAvailableInPlugin(StandardError):
2880
internal_error = False
2882
def __init__(self, cmd_name, plugin_metadata, provider):
2884
self.plugin_metadata = plugin_metadata
2885
self.cmd_name = cmd_name
2886
self.provider = provider
2890
_fmt = ('"%s" is not a standard bzr command. \n'
2891
'However, the following official plugin provides this command: %s\n'
2892
'You can install it by going to: %s'
2893
% (self.cmd_name, self.plugin_metadata['name'],
2894
self.plugin_metadata['url']))
2899
class NoPluginAvailable(BzrError):
2903
class UnableEncodePath(BzrError):
2905
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2906
'user encoding %(user_encoding)s')
2908
def __init__(self, path, kind):
2909
from bzrlib.osutils import get_user_encoding
2912
self.user_encoding = osutils.get_user_encoding()
2915
class NoSuchAlias(BzrError):
2917
_fmt = ('The alias "%(alias_name)s" does not exist.')
2919
def __init__(self, alias_name):
2920
BzrError.__init__(self, alias_name=alias_name)
2923
class DirectoryLookupFailure(BzrError):
2924
"""Base type for lookup errors."""
2929
class InvalidLocationAlias(DirectoryLookupFailure):
2931
_fmt = '"%(alias_name)s" is not a valid location alias.'
2933
def __init__(self, alias_name):
2934
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2937
class UnsetLocationAlias(DirectoryLookupFailure):
2939
_fmt = 'No %(alias_name)s location assigned.'
2941
def __init__(self, alias_name):
2942
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2945
class CannotBindAddress(BzrError):
2947
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2949
def __init__(self, host, port, orig_error):
2950
# nb: in python2.4 socket.error doesn't have a useful repr
2951
BzrError.__init__(self, host=host, port=port,
2952
orig_error=repr(orig_error.args))
2955
class UnknownRules(BzrError):
2957
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2959
def __init__(self, unknowns):
2960
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2963
class HookFailed(BzrError):
2964
"""Raised when a pre_change_branch_tip hook function fails anything other
2965
than TipChangeRejected.
2967
Note that this exception is no longer raised, and the import is only left
2968
to be nice to code which might catch it in a plugin.
2971
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2972
"%(traceback_text)s%(exc_value)s")
2974
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
2976
symbol_versioning.warn("BzrError HookFailed has been deprecated "
2977
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
2979
self.hook_stage = hook_stage
2980
self.hook_name = hook_name
2981
self.exc_info = exc_info
2982
self.exc_type = exc_info[0]
2983
self.exc_value = exc_info[1]
2984
self.exc_tb = exc_info[2]
2985
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2988
class TipChangeRejected(BzrError):
2989
"""A pre_change_branch_tip hook function may raise this to cleanly and
2990
explicitly abort a change to a branch tip.
2993
_fmt = u"Tip change rejected: %(msg)s"
2995
def __init__(self, msg):
2999
class ShelfCorrupt(BzrError):
3001
_fmt = "Shelf corrupt."
3004
class NoSuchShelfId(BzrError):
3006
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3008
def __init__(self, shelf_id):
3009
BzrError.__init__(self, shelf_id=shelf_id)
3012
class InvalidShelfId(BzrError):
3014
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3016
def __init__(self, invalid_id):
3017
BzrError.__init__(self, invalid_id=invalid_id)
3020
class JailBreak(BzrError):
3022
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3024
def __init__(self, url):
3025
BzrError.__init__(self, url=url)
3028
class UserAbort(BzrError):
3030
_fmt = 'The user aborted the operation.'
3033
class MustHaveWorkingTree(BzrError):
3035
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3037
def __init__(self, format, url):
3038
BzrError.__init__(self, format=format, url=url)
3041
class NoSuchView(BzrError):
3042
"""A view does not exist.
3045
_fmt = u"No such view: %(view_name)s."
3047
def __init__(self, view_name):
3048
self.view_name = view_name
3051
class ViewsNotSupported(BzrError):
3052
"""Views are not supported by a tree format.
3055
_fmt = ("Views are not supported by %(tree)s;"
3056
" use 'bzr upgrade' to change your tree to a later format.")
3058
def __init__(self, tree):
3062
class FileOutsideView(BzrError):
3064
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3067
def __init__(self, file_name, view_files):
3068
self.file_name = file_name
3069
self.view_str = ", ".join(view_files)
3072
class UnresumableWriteGroup(BzrError):
3074
_fmt = ("Repository %(repository)s cannot resume write group "
3075
"%(write_groups)r: %(reason)s")
3077
internal_error = True
3079
def __init__(self, repository, write_groups, reason):
3080
self.repository = repository
3081
self.write_groups = write_groups
3082
self.reason = reason
3085
class UnsuspendableWriteGroup(BzrError):
3087
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3089
internal_error = True
3091
def __init__(self, repository):
3092
self.repository = repository
3095
class LossyPushToSameVCS(BzrError):
3097
_fmt = ("Lossy push not possible between %(source_branch)r and "
3098
"%(target_branch)r that are in the same VCS.")
3100
internal_error = True
3102
def __init__(self, source_branch, target_branch):
3103
self.source_branch = source_branch
3104
self.target_branch = target_branch
3107
class NoRoundtrippingSupport(BzrError):
3109
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
3110
"%(target_branch)r.")
3112
internal_error = True
3114
def __init__(self, source_branch, target_branch):
3115
self.source_branch = source_branch
3116
self.target_branch = target_branch
3119
class FileTimestampUnavailable(BzrError):
3121
_fmt = "The filestamp for %(path)s is not available."
3123
internal_error = True
3125
def __init__(self, path):