532
451
class NotADirectory(PathError):
534
_fmt = '"%(path)s" is not a directory %(extra)s'
453
_fmt = "%(path)r is not a directory %(extra)s"
537
456
class NotInWorkingDirectory(PathError):
539
_fmt = '"%(path)s" is not in the working directory %(extra)s'
458
_fmt = "%(path)r is not in the working directory %(extra)s"
542
461
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):
463
_fmt = "Directory not empty: %(path)r%(extra)s"
466
class ReadingCompleted(BzrError):
554
468
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
555
469
"called upon it - the request has been completed and no more "
556
470
"data may be read.")
472
internal_error = True
558
474
def __init__(self, request):
559
475
self.request = request
562
478
class ResourceBusy(PathError):
564
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
480
_fmt = "Device or resource busy: %(path)r%(extra)s"
567
483
class PermissionDenied(PathError):
569
_fmt = 'Permission denied: "%(path)s"%(extra)s'
485
_fmt = "Permission denied: %(path)r%(extra)s"
572
488
class InvalidURL(PathError):
574
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
490
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
577
493
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)
495
_fmt = "Invalid URL join request: %(args)s%(extra)s"
497
def __init__(self, msg, base, args):
498
PathError.__init__(self, base, msg)
499
self.args = [base] + list(args)
610
502
class UnknownHook(BzrError):
1686
1428
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1688
def __init__(self, source, target, is_permanent=False):
1430
def __init__(self, source, target, is_permament=False, qual_proto=None):
1689
1431
self.source = source
1690
1432
self.target = target
1692
1434
self.permanently = ' permanently'
1694
1436
self.permanently = ''
1437
self.is_permament = is_permament
1438
self._qualified_proto = qual_proto
1695
1439
TransportError.__init__(self)
1441
def _requalify_url(self, url):
1442
"""Restore the qualified proto in front of the url"""
1443
# When this exception is raised, source and target are in
1444
# user readable format. But some transports may use a
1445
# different proto (http+urllib:// will present http:// to
1446
# the user. If a qualified proto is specified, the code
1447
# trapping the exception can get the qualified urls to
1448
# properly handle the redirection themself (creating a
1449
# new transport object from the target url for example).
1450
# But checking that the scheme of the original and
1451
# redirected urls are the same can be tricky. (see the
1452
# FIXME in BzrDir.open_from_transport for the unique use
1454
if self._qualified_proto is None:
1457
# The TODO related to NotBranchError mention that doing
1458
# that kind of manipulation on the urls may not be the
1459
# exception object job. On the other hand, this object is
1460
# the interface between the code and the user so
1461
# presenting the urls in different ways is indeed its
1464
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1465
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1468
def get_source_url(self):
1469
return self._requalify_url(self.source)
1471
def get_target_url(self):
1472
return self._requalify_url(self.target)
1698
1475
class TooManyRedirections(TransportError):
1700
1477
_fmt = "Too many redirections"
1703
1479
class ConflictsInTree(BzrError):
1705
1481
_fmt = "Working tree has conflicts."
2677
2279
def __init__(self, error):
2678
2280
self.error = error
2681
class NoMessageSupplied(BzrError):
2683
_fmt = "No message supplied."
2686
class NoMailAddressSpecified(BzrError):
2688
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2691
class UnknownMailClient(BzrError):
2693
_fmt = "Unknown mail client: %(mail_client)s"
2695
def __init__(self, mail_client):
2696
BzrError.__init__(self, mail_client=mail_client)
2699
class MailClientNotFound(BzrError):
2701
_fmt = "Unable to find mail client with the following names:"\
2702
" %(mail_command_list_string)s"
2704
def __init__(self, mail_command_list):
2705
mail_command_list_string = ', '.join(mail_command_list)
2706
BzrError.__init__(self, mail_command_list=mail_command_list,
2707
mail_command_list_string=mail_command_list_string)
2709
class SMTPConnectionRefused(SMTPError):
2711
_fmt = "SMTP connection to %(host)s refused"
2713
def __init__(self, error, host):
2718
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2720
_fmt = "Please specify smtp_server. No server at default %(host)s."
2723
class BzrDirError(BzrError):
2725
def __init__(self, bzrdir):
2726
import bzrlib.urlutils as urlutils
2727
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2729
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2732
class UnsyncedBranches(BzrDirError):
2734
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2735
" bzr help sync-for-reconfigure.")
2737
def __init__(self, bzrdir, target_branch):
2738
BzrDirError.__init__(self, bzrdir)
2739
import bzrlib.urlutils as urlutils
2740
self.target_url = urlutils.unescape_for_display(target_branch.base,
2744
class AlreadyBranch(BzrDirError):
2746
_fmt = "'%(display_url)s' is already a branch."
2749
class AlreadyTree(BzrDirError):
2751
_fmt = "'%(display_url)s' is already a tree."
2754
class AlreadyCheckout(BzrDirError):
2756
_fmt = "'%(display_url)s' is already a checkout."
2759
class AlreadyLightweightCheckout(BzrDirError):
2761
_fmt = "'%(display_url)s' is already a lightweight checkout."
2764
class AlreadyUsingShared(BzrDirError):
2766
_fmt = "'%(display_url)s' is already using a shared repository."
2769
class AlreadyStandalone(BzrDirError):
2771
_fmt = "'%(display_url)s' is already standalone."
2774
class AlreadyWithTrees(BzrDirError):
2776
_fmt = ("Shared repository '%(display_url)s' already creates "
2780
class AlreadyWithNoTrees(BzrDirError):
2782
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2786
class ReconfigurationNotSupported(BzrDirError):
2788
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2791
class NoBindLocation(BzrDirError):
2793
_fmt = "No location could be found to bind to at %(display_url)s."
2796
class UncommittedChanges(BzrError):
2798
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2799
' (See bzr status).%(more)s')
2801
def __init__(self, tree, more=None):
2806
import bzrlib.urlutils as urlutils
2807
display_url = urlutils.unescape_for_display(
2808
tree.bzrdir.root_transport.base, 'ascii')
2809
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2812
class MissingTemplateVariable(BzrError):
2814
_fmt = 'Variable {%(name)s} is not available.'
2816
def __init__(self, name):
2820
class NoTemplate(BzrError):
2822
_fmt = 'No template specified.'
2825
class UnableCreateSymlink(BzrError):
2827
_fmt = 'Unable to create symlink %(path_str)son this platform'
2829
def __init__(self, path=None):
2833
path_str = repr(str(path))
2834
except UnicodeEncodeError:
2835
path_str = repr(path)
2837
self.path_str = path_str
2840
class UnsupportedTimezoneFormat(BzrError):
2842
_fmt = ('Unsupported timezone format "%(timezone)s", '
2843
'options are "utc", "original", "local".')
2845
def __init__(self, timezone):
2846
self.timezone = timezone
2849
class CommandAvailableInPlugin(StandardError):
2851
internal_error = False
2853
def __init__(self, cmd_name, plugin_metadata, provider):
2855
self.plugin_metadata = plugin_metadata
2856
self.cmd_name = cmd_name
2857
self.provider = provider
2861
_fmt = ('"%s" is not a standard bzr command. \n'
2862
'However, the following official plugin provides this command: %s\n'
2863
'You can install it by going to: %s'
2864
% (self.cmd_name, self.plugin_metadata['name'],
2865
self.plugin_metadata['url']))
2870
class NoPluginAvailable(BzrError):
2874
class UnableEncodePath(BzrError):
2876
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2877
'user encoding %(user_encoding)s')
2879
def __init__(self, path, kind):
2880
from bzrlib.osutils import get_user_encoding
2883
self.user_encoding = osutils.get_user_encoding()
2886
class NoSuchAlias(BzrError):
2888
_fmt = ('The alias "%(alias_name)s" does not exist.')
2890
def __init__(self, alias_name):
2891
BzrError.__init__(self, alias_name=alias_name)
2894
class DirectoryLookupFailure(BzrError):
2895
"""Base type for lookup errors."""
2900
class InvalidLocationAlias(DirectoryLookupFailure):
2902
_fmt = '"%(alias_name)s" is not a valid location alias.'
2904
def __init__(self, alias_name):
2905
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2908
class UnsetLocationAlias(DirectoryLookupFailure):
2910
_fmt = 'No %(alias_name)s location assigned.'
2912
def __init__(self, alias_name):
2913
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2916
class CannotBindAddress(BzrError):
2918
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2920
def __init__(self, host, port, orig_error):
2921
BzrError.__init__(self, host=host, port=port,
2922
orig_error=orig_error[1])
2925
class UnknownRules(BzrError):
2927
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2929
def __init__(self, unknowns):
2930
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2933
class HookFailed(BzrError):
2934
"""Raised when a pre_change_branch_tip hook function fails anything other
2935
than TipChangeRejected.
2938
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2939
"%(traceback_text)s%(exc_value)s")
2941
def __init__(self, hook_stage, hook_name, exc_info):
2943
self.hook_stage = hook_stage
2944
self.hook_name = hook_name
2945
self.exc_info = exc_info
2946
self.exc_type = exc_info[0]
2947
self.exc_value = exc_info[1]
2948
self.exc_tb = exc_info[2]
2949
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2952
class TipChangeRejected(BzrError):
2953
"""A pre_change_branch_tip hook function may raise this to cleanly and
2954
explicitly abort a change to a branch tip.
2957
_fmt = u"Tip change rejected: %(msg)s"
2959
def __init__(self, msg):
2963
class ShelfCorrupt(BzrError):
2965
_fmt = "Shelf corrupt."
2968
class NoSuchShelfId(BzrError):
2970
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2972
def __init__(self, shelf_id):
2973
BzrError.__init__(self, shelf_id=shelf_id)
2976
class InvalidShelfId(BzrError):
2978
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2980
def __init__(self, invalid_id):
2981
BzrError.__init__(self, invalid_id=invalid_id)
2984
class JailBreak(BzrError):
2986
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2988
def __init__(self, url):
2989
BzrError.__init__(self, url=url)
2992
class UserAbort(BzrError):
2994
_fmt = 'The user aborted the operation.'
2997
class MustHaveWorkingTree(BzrError):
2999
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3001
def __init__(self, format, url):
3002
BzrError.__init__(self, format=format, url=url)
3005
class NoSuchView(BzrError):
3006
"""A view does not exist.
3009
_fmt = u"No such view: %(view_name)s."
3011
def __init__(self, view_name):
3012
self.view_name = view_name
3015
class ViewsNotSupported(BzrError):
3016
"""Views are not supported by a tree format.
3019
_fmt = ("Views are not supported by %(tree)s;"
3020
" use 'bzr upgrade' to change your tree to a later format.")
3022
def __init__(self, tree):
3026
class FileOutsideView(BzrError):
3028
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3031
def __init__(self, file_name, view_files):
3032
self.file_name = file_name
3033
self.view_str = ", ".join(view_files)
3036
class UnresumableWriteGroup(BzrError):
3038
_fmt = ("Repository %(repository)s cannot resume write group "
3039
"%(write_groups)r: %(reason)s")
3041
internal_error = True
3043
def __init__(self, repository, write_groups, reason):
3044
self.repository = repository
3045
self.write_groups = write_groups
3046
self.reason = reason
3049
class UnsuspendableWriteGroup(BzrError):
3051
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3053
internal_error = True
3055
def __init__(self, repository):
3056
self.repository = repository
3059
class LossyPushToSameVCS(BzrError):
3061
_fmt = ("Lossy push not possible between %(source_branch)r and "
3062
"%(target_branch)r that are in the same VCS.")
3064
internal_error = True
3066
def __init__(self, source_branch, target_branch):
3067
self.source_branch = source_branch
3068
self.target_branch = target_branch