460
532
class NotADirectory(PathError):
462
_fmt = "%(path)r is not a directory %(extra)s"
534
_fmt = '"%(path)s" is not a directory %(extra)s'
465
537
class NotInWorkingDirectory(PathError):
467
_fmt = "%(path)r is not in the working directory %(extra)s"
539
_fmt = '"%(path)s" is not in the working directory %(extra)s'
470
542
class DirectoryNotEmpty(PathError):
472
_fmt = "Directory not empty: %(path)r%(extra)s"
475
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):
477
554
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
478
555
"called upon it - the request has been completed and no more "
479
556
"data may be read.")
481
internal_error = True
483
558
def __init__(self, request):
484
559
self.request = request
487
562
class ResourceBusy(PathError):
489
_fmt = "Device or resource busy: %(path)r%(extra)s"
564
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
492
567
class PermissionDenied(PathError):
494
_fmt = "Permission denied: %(path)r%(extra)s"
569
_fmt = 'Permission denied: "%(path)s"%(extra)s'
497
572
class InvalidURL(PathError):
499
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
574
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
502
577
class InvalidURLJoin(PathError):
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)
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)
511
610
class UnknownHook(BzrError):
1442
1676
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1444
def __init__(self, source, target, is_permament=False, qual_proto=None):
1678
def __init__(self, source, target, is_permanent=False):
1445
1679
self.source = source
1446
1680
self.target = target
1448
1682
self.permanently = ' permanently'
1450
1684
self.permanently = ''
1451
self.is_permament = is_permament
1452
self._qualified_proto = qual_proto
1453
1685
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)
1489
1688
class TooManyRedirections(TransportError):
1491
1690
_fmt = "Too many redirections"
1493
1693
class ConflictsInTree(BzrError):
1495
1695
_fmt = "Working tree has conflicts."
2309
2653
def __init__(self, error):
2310
2654
self.error = error
2657
class NoMessageSupplied(BzrError):
2659
_fmt = "No message supplied."
2662
class NoMailAddressSpecified(BzrError):
2664
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2667
class UnknownMailClient(BzrError):
2669
_fmt = "Unknown mail client: %(mail_client)s"
2671
def __init__(self, mail_client):
2672
BzrError.__init__(self, mail_client=mail_client)
2675
class MailClientNotFound(BzrError):
2677
_fmt = "Unable to find mail client with the following names:"\
2678
" %(mail_command_list_string)s"
2680
def __init__(self, mail_command_list):
2681
mail_command_list_string = ', '.join(mail_command_list)
2682
BzrError.__init__(self, mail_command_list=mail_command_list,
2683
mail_command_list_string=mail_command_list_string)
2685
class SMTPConnectionRefused(SMTPError):
2687
_fmt = "SMTP connection to %(host)s refused"
2689
def __init__(self, error, host):
2694
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2696
_fmt = "Please specify smtp_server. No server at default %(host)s."
2699
class BzrDirError(BzrError):
2701
def __init__(self, bzrdir):
2702
import bzrlib.urlutils as urlutils
2703
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2705
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2708
class UnsyncedBranches(BzrDirError):
2710
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2711
" bzr help sync-for-reconfigure.")
2713
def __init__(self, bzrdir, target_branch):
2714
BzrDirError.__init__(self, bzrdir)
2715
import bzrlib.urlutils as urlutils
2716
self.target_url = urlutils.unescape_for_display(target_branch.base,
2720
class AlreadyBranch(BzrDirError):
2722
_fmt = "'%(display_url)s' is already a branch."
2725
class AlreadyTree(BzrDirError):
2727
_fmt = "'%(display_url)s' is already a tree."
2730
class AlreadyCheckout(BzrDirError):
2732
_fmt = "'%(display_url)s' is already a checkout."
2735
class AlreadyLightweightCheckout(BzrDirError):
2737
_fmt = "'%(display_url)s' is already a lightweight checkout."
2740
class AlreadyUsingShared(BzrDirError):
2742
_fmt = "'%(display_url)s' is already using a shared repository."
2745
class AlreadyStandalone(BzrDirError):
2747
_fmt = "'%(display_url)s' is already standalone."
2750
class AlreadyWithTrees(BzrDirError):
2752
_fmt = ("Shared repository '%(display_url)s' already creates "
2756
class AlreadyWithNoTrees(BzrDirError):
2758
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2762
class ReconfigurationNotSupported(BzrDirError):
2764
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2767
class NoBindLocation(BzrDirError):
2769
_fmt = "No location could be found to bind to at %(display_url)s."
2772
class UncommittedChanges(BzrError):
2774
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2776
def __init__(self, tree):
2777
import bzrlib.urlutils as urlutils
2778
display_url = urlutils.unescape_for_display(
2779
tree.bzrdir.root_transport.base, 'ascii')
2780
BzrError.__init__(self, tree=tree, display_url=display_url)
2783
class MissingTemplateVariable(BzrError):
2785
_fmt = 'Variable {%(name)s} is not available.'
2787
def __init__(self, name):
2791
class NoTemplate(BzrError):
2793
_fmt = 'No template specified.'
2796
class UnableCreateSymlink(BzrError):
2798
_fmt = 'Unable to create symlink %(path_str)son this platform'
2800
def __init__(self, path=None):
2804
path_str = repr(str(path))
2805
except UnicodeEncodeError:
2806
path_str = repr(path)
2808
self.path_str = path_str
2811
class UnsupportedTimezoneFormat(BzrError):
2813
_fmt = ('Unsupported timezone format "%(timezone)s", '
2814
'options are "utc", "original", "local".')
2816
def __init__(self, timezone):
2817
self.timezone = timezone
2820
class CommandAvailableInPlugin(StandardError):
2822
internal_error = False
2824
def __init__(self, cmd_name, plugin_metadata, provider):
2826
self.plugin_metadata = plugin_metadata
2827
self.cmd_name = cmd_name
2828
self.provider = provider
2832
_fmt = ('"%s" is not a standard bzr command. \n'
2833
'However, the following official plugin provides this command: %s\n'
2834
'You can install it by going to: %s'
2835
% (self.cmd_name, self.plugin_metadata['name'],
2836
self.plugin_metadata['url']))
2841
class NoPluginAvailable(BzrError):
2845
class UnableEncodePath(BzrError):
2847
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2848
'user encoding %(user_encoding)s')
2850
def __init__(self, path, kind):
2851
from bzrlib.osutils import get_user_encoding
2854
self.user_encoding = osutils.get_user_encoding()
2857
class NoSuchAlias(BzrError):
2859
_fmt = ('The alias "%(alias_name)s" does not exist.')
2861
def __init__(self, alias_name):
2862
BzrError.__init__(self, alias_name=alias_name)
2865
class DirectoryLookupFailure(BzrError):
2866
"""Base type for lookup errors."""
2871
class InvalidLocationAlias(DirectoryLookupFailure):
2873
_fmt = '"%(alias_name)s" is not a valid location alias.'
2875
def __init__(self, alias_name):
2876
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2879
class UnsetLocationAlias(DirectoryLookupFailure):
2881
_fmt = 'No %(alias_name)s location assigned.'
2883
def __init__(self, alias_name):
2884
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2887
class CannotBindAddress(BzrError):
2889
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2891
def __init__(self, host, port, orig_error):
2892
BzrError.__init__(self, host=host, port=port,
2893
orig_error=orig_error[1])
2896
class UnknownRules(BzrError):
2898
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2900
def __init__(self, unknowns):
2901
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2904
class HookFailed(BzrError):
2905
"""Raised when a pre_change_branch_tip hook function fails anything other
2906
than TipChangeRejected.
2909
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2910
"%(traceback_text)s%(exc_value)s")
2912
def __init__(self, hook_stage, hook_name, exc_info):
2914
self.hook_stage = hook_stage
2915
self.hook_name = hook_name
2916
self.exc_info = exc_info
2917
self.exc_type = exc_info[0]
2918
self.exc_value = exc_info[1]
2919
self.exc_tb = exc_info[2]
2920
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2923
class TipChangeRejected(BzrError):
2924
"""A pre_change_branch_tip hook function may raise this to cleanly and
2925
explicitly abort a change to a branch tip.
2928
_fmt = u"Tip change rejected: %(msg)s"
2930
def __init__(self, msg):
2934
class ShelfCorrupt(BzrError):
2936
_fmt = "Shelf corrupt."
2939
class NoSuchShelfId(BzrError):
2941
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2943
def __init__(self, shelf_id):
2944
BzrError.__init__(self, shelf_id=shelf_id)
2947
class InvalidShelfId(BzrError):
2949
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2951
def __init__(self, invalid_id):
2952
BzrError.__init__(self, invalid_id=invalid_id)
2955
class JailBreak(BzrError):
2957
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2959
def __init__(self, url):
2960
BzrError.__init__(self, url=url)
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
3030
class LossyPushToSameVCS(BzrError):
3032
_fmt = ("Lossy push not possible between %(source_branch)r and "
3033
"%(target_branch)r that are in the same VCS.")
3035
internal_error = True
3037
def __init__(self, source_branch, target_branch):
3038
self.source_branch = source_branch
3039
self.target_branch = target_branch