116
118
getattr(self, '_fmt', None),
119
def __unicode__(self):
121
if isinstance(u, str):
122
# Try decoding the str using the default encoding.
124
elif not isinstance(u, unicode):
125
# Try to make a unicode object from it, because __unicode__ must
126
# return a unicode object.
132
if isinstance(s, unicode):
135
# __str__ must return a str.
139
121
def _get_format_string(self):
140
122
"""Return format string for this exception or None"""
141
123
fmt = getattr(self, '_fmt', None)
567
527
class InvalidURLJoin(PathError):
569
_fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r"
571
def __init__(self, reason, base, join_args):
574
self.join_args = join_args
575
PathError.__init__(self, base, reason)
578
class InvalidRebaseURLs(PathError):
580
_fmt = "URLs differ by more than path: %(from_)r and %(to)r"
582
def __init__(self, from_, to):
585
PathError.__init__(self, from_, 'URLs differ by more than path.')
588
class UnavailableRepresentation(InternalBzrError):
590
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
591
"is encoded as '%(native)s'.")
593
def __init__(self, key, wanted, native):
594
InternalBzrError.__init__(self)
529
_fmt = 'Invalid URL join request: "%(args)s"%(extra)s'
531
def __init__(self, msg, base, args):
532
PathError.__init__(self, base, msg)
533
self.args = [base] + list(args)
600
536
class UnknownHook(BzrError):
615
551
PathError.__init__(self, url, extra=extra)
618
class UnstackableBranchFormat(BzrError):
620
_fmt = ("The branch '%(url)s'(%(format)s) is not a stackable format. "
621
"You will need to upgrade the branch to permit branch stacking.")
623
def __init__(self, format, url):
624
BzrError.__init__(self)
629
class UnstackableRepositoryFormat(BzrError):
631
_fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
632
"You will need to upgrade the repository to permit branch stacking.")
634
def __init__(self, format, url):
635
BzrError.__init__(self)
640
554
class ReadError(PathError):
642
556
_fmt = """Error reading from %(path)r."""
775
685
class IncompatibleRepositories(BzrError):
777
_fmt = "%(target)s\n" \
778
"is not compatible with\n" \
687
_fmt = "Repository %(target)s is not compatible with repository"\
782
def __init__(self, source, target, details=None):
784
details = "(no details)"
785
BzrError.__init__(self, target=target, source=source, details=details)
690
def __init__(self, source, target):
691
BzrError.__init__(self, target=target, source=source)
788
694
class IncompatibleRevision(BzrError):
1105
1011
BzrError.__init__(self, branch=branch, revision=revision)
1014
# zero_ninetyone: this exception is no longer raised and should be removed
1015
class NotLeftParentDescendant(InternalBzrError):
1017
_fmt = ("Revision %(old_revision)s is not the left parent of"
1018
" %(new_revision)s, but branch %(branch_location)s expects this")
1020
def __init__(self, branch, old_revision, new_revision):
1021
BzrError.__init__(self, branch_location=branch.base,
1022
old_revision=old_revision,
1023
new_revision=new_revision)
1108
1026
class RangeInChangeOption(BzrError):
1110
1028
_fmt = "Option --change does not accept revision ranges"
1503
1424
self.details = details
1506
class UnexpectedProtocolVersionMarker(TransportError):
1508
_fmt = "Received bad protocol version marker: %(marker)r"
1510
def __init__(self, marker):
1511
self.marker = marker
1514
class UnknownSmartMethod(InternalBzrError):
1516
_fmt = "The server does not recognise the '%(verb)s' request."
1518
def __init__(self, verb):
1522
class SmartMessageHandlerError(InternalBzrError):
1524
_fmt = "The message handler raised an exception: %(exc_value)s."
1526
def __init__(self, exc_info):
1527
self.exc_type, self.exc_value, self.tb = exc_info
1530
1427
# A set of semi-meaningful errors which can be thrown
1531
1428
class TransportNotPossible(TransportError):
2291
2150
" Please set BZR_SSH environment variable.")
2294
class GhostRevisionsHaveNoRevno(BzrError):
2295
"""When searching for revnos, if we encounter a ghost, we are stuck"""
2297
_fmt = ("Could not determine revno for {%(revision_id)s} because"
2298
" its ancestry shows a ghost at {%(ghost_revision_id)s}")
2300
def __init__(self, revision_id, ghost_revision_id):
2301
self.revision_id = revision_id
2302
self.ghost_revision_id = ghost_revision_id
2305
2153
class GhostRevisionUnusableHere(BzrError):
2307
2155
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2633
2453
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2636
class UnsyncedBranches(BzrDirError):
2638
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2639
" bzr help sync-for-reconfigure.")
2641
def __init__(self, bzrdir, target_branch):
2642
BzrDirError.__init__(self, bzrdir)
2643
import bzrlib.urlutils as urlutils
2644
self.target_url = urlutils.unescape_for_display(target_branch.base,
2648
2456
class AlreadyBranch(BzrDirError):
2650
2458
_fmt = "'%(display_url)s' is already a branch."
2722
2515
path_str = repr(path)
2723
2516
path_str += ' '
2724
2517
self.path_str = path_str
2727
class UnsupportedTimezoneFormat(BzrError):
2729
_fmt = ('Unsupported timezone format "%(timezone)s", '
2730
'options are "utc", "original", "local".')
2732
def __init__(self, timezone):
2733
self.timezone = timezone
2736
class CommandAvailableInPlugin(StandardError):
2738
internal_error = False
2740
def __init__(self, cmd_name, plugin_metadata, provider):
2742
self.plugin_metadata = plugin_metadata
2743
self.cmd_name = cmd_name
2744
self.provider = provider
2748
_fmt = ('"%s" is not a standard bzr command. \n'
2749
'However, the following official plugin provides this command: %s\n'
2750
'You can install it by going to: %s'
2751
% (self.cmd_name, self.plugin_metadata['name'],
2752
self.plugin_metadata['url']))
2757
class NoPluginAvailable(BzrError):
2761
class NotATerminal(BzrError):
2763
_fmt = 'Unable to ask for a password without real terminal.'
2766
class UnableEncodePath(BzrError):
2768
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2769
'user encoding %(user_encoding)s')
2771
def __init__(self, path, kind):
2774
self.user_encoding = osutils.get_user_encoding()
2777
class NoSuchAlias(BzrError):
2779
_fmt = ('The alias "%(alias_name)s" does not exist.')
2781
def __init__(self, alias_name):
2782
BzrError.__init__(self, alias_name=alias_name)
2785
class DirectoryLookupFailure(BzrError):
2786
"""Base type for lookup errors."""
2791
class InvalidLocationAlias(DirectoryLookupFailure):
2793
_fmt = '"%(alias_name)s" is not a valid location alias.'
2795
def __init__(self, alias_name):
2796
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
2799
class UnsetLocationAlias(DirectoryLookupFailure):
2801
_fmt = 'No %(alias_name)s location assigned.'
2803
def __init__(self, alias_name):
2804
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2807
class CannotBindAddress(BzrError):
2809
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2811
def __init__(self, host, port, orig_error):
2812
BzrError.__init__(self, host=host, port=port,
2813
orig_error=orig_error[1])
2816
class UnknownRules(BzrError):
2818
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
2820
def __init__(self, unknowns):
2821
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2824
class HookFailed(BzrError):
2825
"""Raised when a pre_change_branch_tip hook function fails anything other
2826
than TipChangeRejected.
2829
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
2830
"%(traceback_text)s%(exc_value)s")
2832
def __init__(self, hook_stage, hook_name, exc_info):
2834
self.hook_stage = hook_stage
2835
self.hook_name = hook_name
2836
self.exc_info = exc_info
2837
self.exc_type = exc_info[0]
2838
self.exc_value = exc_info[1]
2839
self.exc_tb = exc_info[2]
2840
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2843
class TipChangeRejected(BzrError):
2844
"""A pre_change_branch_tip hook function may raise this to cleanly and
2845
explicitly abort a change to a branch tip.
2848
_fmt = u"Tip change rejected: %(msg)s"
2850
def __init__(self, msg):