1226
1509
class InvalidHttpContentType(InvalidHttpResponse):
1228
1511
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1230
1513
def __init__(self, path, ctype, msg):
1231
1514
self.ctype = ctype
1232
1515
InvalidHttpResponse.__init__(self, path, msg)
1518
class RedirectRequested(TransportError):
1520
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1522
def __init__(self, source, target, is_permanent=False, qual_proto=None):
1523
self.source = source
1524
self.target = target
1526
self.permanently = ' permanently'
1528
self.permanently = ''
1529
self._qualified_proto = qual_proto
1530
TransportError.__init__(self)
1532
def _requalify_url(self, url):
1533
"""Restore the qualified proto in front of the url"""
1534
# When this exception is raised, source and target are in
1535
# user readable format. But some transports may use a
1536
# different proto (http+urllib:// will present http:// to
1537
# the user. If a qualified proto is specified, the code
1538
# trapping the exception can get the qualified urls to
1539
# properly handle the redirection themself (creating a
1540
# new transport object from the target url for example).
1541
# But checking that the scheme of the original and
1542
# redirected urls are the same can be tricky. (see the
1543
# FIXME in BzrDir.open_from_transport for the unique use
1545
if self._qualified_proto is None:
1548
# The TODO related to NotBranchError mention that doing
1549
# that kind of manipulation on the urls may not be the
1550
# exception object job. On the other hand, this object is
1551
# the interface between the code and the user so
1552
# presenting the urls in different ways is indeed its
1555
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1556
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1559
def get_source_url(self):
1560
return self._requalify_url(self.source)
1562
def get_target_url(self):
1563
return self._requalify_url(self.target)
1566
class TooManyRedirections(TransportError):
1568
_fmt = "Too many redirections"
1235
1571
class ConflictsInTree(BzrError):
1237
1573
_fmt = "Working tree has conflicts."
1771
2225
self.extra = ''
1774
class InvalidImportLine(BzrError):
2228
class InvalidImportLine(InternalBzrError):
1776
2230
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
1778
internal_error = True
1780
2232
def __init__(self, text, msg):
1781
2233
BzrError.__init__(self)
1782
2234
self.text = text
1786
class ImportNameCollision(BzrError):
1788
_fmt = "Tried to import an object to the same name as an existing object. %(name)s"
1790
internal_error = True
1792
def __init__(self, name):
1793
BzrError.__init__(self)
2238
class ImportNameCollision(InternalBzrError):
2240
_fmt = ("Tried to import an object to the same name as"
2241
" an existing object. %(name)s")
2243
def __init__(self, name):
2244
BzrError.__init__(self)
2248
class NotAMergeDirective(BzrError):
2249
"""File starting with %(firstline)r is not a merge directive"""
2250
def __init__(self, firstline):
2251
BzrError.__init__(self, firstline=firstline)
2254
class NoMergeSource(BzrError):
2255
"""Raise if no merge source was specified for a merge directive"""
2257
_fmt = "A merge directive must provide either a bundle or a public"\
2261
class IllegalMergeDirectivePayload(BzrError):
2262
"""A merge directive contained something other than a patch or bundle"""
2264
_fmt = "Bad merge directive payload %(start)r"
2266
def __init__(self, start):
2271
class PatchVerificationFailed(BzrError):
2272
"""A patch from a merge directive could not be verified"""
2274
_fmt = "Preview patch does not match requested changes."
2277
class PatchMissing(BzrError):
2278
"""Raise a patch type was specified but no patch supplied"""
2280
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2282
def __init__(self, patch_type):
2283
BzrError.__init__(self)
2284
self.patch_type = patch_type
2287
class UnsupportedInventoryKind(BzrError):
2289
_fmt = """Unsupported entry kind %(kind)s"""
2291
def __init__(self, kind):
2295
class BadSubsumeSource(BzrError):
2297
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2299
def __init__(self, tree, other_tree, reason):
2301
self.other_tree = other_tree
2302
self.reason = reason
2305
class SubsumeTargetNeedsUpgrade(BzrError):
2307
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2309
def __init__(self, other_tree):
2310
self.other_tree = other_tree
2313
class BadReferenceTarget(InternalBzrError):
2315
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2318
def __init__(self, tree, other_tree, reason):
2320
self.other_tree = other_tree
2321
self.reason = reason
2324
class NoSuchTag(BzrError):
2326
_fmt = "No such tag: %(tag_name)s"
2328
def __init__(self, tag_name):
2329
self.tag_name = tag_name
2332
class TagsNotSupported(BzrError):
2334
_fmt = ("Tags not supported by %(branch)s;"
2335
" you may be able to use bzr upgrade --dirstate-tags.")
2337
def __init__(self, branch):
2338
self.branch = branch
2341
class TagAlreadyExists(BzrError):
2343
_fmt = "Tag %(tag_name)s already exists."
2345
def __init__(self, tag_name):
2346
self.tag_name = tag_name
2349
class MalformedBugIdentifier(BzrError):
2351
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2353
def __init__(self, bug_id, reason):
2354
self.bug_id = bug_id
2355
self.reason = reason
2358
class InvalidBugTrackerURL(BzrError):
2360
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2361
"contain {id}: %(url)s")
2363
def __init__(self, abbreviation, url):
2364
self.abbreviation = abbreviation
2368
class UnknownBugTrackerAbbreviation(BzrError):
2370
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2373
def __init__(self, abbreviation, branch):
2374
self.abbreviation = abbreviation
2375
self.branch = branch
2378
class UnexpectedSmartServerResponse(BzrError):
2380
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2382
def __init__(self, response_tuple):
2383
self.response_tuple = response_tuple
2386
class ContainerError(BzrError):
2387
"""Base class of container errors."""
2390
class UnknownContainerFormatError(ContainerError):
2392
_fmt = "Unrecognised container format: %(container_format)r"
2394
def __init__(self, container_format):
2395
self.container_format = container_format
2398
class UnexpectedEndOfContainerError(ContainerError):
2400
_fmt = "Unexpected end of container stream"
2403
class UnknownRecordTypeError(ContainerError):
2405
_fmt = "Unknown record type: %(record_type)r"
2407
def __init__(self, record_type):
2408
self.record_type = record_type
2411
class InvalidRecordError(ContainerError):
2413
_fmt = "Invalid record: %(reason)s"
2415
def __init__(self, reason):
2416
self.reason = reason
2419
class ContainerHasExcessDataError(ContainerError):
2421
_fmt = "Container has data after end marker: %(excess)r"
2423
def __init__(self, excess):
2424
self.excess = excess
2427
class DuplicateRecordNameError(ContainerError):
2429
_fmt = "Container has multiple records with the same name: %(name)s"
2431
def __init__(self, name):
2435
class NoDestinationAddress(InternalBzrError):
2437
_fmt = "Message does not have a destination address."
2440
class RepositoryDataStreamError(BzrError):
2442
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2444
def __init__(self, reason):
2445
self.reason = reason
2448
class SMTPError(BzrError):
2450
_fmt = "SMTP error: %(error)s"
2452
def __init__(self, error):
2456
class NoMessageSupplied(BzrError):
2458
_fmt = "No message supplied."
2461
class NoMailAddressSpecified(BzrError):
2463
_fmt = "No mail-to address specified."
2466
class UnknownMailClient(BzrError):
2468
_fmt = "Unknown mail client: %(mail_client)s"
2470
def __init__(self, mail_client):
2471
BzrError.__init__(self, mail_client=mail_client)
2474
class MailClientNotFound(BzrError):
2476
_fmt = "Unable to find mail client with the following names:"\
2477
" %(mail_command_list_string)s"
2479
def __init__(self, mail_command_list):
2480
mail_command_list_string = ', '.join(mail_command_list)
2481
BzrError.__init__(self, mail_command_list=mail_command_list,
2482
mail_command_list_string=mail_command_list_string)
2484
class SMTPConnectionRefused(SMTPError):
2486
_fmt = "SMTP connection to %(host)s refused"
2488
def __init__(self, error, host):
2493
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2495
_fmt = "Please specify smtp_server. No server at default %(host)s."
2498
class BzrDirError(BzrError):
2500
def __init__(self, bzrdir):
2501
import bzrlib.urlutils as urlutils
2502
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2504
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2507
class AlreadyBranch(BzrDirError):
2509
_fmt = "'%(display_url)s' is already a branch."
2512
class AlreadyTree(BzrDirError):
2514
_fmt = "'%(display_url)s' is already a tree."
2517
class AlreadyCheckout(BzrDirError):
2519
_fmt = "'%(display_url)s' is already a checkout."
2522
class AlreadyLightweightCheckout(BzrDirError):
2524
_fmt = "'%(display_url)s' is already a lightweight checkout."
2527
class ReconfigurationNotSupported(BzrDirError):
2529
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2532
class NoBindLocation(BzrDirError):
2534
_fmt = "No location could be found to bind to at %(display_url)s."
2537
class UncommittedChanges(BzrError):
2539
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2541
def __init__(self, tree):
2542
import bzrlib.urlutils as urlutils
2543
display_url = urlutils.unescape_for_display(
2544
tree.bzrdir.root_transport.base, 'ascii')
2545
BzrError.__init__(self, tree=tree, display_url=display_url)
2548
class MissingTemplateVariable(BzrError):
2550
_fmt = 'Variable {%(name)s} is not available.'
2552
def __init__(self, name):
2556
class NoTemplate(BzrError):
2558
_fmt = 'No template specified.'
2561
class UnableCreateSymlink(BzrError):
2563
_fmt = 'Unable to create symlink %(path_str)son this platform'
2565
def __init__(self, path=None):
2569
path_str = repr(str(path))
2570
except UnicodeEncodeError:
2571
path_str = repr(path)
2573
self.path_str = path_str
2576
class UnsupportedTimezoneFormat(BzrError):
2578
_fmt = ('Unsupported timezone format "%(timezone)s", '
2579
'options are "utc", "original", "local".')
2581
def __init__(self, timezone):
2582
self.timezone = timezone
2585
class UnableEncodePath(BzrError):
2587
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2588
'user encoding %(user_encoding)s')
2590
def __init__(self, path, kind):
2593
self.user_encoding = osutils.get_user_encoding()