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):
1684
1442
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1686
def __init__(self, source, target, is_permanent=False):
1444
def __init__(self, source, target, is_permament=False, qual_proto=None):
1687
1445
self.source = source
1688
1446
self.target = target
1690
1448
self.permanently = ' permanently'
1692
1450
self.permanently = ''
1451
self.is_permament = is_permament
1452
self._qualified_proto = qual_proto
1693
1453
TransportError.__init__(self)
1455
def _requalify_url(self, url):
1456
"""Restore the qualified proto in front of the url"""
1457
# When this exception is raised, source and target are in
1458
# user readable format. But some transports may use a
1459
# different proto (http+urllib:// will present http:// to
1460
# the user. If a qualified proto is specified, the code
1461
# trapping the exception can get the qualified urls to
1462
# properly handle the redirection themself (creating a
1463
# new transport object from the target url for example).
1464
# But checking that the scheme of the original and
1465
# redirected urls are the same can be tricky. (see the
1466
# FIXME in BzrDir.open_from_transport for the unique use
1468
if self._qualified_proto is None:
1471
# The TODO related to NotBranchError mention that doing
1472
# that kind of manipulation on the urls may not be the
1473
# exception object job. On the other hand, this object is
1474
# the interface between the code and the user so
1475
# presenting the urls in different ways is indeed its
1478
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1479
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1482
def get_source_url(self):
1483
return self._requalify_url(self.source)
1485
def get_target_url(self):
1486
return self._requalify_url(self.target)
1696
1489
class TooManyRedirections(TransportError):
1698
1491
_fmt = "Too many redirections"
1701
1493
class ConflictsInTree(BzrError):
1703
1495
_fmt = "Working tree has conflicts."
2661
2309
def __init__(self, error):
2662
2310
self.error = error
2665
class NoMessageSupplied(BzrError):
2667
_fmt = "No message supplied."
2670
class NoMailAddressSpecified(BzrError):
2672
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2675
class UnknownMailClient(BzrError):
2677
_fmt = "Unknown mail client: %(mail_client)s"
2679
def __init__(self, mail_client):
2680
BzrError.__init__(self, mail_client=mail_client)
2683
class MailClientNotFound(BzrError):
2685
_fmt = "Unable to find mail client with the following names:"\
2686
" %(mail_command_list_string)s"
2688
def __init__(self, mail_command_list):
2689
mail_command_list_string = ', '.join(mail_command_list)
2690
BzrError.__init__(self, mail_command_list=mail_command_list,
2691
mail_command_list_string=mail_command_list_string)
2693
class SMTPConnectionRefused(SMTPError):
2695
_fmt = "SMTP connection to %(host)s refused"
2697
def __init__(self, error, host):
2702
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2704
_fmt = "Please specify smtp_server. No server at default %(host)s."
2707
class BzrDirError(BzrError):
2709
def __init__(self, bzrdir):
2710
import bzrlib.urlutils as urlutils
2711
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2713
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2716
class UnsyncedBranches(BzrDirError):
2718
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2719
" bzr help sync-for-reconfigure.")
2721
def __init__(self, bzrdir, target_branch):
2722
BzrDirError.__init__(self, bzrdir)
2723
import bzrlib.urlutils as urlutils
2724
self.target_url = urlutils.unescape_for_display(target_branch.base,
2728
class AlreadyBranch(BzrDirError):
2730
_fmt = "'%(display_url)s' is already a branch."
2733
class AlreadyTree(BzrDirError):
2735
_fmt = "'%(display_url)s' is already a tree."
2738
class AlreadyCheckout(BzrDirError):
2740
_fmt = "'%(display_url)s' is already a checkout."
2743
class AlreadyLightweightCheckout(BzrDirError):
2745
_fmt = "'%(display_url)s' is already a lightweight checkout."
2748
class AlreadyUsingShared(BzrDirError):
2750
_fmt = "'%(display_url)s' is already using a shared repository."
2753
class AlreadyStandalone(BzrDirError):
2755
_fmt = "'%(display_url)s' is already standalone."
2758
class AlreadyWithTrees(BzrDirError):
2760
_fmt = ("Shared repository '%(display_url)s' already creates "
2764
class AlreadyWithNoTrees(BzrDirError):
2766
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2770
class ReconfigurationNotSupported(BzrDirError):
2772
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2775
class NoBindLocation(BzrDirError):
2777
_fmt = "No location could be found to bind to at %(display_url)s."
2780
class UncommittedChanges(BzrError):
2782
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2784
def __init__(self, tree):
2785
import bzrlib.urlutils as urlutils
2786
display_url = urlutils.unescape_for_display(
2787
tree.bzrdir.root_transport.base, 'ascii')
2788
BzrError.__init__(self, tree=tree, display_url=display_url)
2791
class MissingTemplateVariable(BzrError):
2793
_fmt = 'Variable {%(name)s} is not available.'
2795
def __init__(self, name):
2799
class NoTemplate(BzrError):
2801
_fmt = 'No template specified.'
2804
class UnableCreateSymlink(BzrError):
2806
_fmt = 'Unable to create symlink %(path_str)son this platform'
2808
def __init__(self, path=None):
2812
path_str = repr(str(path))
2813
except UnicodeEncodeError:
2814
path_str = repr(path)
2816
self.path_str = path_str
2819
class UnsupportedTimezoneFormat(BzrError):
2821
_fmt = ('Unsupported timezone format "%(timezone)s", '
2822
'options are "utc", "original", "local".')
2824
def __init__(self, timezone):
2825
self.timezone = timezone
2828
class CommandAvailableInPlugin(StandardError):
2830
internal_error = False
2832
def __init__(self, cmd_name, plugin_metadata, provider):
2834
self.plugin_metadata = plugin_metadata
2835
self.cmd_name = cmd_name
2836
self.provider = provider
2840
_fmt = ('"%s" is not a standard bzr command. \n'
2841
'However, the following official plugin provides this command: %s\n'
2842
'You can install it by going to: %s'
2843
% (self.cmd_name, self.plugin_metadata['name'],
2844
self.plugin_metadata['url']))
2849
class NoPluginAvailable(BzrError):
2853
class UnableEncodePath(BzrError):
2855
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2856
'user encoding %(user_encoding)s')
2858
def __init__(self, path, kind):
2859
from bzrlib.osutils import get_user_encoding
2862
self.user_encoding = osutils.get_user_encoding()
2865
class NoSuchAlias(BzrError):
2867
_fmt = ('The alias "%(alias_name)s" does not exist.')
2869
def __init__(self, alias_name):
2870
BzrError.__init__(self, alias_name=alias_name)
2873
class DirectoryLookupFailure(BzrError):
2874
"""Base type for lookup errors."""
2879
class InvalidLocationAlias(DirectoryLookupFailure):
2881
_fmt = '"%(alias_name)s" is not a valid location alias.'
2883
def __init__(self, alias_name):
2884
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2887
class UnsetLocationAlias(DirectoryLookupFailure):
2889
_fmt = 'No %(alias_name)s location assigned.'
2891
def __init__(self, alias_name):
2892
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2895
class CannotBindAddress(BzrError):
2897
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2899
def __init__(self, host, port, orig_error):
2900
BzrError.__init__(self, host=host, port=port,
2901
orig_error=orig_error[1])
2904
class UnknownRules(BzrError):
2906
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2908
def __init__(self, unknowns):
2909
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2912
class HookFailed(BzrError):
2913
"""Raised when a pre_change_branch_tip hook function fails anything other
2914
than TipChangeRejected.
2917
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2918
"%(traceback_text)s%(exc_value)s")
2920
def __init__(self, hook_stage, hook_name, exc_info):
2922
self.hook_stage = hook_stage
2923
self.hook_name = hook_name
2924
self.exc_info = exc_info
2925
self.exc_type = exc_info[0]
2926
self.exc_value = exc_info[1]
2927
self.exc_tb = exc_info[2]
2928
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2931
class TipChangeRejected(BzrError):
2932
"""A pre_change_branch_tip hook function may raise this to cleanly and
2933
explicitly abort a change to a branch tip.
2936
_fmt = u"Tip change rejected: %(msg)s"
2938
def __init__(self, msg):
2942
class ShelfCorrupt(BzrError):
2944
_fmt = "Shelf corrupt."
2947
class NoSuchShelfId(BzrError):
2949
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2951
def __init__(self, shelf_id):
2952
BzrError.__init__(self, shelf_id=shelf_id)
2955
class InvalidShelfId(BzrError):
2957
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2959
def __init__(self, invalid_id):
2960
BzrError.__init__(self, invalid_id=invalid_id)
2963
class UserAbort(BzrError):
2965
_fmt = 'The user aborted the operation.'
2968
class MustHaveWorkingTree(BzrError):
2970
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
2972
def __init__(self, format, url):
2973
BzrError.__init__(self, format=format, url=url)
2976
class NoSuchView(BzrError):
2977
"""A view does not exist.
2980
_fmt = u"No such view: %(view_name)s."
2982
def __init__(self, view_name):
2983
self.view_name = view_name
2986
class ViewsNotSupported(BzrError):
2987
"""Views are not supported by a tree format.
2990
_fmt = ("Views are not supported by %(tree)s;"
2991
" use 'bzr upgrade' to change your tree to a later format.")
2993
def __init__(self, tree):
2997
class FileOutsideView(BzrError):
2999
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3002
def __init__(self, file_name, view_files):
3003
self.file_name = file_name
3004
self.view_str = ", ".join(view_files)
3007
class UnresumableWriteGroup(BzrError):
3009
_fmt = ("Repository %(repository)s cannot resume write group "
3010
"%(write_groups)r: %(reason)s")
3012
internal_error = True
3014
def __init__(self, repository, write_groups, reason):
3015
self.repository = repository
3016
self.write_groups = write_groups
3017
self.reason = reason
3020
class UnsuspendableWriteGroup(BzrError):
3022
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3024
internal_error = True
3026
def __init__(self, repository):
3027
self.repository = repository