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):
1676
1428
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1678
def __init__(self, source, target, is_permanent=False):
1430
def __init__(self, source, target, is_permament=False, qual_proto=None):
1679
1431
self.source = source
1680
1432
self.target = target
1682
1434
self.permanently = ' permanently'
1684
1436
self.permanently = ''
1437
self.is_permament = is_permament
1438
self._qualified_proto = qual_proto
1685
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)
1688
1475
class TooManyRedirections(TransportError):
1690
1477
_fmt = "Too many redirections"
1693
1479
class ConflictsInTree(BzrError):
1695
1481
_fmt = "Working tree has conflicts."
2650
2279
def __init__(self, error):
2651
2280
self.error = error
2654
class NoMessageSupplied(BzrError):
2656
_fmt = "No message supplied."
2659
class NoMailAddressSpecified(BzrError):
2661
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2664
class UnknownMailClient(BzrError):
2666
_fmt = "Unknown mail client: %(mail_client)s"
2668
def __init__(self, mail_client):
2669
BzrError.__init__(self, mail_client=mail_client)
2672
class MailClientNotFound(BzrError):
2674
_fmt = "Unable to find mail client with the following names:"\
2675
" %(mail_command_list_string)s"
2677
def __init__(self, mail_command_list):
2678
mail_command_list_string = ', '.join(mail_command_list)
2679
BzrError.__init__(self, mail_command_list=mail_command_list,
2680
mail_command_list_string=mail_command_list_string)
2682
class SMTPConnectionRefused(SMTPError):
2684
_fmt = "SMTP connection to %(host)s refused"
2686
def __init__(self, error, host):
2691
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2693
_fmt = "Please specify smtp_server. No server at default %(host)s."
2696
class BzrDirError(BzrError):
2698
def __init__(self, bzrdir):
2699
import bzrlib.urlutils as urlutils
2700
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2702
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2705
class UnsyncedBranches(BzrDirError):
2707
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2708
" bzr help sync-for-reconfigure.")
2710
def __init__(self, bzrdir, target_branch):
2711
BzrDirError.__init__(self, bzrdir)
2712
import bzrlib.urlutils as urlutils
2713
self.target_url = urlutils.unescape_for_display(target_branch.base,
2717
class AlreadyBranch(BzrDirError):
2719
_fmt = "'%(display_url)s' is already a branch."
2722
class AlreadyTree(BzrDirError):
2724
_fmt = "'%(display_url)s' is already a tree."
2727
class AlreadyCheckout(BzrDirError):
2729
_fmt = "'%(display_url)s' is already a checkout."
2732
class AlreadyLightweightCheckout(BzrDirError):
2734
_fmt = "'%(display_url)s' is already a lightweight checkout."
2737
class AlreadyUsingShared(BzrDirError):
2739
_fmt = "'%(display_url)s' is already using a shared repository."
2742
class AlreadyStandalone(BzrDirError):
2744
_fmt = "'%(display_url)s' is already standalone."
2747
class AlreadyWithTrees(BzrDirError):
2749
_fmt = ("Shared repository '%(display_url)s' already creates "
2753
class AlreadyWithNoTrees(BzrDirError):
2755
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2759
class ReconfigurationNotSupported(BzrDirError):
2761
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2764
class NoBindLocation(BzrDirError):
2766
_fmt = "No location could be found to bind to at %(display_url)s."
2769
class UncommittedChanges(BzrError):
2771
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2773
def __init__(self, tree):
2774
import bzrlib.urlutils as urlutils
2775
display_url = urlutils.unescape_for_display(
2776
tree.bzrdir.root_transport.base, 'ascii')
2777
BzrError.__init__(self, tree=tree, display_url=display_url)
2780
class MissingTemplateVariable(BzrError):
2782
_fmt = 'Variable {%(name)s} is not available.'
2784
def __init__(self, name):
2788
class NoTemplate(BzrError):
2790
_fmt = 'No template specified.'
2793
class UnableCreateSymlink(BzrError):
2795
_fmt = 'Unable to create symlink %(path_str)son this platform'
2797
def __init__(self, path=None):
2801
path_str = repr(str(path))
2802
except UnicodeEncodeError:
2803
path_str = repr(path)
2805
self.path_str = path_str
2808
class UnsupportedTimezoneFormat(BzrError):
2810
_fmt = ('Unsupported timezone format "%(timezone)s", '
2811
'options are "utc", "original", "local".')
2813
def __init__(self, timezone):
2814
self.timezone = timezone
2817
class CommandAvailableInPlugin(StandardError):
2819
internal_error = False
2821
def __init__(self, cmd_name, plugin_metadata, provider):
2823
self.plugin_metadata = plugin_metadata
2824
self.cmd_name = cmd_name
2825
self.provider = provider
2829
_fmt = ('"%s" is not a standard bzr command. \n'
2830
'However, the following official plugin provides this command: %s\n'
2831
'You can install it by going to: %s'
2832
% (self.cmd_name, self.plugin_metadata['name'],
2833
self.plugin_metadata['url']))
2838
class NoPluginAvailable(BzrError):
2842
class UnableEncodePath(BzrError):
2844
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2845
'user encoding %(user_encoding)s')
2847
def __init__(self, path, kind):
2848
from bzrlib.osutils import get_user_encoding
2851
self.user_encoding = osutils.get_user_encoding()
2854
class NoSuchAlias(BzrError):
2856
_fmt = ('The alias "%(alias_name)s" does not exist.')
2858
def __init__(self, alias_name):
2859
BzrError.__init__(self, alias_name=alias_name)
2862
class DirectoryLookupFailure(BzrError):
2863
"""Base type for lookup errors."""
2868
class InvalidLocationAlias(DirectoryLookupFailure):
2870
_fmt = '"%(alias_name)s" is not a valid location alias.'
2872
def __init__(self, alias_name):
2873
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2876
class UnsetLocationAlias(DirectoryLookupFailure):
2878
_fmt = 'No %(alias_name)s location assigned.'
2880
def __init__(self, alias_name):
2881
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2884
class CannotBindAddress(BzrError):
2886
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2888
def __init__(self, host, port, orig_error):
2889
BzrError.__init__(self, host=host, port=port,
2890
orig_error=orig_error[1])
2893
class UnknownRules(BzrError):
2895
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2897
def __init__(self, unknowns):
2898
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2901
class HookFailed(BzrError):
2902
"""Raised when a pre_change_branch_tip hook function fails anything other
2903
than TipChangeRejected.
2906
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2907
"%(traceback_text)s%(exc_value)s")
2909
def __init__(self, hook_stage, hook_name, exc_info):
2911
self.hook_stage = hook_stage
2912
self.hook_name = hook_name
2913
self.exc_info = exc_info
2914
self.exc_type = exc_info[0]
2915
self.exc_value = exc_info[1]
2916
self.exc_tb = exc_info[2]
2917
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2920
class TipChangeRejected(BzrError):
2921
"""A pre_change_branch_tip hook function may raise this to cleanly and
2922
explicitly abort a change to a branch tip.
2925
_fmt = u"Tip change rejected: %(msg)s"
2927
def __init__(self, msg):
2931
class ShelfCorrupt(BzrError):
2933
_fmt = "Shelf corrupt."
2936
class NoSuchShelfId(BzrError):
2938
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
2940
def __init__(self, shelf_id):
2941
BzrError.__init__(self, shelf_id=shelf_id)
2944
class InvalidShelfId(BzrError):
2946
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2948
def __init__(self, invalid_id):
2949
BzrError.__init__(self, invalid_id=invalid_id)
2952
class JailBreak(BzrError):
2954
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2956
def __init__(self, url):
2957
BzrError.__init__(self, url=url)
2960
class UserAbort(BzrError):
2962
_fmt = 'The user aborted the operation.'
2965
class MustHaveWorkingTree(BzrError):
2967
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
2969
def __init__(self, format, url):
2970
BzrError.__init__(self, format=format, url=url)
2973
class NoSuchView(BzrError):
2974
"""A view does not exist.
2977
_fmt = u"No such view: %(view_name)s."
2979
def __init__(self, view_name):
2980
self.view_name = view_name
2983
class ViewsNotSupported(BzrError):
2984
"""Views are not supported by a tree format.
2987
_fmt = ("Views are not supported by %(tree)s;"
2988
" use 'bzr upgrade' to change your tree to a later format.")
2990
def __init__(self, tree):
2994
class FileOutsideView(BzrError):
2996
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
2999
def __init__(self, file_name, view_files):
3000
self.file_name = file_name
3001
self.view_str = ", ".join(view_files)
3004
class UnresumableWriteGroup(BzrError):
3006
_fmt = ("Repository %(repository)s cannot resume write group "
3007
"%(write_groups)r: %(reason)s")
3009
internal_error = True
3011
def __init__(self, repository, write_groups, reason):
3012
self.repository = repository
3013
self.write_groups = write_groups
3014
self.reason = reason
3017
class UnsuspendableWriteGroup(BzrError):
3019
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3021
internal_error = True
3023
def __init__(self, repository):
3024
self.repository = repository
3027
class LossyPushToSameVCS(BzrError):
3029
_fmt = ("Lossy push not possible between %(source_branch)r and "
3030
"%(target_branch)r that are in the same VCS.")
3032
internal_error = True
3034
def __init__(self, source_branch, target_branch):
3035
self.source_branch = source_branch
3036
self.target_branch = target_branch