357
509
class NotADirectory(PathError):
359
_fmt = "%(path)r is not a directory %(extra)s"
511
_fmt = '"%(path)s" is not a directory %(extra)s'
362
514
class NotInWorkingDirectory(PathError):
364
_fmt = "%(path)r is not in the working directory %(extra)s"
516
_fmt = '"%(path)s" is not in the working directory %(extra)s'
367
519
class DirectoryNotEmpty(PathError):
369
_fmt = "Directory not empty: %(path)r%(extra)s"
372
class ReadingCompleted(BzrError):
521
_fmt = 'Directory not empty: "%(path)s"%(extra)s'
524
class HardLinkNotSupported(PathError):
526
_fmt = 'Hard-linking "%(path)s" is not supported'
529
class ReadingCompleted(InternalBzrError):
374
531
_fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
375
532
"called upon it - the request has been completed and no more "
376
533
"data may be read.")
378
internal_error = True
380
535
def __init__(self, request):
381
536
self.request = request
384
539
class ResourceBusy(PathError):
386
_fmt = "Device or resource busy: %(path)r%(extra)s"
541
_fmt = 'Device or resource busy: "%(path)s"%(extra)s'
389
544
class PermissionDenied(PathError):
391
_fmt = "Permission denied: %(path)r%(extra)s"
546
_fmt = 'Permission denied: "%(path)s"%(extra)s'
394
549
class InvalidURL(PathError):
396
_fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
551
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
399
554
class InvalidURLJoin(PathError):
401
_fmt = "Invalid URL join request: %(args)s%(extra)s"
556
_fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r"
403
def __init__(self, msg, base, args):
404
PathError.__init__(self, base, msg)
405
self.args = [base] + list(args)
558
def __init__(self, reason, base, join_args):
561
self.join_args = join_args
562
PathError.__init__(self, base, reason)
408
565
class UnknownHook(BzrError):
1226
1550
class InvalidHttpContentType(InvalidHttpResponse):
1228
1552
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1230
1554
def __init__(self, path, ctype, msg):
1231
1555
self.ctype = ctype
1232
1556
InvalidHttpResponse.__init__(self, path, msg)
1559
class RedirectRequested(TransportError):
1561
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1563
def __init__(self, source, target, is_permanent=False, qual_proto=None):
1564
self.source = source
1565
self.target = target
1567
self.permanently = ' permanently'
1569
self.permanently = ''
1570
self._qualified_proto = qual_proto
1571
TransportError.__init__(self)
1573
def _requalify_url(self, url):
1574
"""Restore the qualified proto in front of the url"""
1575
# When this exception is raised, source and target are in
1576
# user readable format. But some transports may use a
1577
# different proto (http+urllib:// will present http:// to
1578
# the user. If a qualified proto is specified, the code
1579
# trapping the exception can get the qualified urls to
1580
# properly handle the redirection themself (creating a
1581
# new transport object from the target url for example).
1582
# But checking that the scheme of the original and
1583
# redirected urls are the same can be tricky. (see the
1584
# FIXME in BzrDir.open_from_transport for the unique use
1586
if self._qualified_proto is None:
1589
# The TODO related to NotBranchError mention that doing
1590
# that kind of manipulation on the urls may not be the
1591
# exception object job. On the other hand, this object is
1592
# the interface between the code and the user so
1593
# presenting the urls in different ways is indeed its
1596
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1597
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1600
def get_source_url(self):
1601
return self._requalify_url(self.source)
1603
def get_target_url(self):
1604
return self._requalify_url(self.target)
1607
class TooManyRedirections(TransportError):
1609
_fmt = "Too many redirections"
1235
1612
class ConflictsInTree(BzrError):
1237
1614
_fmt = "Working tree has conflicts."
1771
2272
self.extra = ''
1774
class InvalidImportLine(BzrError):
2275
class InvalidImportLine(InternalBzrError):
1776
2277
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
1778
internal_error = True
1780
2279
def __init__(self, text, msg):
1781
2280
BzrError.__init__(self)
1782
2281
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)
2285
class ImportNameCollision(InternalBzrError):
2287
_fmt = ("Tried to import an object to the same name as"
2288
" an existing object. %(name)s")
2290
def __init__(self, name):
2291
BzrError.__init__(self)
2295
class NotAMergeDirective(BzrError):
2296
"""File starting with %(firstline)r is not a merge directive"""
2297
def __init__(self, firstline):
2298
BzrError.__init__(self, firstline=firstline)
2301
class NoMergeSource(BzrError):
2302
"""Raise if no merge source was specified for a merge directive"""
2304
_fmt = "A merge directive must provide either a bundle or a public"\
2308
class IllegalMergeDirectivePayload(BzrError):
2309
"""A merge directive contained something other than a patch or bundle"""
2311
_fmt = "Bad merge directive payload %(start)r"
2313
def __init__(self, start):
2318
class PatchVerificationFailed(BzrError):
2319
"""A patch from a merge directive could not be verified"""
2321
_fmt = "Preview patch does not match requested changes."
2324
class PatchMissing(BzrError):
2325
"""Raise a patch type was specified but no patch supplied"""
2327
_fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2329
def __init__(self, patch_type):
2330
BzrError.__init__(self)
2331
self.patch_type = patch_type
2334
class UnsupportedInventoryKind(BzrError):
2336
_fmt = """Unsupported entry kind %(kind)s"""
2338
def __init__(self, kind):
2342
class BadSubsumeSource(BzrError):
2344
_fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2346
def __init__(self, tree, other_tree, reason):
2348
self.other_tree = other_tree
2349
self.reason = reason
2352
class SubsumeTargetNeedsUpgrade(BzrError):
2354
_fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2356
def __init__(self, other_tree):
2357
self.other_tree = other_tree
2360
class BadReferenceTarget(InternalBzrError):
2362
_fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2365
def __init__(self, tree, other_tree, reason):
2367
self.other_tree = other_tree
2368
self.reason = reason
2371
class NoSuchTag(BzrError):
2373
_fmt = "No such tag: %(tag_name)s"
2375
def __init__(self, tag_name):
2376
self.tag_name = tag_name
2379
class TagsNotSupported(BzrError):
2381
_fmt = ("Tags not supported by %(branch)s;"
2382
" you may be able to use bzr upgrade --dirstate-tags.")
2384
def __init__(self, branch):
2385
self.branch = branch
2388
class TagAlreadyExists(BzrError):
2390
_fmt = "Tag %(tag_name)s already exists."
2392
def __init__(self, tag_name):
2393
self.tag_name = tag_name
2396
class MalformedBugIdentifier(BzrError):
2398
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2400
def __init__(self, bug_id, reason):
2401
self.bug_id = bug_id
2402
self.reason = reason
2405
class InvalidBugTrackerURL(BzrError):
2407
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2408
"contain {id}: %(url)s")
2410
def __init__(self, abbreviation, url):
2411
self.abbreviation = abbreviation
2415
class UnknownBugTrackerAbbreviation(BzrError):
2417
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2420
def __init__(self, abbreviation, branch):
2421
self.abbreviation = abbreviation
2422
self.branch = branch
2425
class UnexpectedSmartServerResponse(BzrError):
2427
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2429
def __init__(self, response_tuple):
2430
self.response_tuple = response_tuple
2433
class ContainerError(BzrError):
2434
"""Base class of container errors."""
2437
class UnknownContainerFormatError(ContainerError):
2439
_fmt = "Unrecognised container format: %(container_format)r"
2441
def __init__(self, container_format):
2442
self.container_format = container_format
2445
class UnexpectedEndOfContainerError(ContainerError):
2447
_fmt = "Unexpected end of container stream"
2450
class UnknownRecordTypeError(ContainerError):
2452
_fmt = "Unknown record type: %(record_type)r"
2454
def __init__(self, record_type):
2455
self.record_type = record_type
2458
class InvalidRecordError(ContainerError):
2460
_fmt = "Invalid record: %(reason)s"
2462
def __init__(self, reason):
2463
self.reason = reason
2466
class ContainerHasExcessDataError(ContainerError):
2468
_fmt = "Container has data after end marker: %(excess)r"
2470
def __init__(self, excess):
2471
self.excess = excess
2474
class DuplicateRecordNameError(ContainerError):
2476
_fmt = "Container has multiple records with the same name: %(name)s"
2478
def __init__(self, name):
2482
class NoDestinationAddress(InternalBzrError):
2484
_fmt = "Message does not have a destination address."
2487
class RepositoryDataStreamError(BzrError):
2489
_fmt = "Corrupt or incompatible data stream: %(reason)s"
2491
def __init__(self, reason):
2492
self.reason = reason
2495
class SMTPError(BzrError):
2497
_fmt = "SMTP error: %(error)s"
2499
def __init__(self, error):
2503
class NoMessageSupplied(BzrError):
2505
_fmt = "No message supplied."
2508
class NoMailAddressSpecified(BzrError):
2510
_fmt = "No mail-to address specified."
2513
class UnknownMailClient(BzrError):
2515
_fmt = "Unknown mail client: %(mail_client)s"
2517
def __init__(self, mail_client):
2518
BzrError.__init__(self, mail_client=mail_client)
2521
class MailClientNotFound(BzrError):
2523
_fmt = "Unable to find mail client with the following names:"\
2524
" %(mail_command_list_string)s"
2526
def __init__(self, mail_command_list):
2527
mail_command_list_string = ', '.join(mail_command_list)
2528
BzrError.__init__(self, mail_command_list=mail_command_list,
2529
mail_command_list_string=mail_command_list_string)
2531
class SMTPConnectionRefused(SMTPError):
2533
_fmt = "SMTP connection to %(host)s refused"
2535
def __init__(self, error, host):
2540
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2542
_fmt = "Please specify smtp_server. No server at default %(host)s."
2545
class BzrDirError(BzrError):
2547
def __init__(self, bzrdir):
2548
import bzrlib.urlutils as urlutils
2549
display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
2551
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2554
class UnsyncedBranches(BzrDirError):
2556
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2557
" bzr help sync-for-reconfigure.")
2559
def __init__(self, bzrdir, target_branch):
2560
BzrDirError.__init__(self, bzrdir)
2561
import bzrlib.urlutils as urlutils
2562
self.target_url = urlutils.unescape_for_display(target_branch.base,
2566
class AlreadyBranch(BzrDirError):
2568
_fmt = "'%(display_url)s' is already a branch."
2571
class AlreadyTree(BzrDirError):
2573
_fmt = "'%(display_url)s' is already a tree."
2576
class AlreadyCheckout(BzrDirError):
2578
_fmt = "'%(display_url)s' is already a checkout."
2581
class AlreadyLightweightCheckout(BzrDirError):
2583
_fmt = "'%(display_url)s' is already a lightweight checkout."
2586
class AlreadyUsingShared(BzrDirError):
2588
_fmt = "'%(display_url)s' is already using a shared repository."
2591
class AlreadyStandalone(BzrDirError):
2593
_fmt = "'%(display_url)s' is already standalone."
2596
class ReconfigurationNotSupported(BzrDirError):
2598
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2601
class NoBindLocation(BzrDirError):
2603
_fmt = "No location could be found to bind to at %(display_url)s."
2606
class UncommittedChanges(BzrError):
2608
_fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
2610
def __init__(self, tree):
2611
import bzrlib.urlutils as urlutils
2612
display_url = urlutils.unescape_for_display(
2613
tree.bzrdir.root_transport.base, 'ascii')
2614
BzrError.__init__(self, tree=tree, display_url=display_url)
2617
class MissingTemplateVariable(BzrError):
2619
_fmt = 'Variable {%(name)s} is not available.'
2621
def __init__(self, name):
2625
class NoTemplate(BzrError):
2627
_fmt = 'No template specified.'
2630
class UnableCreateSymlink(BzrError):
2632
_fmt = 'Unable to create symlink %(path_str)son this platform'
2634
def __init__(self, path=None):
2638
path_str = repr(str(path))
2639
except UnicodeEncodeError:
2640
path_str = repr(path)
2642
self.path_str = path_str
2645
class UnsupportedTimezoneFormat(BzrError):
2647
_fmt = ('Unsupported timezone format "%(timezone)s", '
2648
'options are "utc", "original", "local".')
2650
def __init__(self, timezone):
2651
self.timezone = timezone
2654
class CommandAvailableInPlugin(StandardError):
2656
internal_error = False
2658
def __init__(self, cmd_name, plugin_metadata, provider):
2660
self.plugin_metadata = plugin_metadata
2661
self.cmd_name = cmd_name
2662
self.provider = provider
2666
_fmt = ('"%s" is not a standard bzr command. \n'
2667
'However, the following official plugin provides this command: %s\n'
2668
'You can install it by going to: %s'
2669
% (self.cmd_name, self.plugin_metadata['name'],
2670
self.plugin_metadata['url']))
2675
class NoPluginAvailable(BzrError):
2679
class NotATerminal(BzrError):
2681
_fmt = 'Unable to ask for a password without real terminal.'
2684
class UnableEncodePath(BzrError):
2686
_fmt = ('Unable to encode %(kind)s path %(path)r in '
2687
'user encoding %(user_encoding)s')
2689
def __init__(self, path, kind):
2692
self.user_encoding = osutils.get_user_encoding()