100
108
# __str__() should always return a 'str' object
101
109
# never a 'unicode' object.
110
if isinstance(s, unicode):
111
return s.encode('utf8')
103
except Exception as e:
105
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
113
except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
114
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
115
% (self.__class__.__name__,
117
getattr(self, '_fmt', None),
120
def _get_format_string(self):
121
"""Return format string for this exception or None"""
122
fmt = getattr(self, '_fmt', None)
125
fmt = getattr(self, '__doc__', None)
127
symbol_versioning.warn("%s uses its docstring as a format, "
128
"it should use _fmt instead" % self.__class__.__name__,
131
return 'Unprintable exception %s: dict=%r, fmt=%r' \
106
132
% (self.__class__.__name__,
108
134
getattr(self, '_fmt', None),
115
return self._format().encode('utf-8')
117
__unicode__ = _format
120
return '%s(%s)' % (self.__class__.__name__, str(self))
122
def _get_format_string(self):
123
"""Return format string for this exception or None"""
124
fmt = getattr(self, '_fmt', None)
126
from breezy.i18n import gettext
127
return gettext(fmt) # _fmt strings should be ascii
129
def __eq__(self, other):
130
if self.__class__ is not other.__class__:
131
return NotImplemented
132
return self.__dict__ == other.__dict__
138
138
class InternalBzrError(BzrError):
146
146
internal_error = True
149
class BranchError(BzrError):
150
"""Base class for concrete 'errors about a branch'."""
152
def __init__(self, branch):
153
BzrError.__init__(self, branch=branch)
149
class BzrNewError(BzrError):
150
"""Deprecated error base class."""
151
# base classes should override the docstring with their human-
152
# readable explanation
154
def __init__(self, *args, **kwds):
155
# XXX: Use the underlying BzrError to always generate the args
156
# attribute if it doesn't exist. We can't use super here, because
157
# exceptions are old-style classes in python2.4 (but new in 2.5).
159
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
160
'please convert %s to use BzrError instead'
161
% self.__class__.__name__,
164
BzrError.__init__(self, *args)
165
for key, value in kwds.items():
166
setattr(self, key, value)
170
# __str__() should always return a 'str' object
171
# never a 'unicode' object.
172
s = self.__doc__ % self.__dict__
173
if isinstance(s, unicode):
174
return s.encode('utf8')
176
except (TypeError, NameError, ValueError, KeyError), e:
177
return 'Unprintable exception %s(%r): %r' \
178
% (self.__class__.__name__,
182
class AlreadyBuilding(BzrError):
184
_fmt = "The tree builder is already building a tree."
156
187
class BzrCheckError(InternalBzrError):
304
362
self.not_locked = not_locked
365
class BzrOptionError(BzrCommandError):
367
_fmt = "Error in command line options"
370
class BadIndexFormatSignature(BzrError):
372
_fmt = "%(value)s is not an index of type %(_type)s."
374
def __init__(self, value, _type):
375
BzrError.__init__(self)
380
class BadIndexData(BzrError):
382
_fmt = "Error in data for index %(value)s."
384
def __init__(self, value):
385
BzrError.__init__(self)
389
class BadIndexDuplicateKey(BzrError):
391
_fmt = "The key '%(key)s' is already in index '%(index)s'."
393
def __init__(self, key, index):
394
BzrError.__init__(self)
399
class BadIndexKey(BzrError):
401
_fmt = "The key '%(key)s' is not a valid key."
403
def __init__(self, key):
404
BzrError.__init__(self)
408
class BadIndexOptions(BzrError):
410
_fmt = "Could not parse options for index %(value)s."
412
def __init__(self, value):
413
BzrError.__init__(self)
417
class BadIndexValue(BzrError):
419
_fmt = "The value '%(value)s' is not a valid value."
421
def __init__(self, value):
422
BzrError.__init__(self)
426
class BadOptionValue(BzrError):
428
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
430
def __init__(self, name, value):
431
BzrError.__init__(self, name=name, value=value)
307
434
class StrictCommitFailed(BzrError):
309
436
_fmt = "Commit refused because there are unknown files in the tree"
395
517
_fmt = 'Permission denied: "%(path)s"%(extra)s'
398
class UnavailableRepresentation(InternalBzrError):
400
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
401
"is encoded as '%(native)s'.")
403
def __init__(self, key, wanted, native):
404
InternalBzrError.__init__(self)
520
class InvalidURL(PathError):
522
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
525
class InvalidURLJoin(PathError):
527
_fmt = 'Invalid URL join request: "%(args)s"%(extra)s'
529
def __init__(self, msg, base, args):
530
PathError.__init__(self, base, msg)
531
self.args = [base] + list(args)
534
class UnknownHook(BzrError):
536
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
538
def __init__(self, hook_type, hook_name):
539
BzrError.__init__(self)
540
self.type = hook_type
541
self.hook = hook_name
410
544
class UnsupportedProtocol(PathError):
412
546
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
414
def __init__(self, url, extra=""):
548
def __init__(self, url, extra):
415
549
PathError.__init__(self, url, extra=extra)
418
class UnstackableLocationError(BzrError):
420
_fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
422
def __init__(self, branch_url, target_url):
423
BzrError.__init__(self)
424
self.branch_url = branch_url
425
self.target_url = target_url
428
class UnstackableRepositoryFormat(BzrError):
430
_fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
431
"You will need to upgrade the repository to permit branch stacking.")
433
def __init__(self, format, url):
434
BzrError.__init__(self)
439
552
class ReadError(PathError):
441
554
_fmt = """Error reading from %(path)r."""
479
592
# TODO: This is given a URL; we try to unescape it but doing that from inside
480
593
# the exception object is a bit undesirable.
481
# TODO: Probably this behavior of should be a common superclass
594
# TODO: Probably this behavior of should be a common superclass
482
595
class NotBranchError(PathError):
484
_fmt = 'Not a branch: "%(path)s"%(detail)s.'
486
def __init__(self, path, detail=None, controldir=None):
487
from . import urlutils
488
path = urlutils.unescape_for_display(path, 'ascii')
489
if detail is not None:
490
detail = ': ' + detail
492
self.controldir = controldir
493
PathError.__init__(self, path=path)
496
return '<%s %r>' % (self.__class__.__name__, self.__dict__)
498
def _get_format_string(self):
499
# GZ 2017-06-08: Not the best place to lazy fill detail in.
500
if self.detail is None:
501
self.detail = self._get_detail()
502
return super(NotBranchError, self)._get_format_string()
504
def _get_detail(self):
505
if self.controldir is not None:
507
self.controldir.open_repository()
508
except NoRepositoryPresent:
510
except Exception as e:
511
# Just ignore unexpected errors. Raising arbitrary errors
512
# during str(err) can provoke strange bugs. Concretely
513
# Launchpad's codehosting managed to raise NotBranchError
514
# here, and then get stuck in an infinite loop/recursion
515
# trying to str() that error. All this error really cares
516
# about that there's no working repository there, and if
517
# open_repository() fails, there probably isn't.
518
return ': ' + e.__class__.__name__
520
return ': location is a repository'
597
_fmt = 'Not a branch: "%(path)s".'
599
def __init__(self, path):
600
import bzrlib.urlutils as urlutils
601
self.path = urlutils.unescape_for_display(path, 'ascii')
524
604
class NoSubmitBranch(PathError):
583
644
class NoRepositoryPresent(BzrError):
585
646
_fmt = 'No repository present: "%(path)s"'
586
def __init__(self, controldir):
587
BzrError.__init__(self)
588
self.path = controldir.transport.clone('..').base
647
def __init__(self, bzrdir):
648
BzrError.__init__(self)
649
self.path = bzrdir.transport.clone('..').base
652
class FileInWrongBranch(BzrError):
654
_fmt = 'File "%(path)s" in not in branch %(branch_base)s.'
656
def __init__(self, branch, path):
657
BzrError.__init__(self)
659
self.branch_base = branch.base
591
663
class UnsupportedFormatError(BzrError):
593
_fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
665
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
596
668
class UnknownFormatError(BzrError):
598
_fmt = "Unknown %(kind)s format: %(format)r"
600
def __init__(self, format, kind='branch'):
670
_fmt = "Unknown branch format: %(format)r"
605
673
class IncompatibleFormat(BzrError):
607
_fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
609
def __init__(self, format, controldir_format):
610
BzrError.__init__(self)
612
self.controldir = controldir_format
615
class ParseFormatError(BzrError):
617
_fmt = "Parse error on line %(lineno)d of %(format)s format: %(line)s"
619
def __init__(self, format, lineno, line, text):
620
BzrError.__init__(self)
675
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
677
def __init__(self, format, bzrdir_format):
678
BzrError.__init__(self)
680
self.bzrdir = bzrdir_format
627
683
class IncompatibleRepositories(BzrError):
628
"""Report an error that two repositories are not compatible.
630
Note that the source and target repositories are permitted to be strings:
631
this exception is thrown from the smart server and may refer to a
632
repository the client hasn't opened.
635
_fmt = "%(target)s\n" \
636
"is not compatible with\n" \
640
def __init__(self, source, target, details=None):
642
details = "(no details)"
643
BzrError.__init__(self, target=target, source=source, details=details)
685
_fmt = "Repository %(target)s is not compatible with repository"\
688
def __init__(self, source, target):
689
BzrError.__init__(self, target=target, source=source)
646
692
class IncompatibleRevision(BzrError):
648
694
_fmt = "Revision is not compatible with %(repo_format)s"
650
696
def __init__(self, repo_format):
1116
1211
self.error = error
1214
class WeaveError(BzrError):
1216
_fmt = "Error in processing weave: %(msg)s"
1218
def __init__(self, msg=None):
1219
BzrError.__init__(self)
1223
class WeaveRevisionAlreadyPresent(WeaveError):
1225
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1227
def __init__(self, revision_id, weave):
1229
WeaveError.__init__(self)
1230
self.revision_id = revision_id
1234
class WeaveRevisionNotPresent(WeaveError):
1236
_fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1238
def __init__(self, revision_id, weave):
1239
WeaveError.__init__(self)
1240
self.revision_id = revision_id
1244
class WeaveFormatError(WeaveError):
1246
_fmt = "Weave invariant violated: %(what)s"
1248
def __init__(self, what):
1249
WeaveError.__init__(self)
1253
class WeaveParentMismatch(WeaveError):
1255
_fmt = "Parents are mismatched between two revisions. %(message)s"
1258
class WeaveInvalidChecksum(WeaveError):
1260
_fmt = "Text did not match it's checksum: %(message)s"
1263
class WeaveTextDiffers(WeaveError):
1265
_fmt = ("Weaves differ on text content. Revision:"
1266
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1268
def __init__(self, revision_id, weave_a, weave_b):
1269
WeaveError.__init__(self)
1270
self.revision_id = revision_id
1271
self.weave_a = weave_a
1272
self.weave_b = weave_b
1275
class WeaveTextDiffers(WeaveError):
1277
_fmt = ("Weaves differ on text content. Revision:"
1278
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1280
def __init__(self, revision_id, weave_a, weave_b):
1281
WeaveError.__init__(self)
1282
self.revision_id = revision_id
1283
self.weave_a = weave_a
1284
self.weave_b = weave_b
1119
1287
class VersionedFileError(BzrError):
1121
1289
_fmt = "Versioned file error"
1124
1292
class RevisionNotPresent(VersionedFileError):
1126
1294
_fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1128
1296
def __init__(self, revision_id, file_id):
1144
1312
class VersionedFileInvalidChecksum(VersionedFileError):
1146
_fmt = "Text did not match its checksum: %(msg)s"
1149
class RetryWithNewPacks(BzrError):
1150
"""Raised when we realize that the packs on disk have changed.
1152
This is meant as more of a signaling exception, to trap between where a
1153
local error occurred and the code that can actually handle the error and
1154
code that can retry appropriately.
1157
internal_error = True
1159
_fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1162
def __init__(self, context, reload_occurred, exc_info):
1163
"""create a new RetryWithNewPacks error.
1165
:param reload_occurred: Set to True if we know that the packs have
1166
already been reloaded, and we are failing because of an in-memory
1167
cache miss. If set to True then we will ignore if a reload says
1168
nothing has changed, because we assume it has already reloaded. If
1169
False, then a reload with nothing changed will force an error.
1170
:param exc_info: The original exception traceback, so if there is a
1171
problem we can raise the original error (value from sys.exc_info())
1173
BzrError.__init__(self)
1174
self.context = context
1175
self.reload_occurred = reload_occurred
1176
self.exc_info = exc_info
1177
self.orig_error = exc_info[1]
1178
# TODO: The global error handler should probably treat this by
1179
# raising/printing the original exception with a bit about
1180
# RetryWithNewPacks also not being caught
1183
class RetryAutopack(RetryWithNewPacks):
1184
"""Raised when we are autopacking and we find a missing file.
1186
Meant as a signaling exception, to tell the autopack code it should try
1190
internal_error = True
1192
_fmt = ("Pack files have changed, reload and try autopack again."
1193
" context: %(context)s %(orig_error)s")
1314
_fmt = "Text did not match its checksum: %(message)s"
1317
class KnitError(InternalBzrError):
1322
class KnitCorrupt(KnitError):
1324
_fmt = "Knit %(filename)s corrupt: %(how)s"
1326
def __init__(self, filename, how):
1327
KnitError.__init__(self)
1328
self.filename = filename
1332
class KnitDataStreamIncompatible(KnitError):
1334
_fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
1336
def __init__(self, stream_format, target_format):
1337
self.stream_format = stream_format
1338
self.target_format = target_format
1341
class KnitHeaderError(KnitError):
1343
_fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
1345
def __init__(self, badline, filename):
1346
KnitError.__init__(self)
1347
self.badline = badline
1348
self.filename = filename
1350
class KnitIndexUnknownMethod(KnitError):
1351
"""Raised when we don't understand the storage method.
1353
Currently only 'fulltext' and 'line-delta' are supported.
1356
_fmt = ("Knit index %(filename)s does not have a known method"
1357
" in options: %(options)r")
1359
def __init__(self, filename, options):
1360
KnitError.__init__(self)
1361
self.filename = filename
1362
self.options = options
1196
1365
class NoSuchExportFormat(BzrError):
1198
1367
_fmt = "Export format %(format)r not supported"
1200
1369
def __init__(self, format):
1297
1435
self.port = ':%s' % port
1300
# XXX: This is also used for unexpected end of file, which is different at the
1301
# TCP level from "connection reset".
1302
1438
class ConnectionReset(TransportError):
1304
1440
_fmt = "Connection closed: %(msg)s %(orig_error)s"
1307
class ConnectionTimeout(ConnectionError):
1309
_fmt = "Connection Timeout: %(msg)s%(orig_error)s"
1312
1443
class InvalidRange(TransportError):
1314
_fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1316
def __init__(self, path, offset, msg=None):
1317
TransportError.__init__(self, msg)
1445
_fmt = "Invalid range access in %(path)s at %(offset)s."
1447
def __init__(self, path, offset):
1448
TransportError.__init__(self, ("Invalid range access in %s at %d"
1318
1450
self.path = path
1319
1451
self.offset = offset
1322
1454
class InvalidHttpResponse(TransportError):
1324
_fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1456
_fmt = "Invalid http response for %(path)s: %(msg)s"
1326
1458
def __init__(self, path, msg, orig_error=None):
1327
1459
self.path = path
1328
if orig_error is None:
1331
# This is reached for obscure and unusual errors so we want to
1332
# preserve as much info as possible to ease debug.
1333
orig_error = ': %r' % (orig_error,)
1334
1460
TransportError.__init__(self, msg, orig_error=orig_error)
1337
1463
class InvalidHttpRange(InvalidHttpResponse):
1339
1465
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1341
1467
def __init__(self, path, range, msg):
1342
1468
self.range = range
1343
1469
InvalidHttpResponse.__init__(self, path, msg)
1346
class HttpBoundaryMissing(InvalidHttpResponse):
1347
"""A multipart response ends with no boundary marker.
1349
This is a special case caused by buggy proxies, described in
1350
<https://bugs.launchpad.net/bzr/+bug/198646>.
1353
_fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1355
def __init__(self, path, msg):
1356
InvalidHttpResponse.__init__(self, path, msg)
1359
1472
class InvalidHttpContentType(InvalidHttpResponse):
1361
1474
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1363
1476
def __init__(self, path, ctype, msg):
1364
1477
self.ctype = ctype
1365
1478
InvalidHttpResponse.__init__(self, path, msg)
1370
1483
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1372
def __init__(self, source, target, is_permanent=False):
1485
def __init__(self, source, target, is_permanent=False, qual_proto=None):
1373
1486
self.source = source
1374
1487
self.target = target
1375
1488
if is_permanent:
1376
1489
self.permanently = ' permanently'
1378
1491
self.permanently = ''
1492
self._qualified_proto = qual_proto
1379
1493
TransportError.__init__(self)
1495
def _requalify_url(self, url):
1496
"""Restore the qualified proto in front of the url"""
1497
# When this exception is raised, source and target are in
1498
# user readable format. But some transports may use a
1499
# different proto (http+urllib:// will present http:// to
1500
# the user. If a qualified proto is specified, the code
1501
# trapping the exception can get the qualified urls to
1502
# properly handle the redirection themself (creating a
1503
# new transport object from the target url for example).
1504
# But checking that the scheme of the original and
1505
# redirected urls are the same can be tricky. (see the
1506
# FIXME in BzrDir.open_from_transport for the unique use
1508
if self._qualified_proto is None:
1511
# The TODO related to NotBranchError mention that doing
1512
# that kind of manipulation on the urls may not be the
1513
# exception object job. On the other hand, this object is
1514
# the interface between the code and the user so
1515
# presenting the urls in different ways is indeed its
1518
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1519
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1522
def get_source_url(self):
1523
return self._requalify_url(self.source)
1525
def get_target_url(self):
1526
return self._requalify_url(self.target)
1382
1529
class TooManyRedirections(TransportError):
2269
2358
self.reason = reason
2361
class SMTPError(BzrError):
2363
_fmt = "SMTP error: %(error)s"
2365
def __init__(self, error):
2369
class NoMessageSupplied(BzrError):
2371
_fmt = "No message supplied."
2374
class UnknownMailClient(BzrError):
2376
_fmt = "Unknown mail client: %(mail_client)s"
2378
def __init__(self, mail_client):
2379
BzrError.__init__(self, mail_client=mail_client)
2382
class MailClientNotFound(BzrError):
2384
_fmt = "Unable to find mail client with the following names:"\
2385
" %(mail_command_list_string)s"
2387
def __init__(self, mail_command_list):
2388
mail_command_list_string = ', '.join(mail_command_list)
2389
BzrError.__init__(self, mail_command_list=mail_command_list,
2390
mail_command_list_string=mail_command_list_string)
2392
class SMTPConnectionRefused(SMTPError):
2394
_fmt = "SMTP connection to %(host)s refused"
2396
def __init__(self, error, host):
2401
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2403
_fmt = "Please specify smtp_server. No server at default %(host)s."
2406
class BzrDirError(BzrError):
2408
def __init__(self, bzrdir):
2409
import bzrlib.urlutils as urlutils
2410
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2412
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2415
class AlreadyBranch(BzrDirError):
2417
_fmt = "'%(display_url)s' is already a branch."
2420
class AlreadyTree(BzrDirError):
2422
_fmt = "'%(display_url)s' is already a tree."
2425
class AlreadyCheckout(BzrDirError):
2427
_fmt = "'%(display_url)s' is already a checkout."
2430
class ReconfigurationNotSupported(BzrDirError):
2432
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2435
class NoBindLocation(BzrDirError):
2437
_fmt = "No location could be found to bind to at %(display_url)s."
2272
2440
class UncommittedChanges(BzrError):
2274
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2275
' (See brz status).%(more)s')
2277
def __init__(self, tree, more=None):
2282
import breezy.urlutils as urlutils
2283
user_url = getattr(tree, "user_url", None)
2284
if user_url is None:
2285
display_url = str(tree)
2287
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2288
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2291
class StoringUncommittedNotSupported(BzrError):
2293
_fmt = ('Branch "%(display_url)s" does not support storing uncommitted'
2296
def __init__(self, branch):
2297
import breezy.urlutils as urlutils
2298
user_url = getattr(branch, "user_url", None)
2299
if user_url is None:
2300
display_url = str(branch)
2302
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2303
BzrError.__init__(self, branch=branch, display_url=display_url)
2306
class ShelvedChanges(UncommittedChanges):
2308
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2309
' (See brz shelve --list).%(more)s')
2312
class UnableCreateSymlink(BzrError):
2314
_fmt = 'Unable to create symlink %(path_str)son this platform'
2316
def __init__(self, path=None):
2320
path_str = repr(str(path))
2321
except UnicodeEncodeError:
2322
path_str = repr(path)
2324
self.path_str = path_str
2327
class UnableEncodePath(BzrError):
2329
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2330
'user encoding %(user_encoding)s')
2332
def __init__(self, path, kind):
2333
from breezy.osutils import get_user_encoding
2336
self.user_encoding = get_user_encoding()
2339
class NoSuchAlias(BzrError):
2341
_fmt = ('The alias "%(alias_name)s" does not exist.')
2343
def __init__(self, alias_name):
2344
BzrError.__init__(self, alias_name=alias_name)
2347
class CannotBindAddress(BzrError):
2349
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2351
def __init__(self, host, port, orig_error):
2352
# nb: in python2.4 socket.error doesn't have a useful repr
2353
BzrError.__init__(self, host=host, port=port,
2354
orig_error=repr(orig_error.args))
2357
class TipChangeRejected(BzrError):
2358
"""A pre_change_branch_tip hook function may raise this to cleanly and
2359
explicitly abort a change to a branch tip.
2362
_fmt = u"Tip change rejected: %(msg)s"
2364
def __init__(self, msg):
2368
class JailBreak(BzrError):
2370
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2372
def __init__(self, url):
2373
BzrError.__init__(self, url=url)
2376
class UserAbort(BzrError):
2378
_fmt = 'The user aborted the operation.'
2381
class UnresumableWriteGroup(BzrError):
2383
_fmt = ("Repository %(repository)s cannot resume write group "
2384
"%(write_groups)r: %(reason)s")
2386
internal_error = True
2388
def __init__(self, repository, write_groups, reason):
2389
self.repository = repository
2390
self.write_groups = write_groups
2391
self.reason = reason
2394
class UnsuspendableWriteGroup(BzrError):
2396
_fmt = ("Repository %(repository)s cannot suspend a write group.")
2398
internal_error = True
2400
def __init__(self, repository):
2401
self.repository = repository
2404
class LossyPushToSameVCS(BzrError):
2406
_fmt = ("Lossy push not possible between %(source_branch)r and "
2407
"%(target_branch)r that are in the same VCS.")
2409
internal_error = True
2411
def __init__(self, source_branch, target_branch):
2412
self.source_branch = source_branch
2413
self.target_branch = target_branch
2416
class NoRoundtrippingSupport(BzrError):
2418
_fmt = ("Roundtripping is not supported between %(source_branch)r and "
2419
"%(target_branch)r.")
2421
internal_error = True
2423
def __init__(self, source_branch, target_branch):
2424
self.source_branch = source_branch
2425
self.target_branch = target_branch
2428
class NoColocatedBranchSupport(BzrError):
2430
_fmt = ("%(controldir)r does not support co-located branches.")
2432
def __init__(self, controldir):
2433
self.controldir = controldir
2436
class RecursiveBind(BzrError):
2438
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2439
'Please use `brz unbind` to fix.')
2441
def __init__(self, branch_url):
2442
self.branch_url = branch_url
2445
class UnsupportedKindChange(BzrError):
2447
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2448
"%(path)s not supported by format %(format)r")
2450
def __init__(self, path, from_kind, to_kind, format):
2452
self.from_kind = from_kind
2453
self.to_kind = to_kind
2454
self.format = format
2457
class ChangesAlreadyStored(BzrCommandError):
2459
_fmt = ('Cannot store uncommitted changes because this branch already'
2460
' stores uncommitted changes.')
2442
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2444
def __init__(self, tree):
2445
import bzrlib.urlutils as urlutils
2446
display_url = urlutils.unescape_for_display(
2447
tree.bzrdir.root_transport.base, 'ascii')
2448
BzrError.__init__(self, tree=tree, display_url=display_url)