/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Jelmer Vernooij
  • Date: 2009-03-12 00:05:46 UTC
  • mfrom: (4118 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4120.
  • Revision ID: jelmer@samba.org-20090312000546-lyzl6eelzwkraidl
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
 
33
33
# TODO: is there any value in providing the .args field used by standard
34
 
# python exceptions?   A list of values with no names seems less useful 
 
34
# python exceptions?   A list of values with no names seems less useful
35
35
# to me.
36
36
 
37
 
# TODO: Perhaps convert the exception to a string at the moment it's 
 
37
# TODO: Perhaps convert the exception to a string at the moment it's
38
38
# constructed to make sure it will succeed.  But that says nothing about
39
39
# exceptions that are never raised.
40
40
 
61
61
    :cvar _fmt: Format string to display the error; this is expanded
62
62
    by the instance's dict.
63
63
    """
64
 
    
 
64
 
65
65
    internal_error = False
66
66
 
67
67
    def __init__(self, msg=None, **kwds):
72
72
        arguments can be given.  The first is for generic "user" errors which
73
73
        are not intended to be caught and so do not need a specific subclass.
74
74
        The second case is for use with subclasses that provide a _fmt format
75
 
        string to print the arguments.  
 
75
        string to print the arguments.
76
76
 
77
 
        Keyword arguments are taken as parameters to the error, which can 
78
 
        be inserted into the format string template.  It's recommended 
79
 
        that subclasses override the __init__ method to require specific 
 
77
        Keyword arguments are taken as parameters to the error, which can
 
78
        be inserted into the format string template.  It's recommended
 
79
        that subclasses override the __init__ method to require specific
80
80
        parameters.
81
81
 
82
82
        :param msg: If given, this is the literal complete text for the error,
154
154
               )
155
155
 
156
156
    def __eq__(self, other):
157
 
        if self.__class__ != other.__class__:
 
157
        if self.__class__ is not other.__class__:
158
158
            return NotImplemented
159
159
        return self.__dict__ == other.__dict__
160
160
 
265
265
 
266
266
 
267
267
class InvalidEntryName(InternalBzrError):
268
 
    
 
268
 
269
269
    _fmt = "Invalid entry name: %(name)s"
270
270
 
271
271
    def __init__(self, name):
274
274
 
275
275
 
276
276
class InvalidRevisionNumber(BzrError):
277
 
    
 
277
 
278
278
    _fmt = "Invalid revision number %(revno)s"
279
279
 
280
280
    def __init__(self, revno):
329
329
class NoSuchId(BzrError):
330
330
 
331
331
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
332
 
    
 
332
 
333
333
    def __init__(self, tree, file_id):
334
334
        BzrError.__init__(self)
335
335
        self.file_id = file_id
362
362
class NoWorkingTree(BzrError):
363
363
 
364
364
    _fmt = 'No WorkingTree exists for "%(base)s".'
365
 
    
 
365
 
366
366
    def __init__(self, base):
367
367
        BzrError.__init__(self)
368
368
        self.base = base
477
477
    def __init__(self, name, value):
478
478
        BzrError.__init__(self, name=name, value=value)
479
479
 
480
 
    
 
480
 
481
481
class StrictCommitFailed(BzrError):
482
482
 
483
483
    _fmt = "Commit refused because there are unknown files in the tree"
486
486
# XXX: Should be unified with TransportError; they seem to represent the
487
487
# same thing
488
488
# RBC 20060929: I think that unifiying with TransportError would be a mistake
489
 
# - this is finer than a TransportError - and more useful as such. It 
 
489
# - this is finer than a TransportError - and more useful as such. It
490
490
# differentiates between 'transport has failed' and 'operation on a transport
491
491
# has failed.'
492
492
class PathError(BzrError):
493
 
    
 
493
 
494
494
    _fmt = "Generic path error: %(path)r%(extra)s)"
495
495
 
496
496
    def __init__(self, path, extra=None):
550
550
 
551
551
 
552
552
class ReadingCompleted(InternalBzrError):
553
 
    
 
553
 
554
554
    _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
555
555
            "called upon it - the request has been completed and no more "
556
556
            "data may be read.")
648
648
 
649
649
 
650
650
class ReadError(PathError):
651
 
    
 
651
 
652
652
    _fmt = """Error reading from %(path)r."""
653
653
 
654
654
 
689
689
 
690
690
# TODO: This is given a URL; we try to unescape it but doing that from inside
691
691
# the exception object is a bit undesirable.
692
 
# TODO: Probably this behavior of should be a common superclass 
 
692
# TODO: Probably this behavior of should be a common superclass
693
693
class NotBranchError(PathError):
694
694
 
695
695
    _fmt = 'Not a branch: "%(path)s".'
764
764
 
765
765
 
766
766
class UnknownFormatError(BzrError):
767
 
    
 
767
 
768
768
    _fmt = "Unknown %(kind)s format: %(format)r"
769
769
 
770
770
    def __init__(self, format, kind='branch'):
773
773
 
774
774
 
775
775
class IncompatibleFormat(BzrError):
776
 
    
 
776
 
777
777
    _fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
778
778
 
779
779
    def __init__(self, format, bzrdir_format):
796
796
 
797
797
 
798
798
class IncompatibleRevision(BzrError):
799
 
    
 
799
 
800
800
    _fmt = "Revision is not compatible with %(repo_format)s"
801
801
 
802
802
    def __init__(self, repo_format):
1003
1003
 
1004
1004
class LockContention(LockError):
1005
1005
 
1006
 
    _fmt = 'Could not acquire lock "%(lock)s"'
 
1006
    _fmt = 'Could not acquire lock "%(lock)s": %(message)s'
1007
1007
    # TODO: show full url for lock, combining the transport and relative
1008
1008
    # bits?
1009
1009
 
1010
1010
    internal_error = False
1011
1011
 
1012
 
    def __init__(self, lock):
 
1012
    def __init__(self, lock, message=''):
1013
1013
        self.lock = lock
 
1014
        self.message = message
1014
1015
 
1015
1016
 
1016
1017
class LockBroken(LockError):
1130
1131
 
1131
1132
class NoSuchRevisionInTree(NoSuchRevision):
1132
1133
    """When using Tree.revision_tree, and the revision is not accessible."""
1133
 
    
 
1134
 
1134
1135
    _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
1135
1136
 
1136
1137
    def __init__(self, tree, revision_id):
1200
1201
 
1201
1202
 
1202
1203
class NoCommonAncestor(BzrError):
1203
 
    
 
1204
 
1204
1205
    _fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1205
1206
 
1206
1207
    def __init__(self, revision_a, revision_b):
1274
1275
        self.branch = branch
1275
1276
        self.master = master
1276
1277
 
1277
 
        
 
1278
 
1278
1279
class CommitToDoubleBoundBranch(BzrError):
1279
1280
 
1280
1281
    _fmt = ("Cannot commit to branch %(branch)s."
1350
1351
class WeaveParentMismatch(WeaveError):
1351
1352
 
1352
1353
    _fmt = "Parents are mismatched between two revisions. %(message)s"
1353
 
    
 
1354
 
1354
1355
 
1355
1356
class WeaveInvalidChecksum(WeaveError):
1356
1357
 
1382
1383
 
1383
1384
 
1384
1385
class VersionedFileError(BzrError):
1385
 
    
 
1386
 
1386
1387
    _fmt = "Versioned file error"
1387
1388
 
1388
1389
 
1389
1390
class RevisionNotPresent(VersionedFileError):
1390
 
    
 
1391
 
1391
1392
    _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1392
1393
 
1393
1394
    def __init__(self, revision_id, file_id):
1397
1398
 
1398
1399
 
1399
1400
class RevisionAlreadyPresent(VersionedFileError):
1400
 
    
 
1401
 
1401
1402
    _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1402
1403
 
1403
1404
    def __init__(self, revision_id, file_id):
1412
1413
 
1413
1414
 
1414
1415
class KnitError(InternalBzrError):
1415
 
    
 
1416
 
1416
1417
    _fmt = "Knit error"
1417
1418
 
1418
1419
 
1450
1451
    def __init__(self, stream_format, target_format):
1451
1452
        self.stream_format = stream_format
1452
1453
        self.target_format = target_format
1453
 
        
 
1454
 
1454
1455
 
1455
1456
class KnitDataStreamUnknown(KnitError):
1456
1457
    # Indicates a data stream we don't know how to handle.
1459
1460
 
1460
1461
    def __init__(self, stream_format):
1461
1462
        self.stream_format = stream_format
1462
 
        
 
1463
 
1463
1464
 
1464
1465
class KnitHeaderError(KnitError):
1465
1466
 
1475
1476
 
1476
1477
    Currently only 'fulltext' and 'line-delta' are supported.
1477
1478
    """
1478
 
    
 
1479
 
1479
1480
    _fmt = ("Knit index %(filename)s does not have a known method"
1480
1481
            " in options: %(options)r")
1481
1482
 
1532
1533
 
1533
1534
 
1534
1535
class NoSuchExportFormat(BzrError):
1535
 
    
 
1536
 
1536
1537
    _fmt = "Export format %(format)r not supported"
1537
1538
 
1538
1539
    def __init__(self, format):
1541
1542
 
1542
1543
 
1543
1544
class TransportError(BzrError):
1544
 
    
 
1545
 
1545
1546
    _fmt = "Transport error: %(msg)s %(orig_error)s"
1546
1547
 
1547
1548
    def __init__(self, msg=None, orig_error=None):
1634
1635
            self.port = ':%s' % port
1635
1636
 
1636
1637
 
 
1638
# XXX: This is also used for unexpected end of file, which is different at the
 
1639
# TCP level from "connection reset".
1637
1640
class ConnectionReset(TransportError):
1638
1641
 
1639
1642
    _fmt = "Connection closed: %(msg)s %(orig_error)s"
1729
1732
 
1730
1733
class WorkingTreeNotRevision(BzrError):
1731
1734
 
1732
 
    _fmt = ("The working tree for %(basedir)s has changed since" 
 
1735
    _fmt = ("The working tree for %(basedir)s has changed since"
1733
1736
            " the last commit, but weave merge requires that it be"
1734
1737
            " unchanged")
1735
1738
 
2049
2052
    _fmt = """This tree contains left-over files from a failed operation.
2050
2053
    Please examine %(limbo_dir)s to see if it contains any files you wish to
2051
2054
    keep, and delete it when you are done."""
2052
 
    
 
2055
 
2053
2056
    def __init__(self, limbo_dir):
2054
2057
       BzrError.__init__(self)
2055
2058
       self.limbo_dir = limbo_dir
2202
2205
 
2203
2206
 
2204
2207
class BinaryFile(BzrError):
2205
 
    
 
2208
 
2206
2209
    _fmt = "File is binary but should be text."
2207
2210
 
2208
2211
 
2228
2231
 
2229
2232
 
2230
2233
class NotABundle(BzrError):
2231
 
    
 
2234
 
2232
2235
    _fmt = "Not a bzr revision-bundle: %(text)r"
2233
2236
 
2234
2237
    def __init__(self, text):
2236
2239
        self.text = text
2237
2240
 
2238
2241
 
2239
 
class BadBundle(BzrError): 
2240
 
    
 
2242
class BadBundle(BzrError):
 
2243
 
2241
2244
    _fmt = "Bad bzr revision-bundle: %(text)r"
2242
2245
 
2243
2246
    def __init__(self, text):
2245
2248
        self.text = text
2246
2249
 
2247
2250
 
2248
 
class MalformedHeader(BadBundle): 
2249
 
    
 
2251
class MalformedHeader(BadBundle):
 
2252
 
2250
2253
    _fmt = "Malformed bzr revision-bundle header: %(text)r"
2251
2254
 
2252
2255
 
2253
 
class MalformedPatches(BadBundle): 
2254
 
    
 
2256
class MalformedPatches(BadBundle):
 
2257
 
2255
2258
    _fmt = "Malformed patches in bzr revision-bundle: %(text)r"
2256
2259
 
2257
2260
 
2258
 
class MalformedFooter(BadBundle): 
2259
 
    
 
2261
class MalformedFooter(BadBundle):
 
2262
 
2260
2263
    _fmt = "Malformed footer in bzr revision-bundle: %(text)r"
2261
2264
 
2262
2265
 
2263
2266
class UnsupportedEOLMarker(BadBundle):
2264
 
    
2265
 
    _fmt = "End of line marker was not \\n in bzr revision-bundle"    
 
2267
 
 
2268
    _fmt = "End of line marker was not \\n in bzr revision-bundle"
2266
2269
 
2267
2270
    def __init__(self):
2268
 
        # XXX: BadBundle's constructor assumes there's explanatory text, 
 
2271
        # XXX: BadBundle's constructor assumes there's explanatory text,
2269
2272
        # but for this there is not
2270
2273
        BzrError.__init__(self)
2271
2274
 
2272
2275
 
2273
2276
class IncompatibleBundleFormat(BzrError):
2274
 
    
 
2277
 
2275
2278
    _fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
2276
2279
 
2277
2280
    def __init__(self, bundle_format, other):
2281
2284
 
2282
2285
 
2283
2286
class BadInventoryFormat(BzrError):
2284
 
    
 
2287
 
2285
2288
    _fmt = "Root class for inventory serialization errors"
2286
2289
 
2287
2290
 
2340
2343
        self.revision_id = revision_id
2341
2344
        self.ghost_revision_id = ghost_revision_id
2342
2345
 
2343
 
        
 
2346
 
2344
2347
class GhostRevisionUnusableHere(BzrError):
2345
2348
 
2346
2349
    _fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2438
2441
 
2439
2442
 
2440
2443
class UnsupportedInventoryKind(BzrError):
2441
 
    
 
2444
 
2442
2445
    _fmt = """Unsupported entry kind %(kind)s"""
2443
2446
 
2444
2447
    def __init__(self, kind):
2456
2459
 
2457
2460
 
2458
2461
class SubsumeTargetNeedsUpgrade(BzrError):
2459
 
    
 
2462
 
2460
2463
    _fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2461
2464
 
2462
2465
    def __init__(self, other_tree):
2490
2493
    def __init__(self, branch):
2491
2494
        self.branch = branch
2492
2495
 
2493
 
        
 
2496
 
2494
2497
class TagAlreadyExists(BzrError):
2495
2498
 
2496
2499
    _fmt = "Tag %(tag_name)s already exists."
2501
2504
 
2502
2505
class MalformedBugIdentifier(BzrError):
2503
2506
 
2504
 
    _fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
 
2507
    _fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
 
2508
            'See "bzr help bugs" for more information on this feature.')
2505
2509
 
2506
2510
    def __init__(self, bug_id, reason):
2507
2511
        self.bug_id = bug_id
2579
2583
        """
2580
2584
        self.error_from_smart_server = error_from_smart_server
2581
2585
        self.error_tuple = error_from_smart_server.error_tuple
2582
 
        
 
2586
 
2583
2587
 
2584
2588
class ContainerError(BzrError):
2585
2589
    """Base class of container errors."""
2588
2592
class UnknownContainerFormatError(ContainerError):
2589
2593
 
2590
2594
    _fmt = "Unrecognised container format: %(container_format)r"
2591
 
    
 
2595
 
2592
2596
    def __init__(self, container_format):
2593
2597
        self.container_format = container_format
2594
2598
 
2658
2662
 
2659
2663
class NoMailAddressSpecified(BzrError):
2660
2664
 
2661
 
    _fmt = "No mail-to address specified."
 
2665
    _fmt = "No mail-to address (--mail-to) or output (-o) specified."
2662
2666
 
2663
2667
 
2664
2668
class UnknownMailClient(BzrError):
2744
2748
    _fmt = "'%(display_url)s' is already standalone."
2745
2749
 
2746
2750
 
 
2751
class AlreadyWithTrees(BzrDirError):
 
2752
 
 
2753
    _fmt = ("Shared repository '%(display_url)s' already creates "
 
2754
            "working trees.")
 
2755
 
 
2756
 
 
2757
class AlreadyWithNoTrees(BzrDirError):
 
2758
 
 
2759
    _fmt = ("Shared repository '%(display_url)s' already doesn't create "
 
2760
            "working trees.")
 
2761
 
 
2762
 
2747
2763
class ReconfigurationNotSupported(BzrDirError):
2748
2764
 
2749
2765
    _fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2803
2819
 
2804
2820
 
2805
2821
class CommandAvailableInPlugin(StandardError):
2806
 
    
 
2822
 
2807
2823
    internal_error = False
2808
2824
 
2809
2825
    def __init__(self, cmd_name, plugin_metadata, provider):
2810
 
        
 
2826
 
2811
2827
        self.plugin_metadata = plugin_metadata
2812
2828
        self.cmd_name = cmd_name
2813
2829
        self.provider = provider
2814
2830
 
2815
2831
    def __str__(self):
2816
2832
 
2817
 
        _fmt = ('"%s" is not a standard bzr command. \n' 
 
2833
        _fmt = ('"%s" is not a standard bzr command. \n'
2818
2834
                'However, the following official plugin provides this command: %s\n'
2819
2835
                'You can install it by going to: %s'
2820
 
                % (self.cmd_name, self.plugin_metadata['name'], 
 
2836
                % (self.cmd_name, self.plugin_metadata['name'],
2821
2837
                    self.plugin_metadata['url']))
2822
2838
 
2823
2839
        return _fmt
2824
2840
 
2825
2841
 
2826
2842
class NoPluginAvailable(BzrError):
2827
 
    pass    
 
2843
    pass
2828
2844
 
2829
2845
 
2830
2846
class NotATerminal(BzrError):
2914
2930
    """A pre_change_branch_tip hook function may raise this to cleanly and
2915
2931
    explicitly abort a change to a branch tip.
2916
2932
    """
2917
 
    
 
2933
 
2918
2934
    _fmt = u"Tip change rejected: %(msg)s"
2919
2935
 
2920
2936
    def __init__(self, msg):
2934
2950
        BzrError.__init__(self, shelf_id=shelf_id)
2935
2951
 
2936
2952
 
 
2953
class InvalidShelfId(BzrError):
 
2954
 
 
2955
    _fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
 
2956
 
 
2957
    def __init__(self, invalid_id):
 
2958
        BzrError.__init__(self, invalid_id=invalid_id)
 
2959
 
 
2960
 
2937
2961
class UserAbort(BzrError):
2938
2962
 
2939
2963
    _fmt = 'The user aborted the operation.'
 
2964
 
 
2965
 
 
2966
class MustHaveWorkingTree(BzrError):
 
2967
 
 
2968
    _fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
 
2969
 
 
2970
    def __init__(self, format, url):
 
2971
        BzrError.__init__(self, format=format, url=url)
 
2972
 
 
2973
 
 
2974
class NoSuchView(BzrError):
 
2975
    """A view does not exist.
 
2976
    """
 
2977
 
 
2978
    _fmt = u"No such view: %(view_name)s."
 
2979
 
 
2980
    def __init__(self, view_name):
 
2981
        self.view_name = view_name
 
2982
 
 
2983
 
 
2984
class ViewsNotSupported(BzrError):
 
2985
    """Views are not supported by a tree format.
 
2986
    """
 
2987
 
 
2988
    _fmt = ("Views are not supported by %(tree)s;"
 
2989
            " use 'bzr upgrade' to change your tree to a later format.")
 
2990
 
 
2991
    def __init__(self, tree):
 
2992
        self.tree = tree
 
2993
 
 
2994
 
 
2995
class FileOutsideView(BzrError):
 
2996
 
 
2997
    _fmt = ('Specified file "%(file_name)s" is outside the current view: '
 
2998
            '%(view_str)s')
 
2999
 
 
3000
    def __init__(self, file_name, view_files):
 
3001
        self.file_name = file_name
 
3002
        self.view_str = ", ".join(view_files)
 
3003
 
 
3004
 
 
3005
class UnresumableWriteGroup(BzrError):
 
3006
 
 
3007
    _fmt = ("Repository %(repository)s cannot resume write group "
 
3008
            "%(write_groups)r: %(reason)s")
 
3009
 
 
3010
    internal_error = True
 
3011
 
 
3012
    def __init__(self, repository, write_groups, reason):
 
3013
        self.repository = repository
 
3014
        self.write_groups = write_groups
 
3015
        self.reason = reason
 
3016
 
 
3017
 
 
3018
class UnsuspendableWriteGroup(BzrError):
 
3019
 
 
3020
    _fmt = ("Repository %(repository)s cannot suspend a write group.")
 
3021
 
 
3022
    internal_error = True
 
3023
 
 
3024
    def __init__(self, repository):
 
3025
        self.repository = repository