404
532
class NotADirectory(PathError):
406
_fmt = "%(path)r is not a directory %(extra)s"
534
_fmt = '"%(path)s" is not a directory %(extra)s'
409
537
class NotInWorkingDirectory(PathError):
411
_fmt = "%(path)r is not in the working directory %(extra)s"
539
_fmt = '"%(path)s" is not in the working directory %(extra)s'
414
542
class DirectoryNotEmpty(PathError):
416
_fmt = "Directory not empty: %(path)r%(extra)s"
419
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):
421
554
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
422
555
"called upon it - the request has been completed and no more "
423
556
"data may be read.")
425
internal_error = True
427
558
def __init__(self, request):
428
559
self.request = request
431
562
class ResourceBusy(PathError):
433
_fmt = "Device or resource busy: %(path)r%(extra)s"
564
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
436
567
class PermissionDenied(PathError):
438
_fmt = "Permission denied: %(path)r%(extra)s"
569
_fmt = 'Permission denied: "%(path)s"%(extra)s'
441
572
class InvalidURL(PathError):
443
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
574
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
446
577
class InvalidURLJoin(PathError):
448
_fmt = "Invalid URL join request: %(args)s%(extra)s"
450
def __init__(self, msg, base, args):
451
PathError.__init__(self, base, msg)
452
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)
455
610
class UnknownHook(BzrError):
1381
1692
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1383
def __init__(self, source, target, is_permament=False, qual_proto=None):
1694
def __init__(self, source, target, is_permanent=False):
1384
1695
self.source = source
1385
1696
self.target = target
1387
1698
self.permanently = ' permanently'
1389
1700
self.permanently = ''
1390
self.is_permament = is_permament
1391
self._qualified_proto = qual_proto
1392
1701
TransportError.__init__(self)
1394
def _requalify_url(self, url):
1395
"""Restore the qualified proto in front of the url"""
1396
# When this exception is raised, source and target are in
1397
# user readable format. But some transports may use a
1398
# different proto (http+urllib:// will present http:// to
1399
# the user. If a qualified proto is specified, the code
1400
# trapping the exception can get the qualified urls to
1401
# properly handle the redirection themself (creating a
1402
# new transport object from the target url for example).
1403
# But checking that the scheme of the original and
1404
# redirected urls are the same can be tricky. (see the
1405
# FIXME in BzrDir.open_from_transport for the unique use
1407
if self._qualified_proto is None:
1410
# The TODO related to NotBranchError mention that doing
1411
# that kind of manipulation on the urls may not be the
1412
# exception object job. On the other hand, this object is
1413
# the interface between the code and the user so
1414
# presenting the urls in different ways is indeed its
1417
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1418
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1421
def get_source_url(self):
1422
return self._requalify_url(self.source)
1424
def get_target_url(self):
1425
return self._requalify_url(self.target)
1428
1704
class TooManyRedirections(TransportError):
1430
1706
_fmt = "Too many redirections"
1432
1709
class ConflictsInTree(BzrError):
1434
1711
_fmt = "Working tree has conflicts."
2233
2685
def __init__(self, error):
2234
2686
self.error = error
2689
class NoMessageSupplied(BzrError):
2691
_fmt = "No message supplied."
2694
class NoMailAddressSpecified(BzrError):
2696
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2699
class UnknownMailClient(BzrError):
2701
_fmt = "Unknown mail client: %(mail_client)s"
2703
def __init__(self, mail_client):
2704
BzrError.__init__(self, mail_client=mail_client)
2707
class MailClientNotFound(BzrError):
2709
_fmt = "Unable to find mail client with the following names:"\
2710
" %(mail_command_list_string)s"
2712
def __init__(self, mail_command_list):
2713
mail_command_list_string = ', '.join(mail_command_list)
2714
BzrError.__init__(self, mail_command_list=mail_command_list,
2715
mail_command_list_string=mail_command_list_string)
2717
class SMTPConnectionRefused(SMTPError):
2719
_fmt = "SMTP connection to %(host)s refused"
2721
def __init__(self, error, host):
2726
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2728
_fmt = "Please specify smtp_server. No server at default %(host)s."
2731
class BzrDirError(BzrError):
2733
def __init__(self, bzrdir):
2734
import bzrlib.urlutils as urlutils
2735
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2737
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2740
class UnsyncedBranches(BzrDirError):
2742
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2743
" bzr help sync-for-reconfigure.")
2745
def __init__(self, bzrdir, target_branch):
2746
BzrDirError.__init__(self, bzrdir)
2747
import bzrlib.urlutils as urlutils
2748
self.target_url = urlutils.unescape_for_display(target_branch.base,
2752
class AlreadyBranch(BzrDirError):
2754
_fmt = "'%(display_url)s' is already a branch."
2757
class AlreadyTree(BzrDirError):
2759
_fmt = "'%(display_url)s' is already a tree."
2762
class AlreadyCheckout(BzrDirError):
2764
_fmt = "'%(display_url)s' is already a checkout."
2767
class AlreadyLightweightCheckout(BzrDirError):
2769
_fmt = "'%(display_url)s' is already a lightweight checkout."
2772
class AlreadyUsingShared(BzrDirError):
2774
_fmt = "'%(display_url)s' is already using a shared repository."
2777
class AlreadyStandalone(BzrDirError):
2779
_fmt = "'%(display_url)s' is already standalone."
2782
class AlreadyWithTrees(BzrDirError):
2784
_fmt = ("Shared repository '%(display_url)s' already creates "
2788
class AlreadyWithNoTrees(BzrDirError):
2790
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2794
class ReconfigurationNotSupported(BzrDirError):
2796
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2799
class NoBindLocation(BzrDirError):
2801
_fmt = "No location could be found to bind to at %(display_url)s."
2804
class UncommittedChanges(BzrError):
2806
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2807
' (See bzr status).%(more)s')
2809
def __init__(self, tree, more=None):
2814
import bzrlib.urlutils as urlutils
2815
display_url = urlutils.unescape_for_display(
2816
tree.bzrdir.root_transport.base, 'ascii')
2817
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2820
class MissingTemplateVariable(BzrError):
2822
_fmt = 'Variable {%(name)s} is not available.'
2824
def __init__(self, name):
2828
class NoTemplate(BzrError):
2830
_fmt = 'No template specified.'
2833
class UnableCreateSymlink(BzrError):
2835
_fmt = 'Unable to create symlink %(path_str)son this platform'
2837
def __init__(self, path=None):
2841
path_str = repr(str(path))
2842
except UnicodeEncodeError:
2843
path_str = repr(path)
2845
self.path_str = path_str
2848
class UnsupportedTimezoneFormat(BzrError):
2850
_fmt = ('Unsupported timezone format "%(timezone)s", '
2851
'options are "utc", "original", "local".')
2853
def __init__(self, timezone):
2854
self.timezone = timezone
2857
class CommandAvailableInPlugin(StandardError):
2859
internal_error = False
2861
def __init__(self, cmd_name, plugin_metadata, provider):
2863
self.plugin_metadata = plugin_metadata
2864
self.cmd_name = cmd_name
2865
self.provider = provider
2869
_fmt = ('"%s" is not a standard bzr command. \n'
2870
'However, the following official plugin provides this command: %s\n'
2871
'You can install it by going to: %s'
2872
% (self.cmd_name, self.plugin_metadata['name'],
2873
self.plugin_metadata['url']))
2878
class NoPluginAvailable(BzrError):
2882
class UnableEncodePath(BzrError):
2884
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2885
'user encoding %(user_encoding)s')
2887
def __init__(self, path, kind):
2888
from bzrlib.osutils import get_user_encoding
2891
self.user_encoding = osutils.get_user_encoding()
2894
class NoSuchAlias(BzrError):
2896
_fmt = ('The alias "%(alias_name)s" does not exist.')
2898
def __init__(self, alias_name):
2899
BzrError.__init__(self, alias_name=alias_name)
2902
class DirectoryLookupFailure(BzrError):
2903
"""Base type for lookup errors."""
2908
class InvalidLocationAlias(DirectoryLookupFailure):
2910
_fmt = '"%(alias_name)s" is not a valid location alias.'
2912
def __init__(self, alias_name):
2913
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2916
class UnsetLocationAlias(DirectoryLookupFailure):
2918
_fmt = 'No %(alias_name)s location assigned.'
2920
def __init__(self, alias_name):
2921
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2924
class CannotBindAddress(BzrError):
2926
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2928
def __init__(self, host, port, orig_error):
2929
# nb: in python2.4 socket.error doesn't have a useful repr
2930
BzrError.__init__(self, host=host, port=port,
2931
orig_error=repr(orig_error.args))
2934
class UnknownRules(BzrError):
2936
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2938
def __init__(self, unknowns):
2939
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2942
class HookFailed(BzrError):
2943
"""Raised when a pre_change_branch_tip hook function fails anything other
2944
than TipChangeRejected.
2947
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2948
"%(traceback_text)s%(exc_value)s")
2950
def __init__(self, hook_stage, hook_name, exc_info):
2952
self.hook_stage = hook_stage
2953
self.hook_name = hook_name
2954
self.exc_info = exc_info
2955
self.exc_type = exc_info[0]
2956
self.exc_value = exc_info[1]
2957
self.exc_tb = exc_info[2]
2958
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2961
class TipChangeRejected(BzrError):
2962
"""A pre_change_branch_tip hook function may raise this to cleanly and
2963
explicitly abort a change to a branch tip.
2966
_fmt = u"Tip change rejected: %(msg)s"
2968
def __init__(self, msg):
2972
class ShelfCorrupt(BzrError):
2974
_fmt = "Shelf corrupt."
2977
class NoSuchShelfId(BzrError):
2979
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2981
def __init__(self, shelf_id):
2982
BzrError.__init__(self, shelf_id=shelf_id)
2985
class InvalidShelfId(BzrError):
2987
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2989
def __init__(self, invalid_id):
2990
BzrError.__init__(self, invalid_id=invalid_id)
2993
class JailBreak(BzrError):
2995
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2997
def __init__(self, url):
2998
BzrError.__init__(self, url=url)
3001
class UserAbort(BzrError):
3003
_fmt = 'The user aborted the operation.'
3006
class MustHaveWorkingTree(BzrError):
3008
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3010
def __init__(self, format, url):
3011
BzrError.__init__(self, format=format, url=url)
3014
class NoSuchView(BzrError):
3015
"""A view does not exist.
3018
_fmt = u"No such view: %(view_name)s."
3020
def __init__(self, view_name):
3021
self.view_name = view_name
3024
class ViewsNotSupported(BzrError):
3025
"""Views are not supported by a tree format.
3028
_fmt = ("Views are not supported by %(tree)s;"
3029
" use 'bzr upgrade' to change your tree to a later format.")
3031
def __init__(self, tree):
3035
class FileOutsideView(BzrError):
3037
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3040
def __init__(self, file_name, view_files):
3041
self.file_name = file_name
3042
self.view_str = ", ".join(view_files)
3045
class UnresumableWriteGroup(BzrError):
3047
_fmt = ("Repository %(repository)s cannot resume write group "
3048
"%(write_groups)r: %(reason)s")
3050
internal_error = True
3052
def __init__(self, repository, write_groups, reason):
3053
self.repository = repository
3054
self.write_groups = write_groups
3055
self.reason = reason
3058
class UnsuspendableWriteGroup(BzrError):
3060
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3062
internal_error = True
3064
def __init__(self, repository):
3065
self.repository = repository
3068
class LossyPushToSameVCS(BzrError):
3070
_fmt = ("Lossy push not possible between %(source_branch)r and "
3071
"%(target_branch)r that are in the same VCS.")
3073
internal_error = True
3075
def __init__(self, source_branch, target_branch):
3076
self.source_branch = source_branch
3077
self.target_branch = target_branch