/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: Aaron Bentley
  • Date: 2009-03-09 02:16:29 UTC
  • mfrom: (4090 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4100.
  • Revision ID: aaron@aaronbentley.com-20090309021629-o4j18ltv1hzuuyhl
Merge bzr.dev into clean-tree2

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,
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):
1130
1130
 
1131
1131
class NoSuchRevisionInTree(NoSuchRevision):
1132
1132
    """When using Tree.revision_tree, and the revision is not accessible."""
1133
 
    
 
1133
 
1134
1134
    _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
1135
1135
 
1136
1136
    def __init__(self, tree, revision_id):
1200
1200
 
1201
1201
 
1202
1202
class NoCommonAncestor(BzrError):
1203
 
    
 
1203
 
1204
1204
    _fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1205
1205
 
1206
1206
    def __init__(self, revision_a, revision_b):
1274
1274
        self.branch = branch
1275
1275
        self.master = master
1276
1276
 
1277
 
        
 
1277
 
1278
1278
class CommitToDoubleBoundBranch(BzrError):
1279
1279
 
1280
1280
    _fmt = ("Cannot commit to branch %(branch)s."
1350
1350
class WeaveParentMismatch(WeaveError):
1351
1351
 
1352
1352
    _fmt = "Parents are mismatched between two revisions. %(message)s"
1353
 
    
 
1353
 
1354
1354
 
1355
1355
class WeaveInvalidChecksum(WeaveError):
1356
1356
 
1382
1382
 
1383
1383
 
1384
1384
class VersionedFileError(BzrError):
1385
 
    
 
1385
 
1386
1386
    _fmt = "Versioned file error"
1387
1387
 
1388
1388
 
1389
1389
class RevisionNotPresent(VersionedFileError):
1390
 
    
 
1390
 
1391
1391
    _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1392
1392
 
1393
1393
    def __init__(self, revision_id, file_id):
1397
1397
 
1398
1398
 
1399
1399
class RevisionAlreadyPresent(VersionedFileError):
1400
 
    
 
1400
 
1401
1401
    _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1402
1402
 
1403
1403
    def __init__(self, revision_id, file_id):
1412
1412
 
1413
1413
 
1414
1414
class KnitError(InternalBzrError):
1415
 
    
 
1415
 
1416
1416
    _fmt = "Knit error"
1417
1417
 
1418
1418
 
1450
1450
    def __init__(self, stream_format, target_format):
1451
1451
        self.stream_format = stream_format
1452
1452
        self.target_format = target_format
1453
 
        
 
1453
 
1454
1454
 
1455
1455
class KnitDataStreamUnknown(KnitError):
1456
1456
    # Indicates a data stream we don't know how to handle.
1459
1459
 
1460
1460
    def __init__(self, stream_format):
1461
1461
        self.stream_format = stream_format
1462
 
        
 
1462
 
1463
1463
 
1464
1464
class KnitHeaderError(KnitError):
1465
1465
 
1475
1475
 
1476
1476
    Currently only 'fulltext' and 'line-delta' are supported.
1477
1477
    """
1478
 
    
 
1478
 
1479
1479
    _fmt = ("Knit index %(filename)s does not have a known method"
1480
1480
            " in options: %(options)r")
1481
1481
 
1532
1532
 
1533
1533
 
1534
1534
class NoSuchExportFormat(BzrError):
1535
 
    
 
1535
 
1536
1536
    _fmt = "Export format %(format)r not supported"
1537
1537
 
1538
1538
    def __init__(self, format):
1541
1541
 
1542
1542
 
1543
1543
class TransportError(BzrError):
1544
 
    
 
1544
 
1545
1545
    _fmt = "Transport error: %(msg)s %(orig_error)s"
1546
1546
 
1547
1547
    def __init__(self, msg=None, orig_error=None):
1634
1634
            self.port = ':%s' % port
1635
1635
 
1636
1636
 
 
1637
# XXX: This is also used for unexpected end of file, which is different at the
 
1638
# TCP level from "connection reset".
1637
1639
class ConnectionReset(TransportError):
1638
1640
 
1639
1641
    _fmt = "Connection closed: %(msg)s %(orig_error)s"
1729
1731
 
1730
1732
class WorkingTreeNotRevision(BzrError):
1731
1733
 
1732
 
    _fmt = ("The working tree for %(basedir)s has changed since" 
 
1734
    _fmt = ("The working tree for %(basedir)s has changed since"
1733
1735
            " the last commit, but weave merge requires that it be"
1734
1736
            " unchanged")
1735
1737
 
2049
2051
    _fmt = """This tree contains left-over files from a failed operation.
2050
2052
    Please examine %(limbo_dir)s to see if it contains any files you wish to
2051
2053
    keep, and delete it when you are done."""
2052
 
    
 
2054
 
2053
2055
    def __init__(self, limbo_dir):
2054
2056
       BzrError.__init__(self)
2055
2057
       self.limbo_dir = limbo_dir
2202
2204
 
2203
2205
 
2204
2206
class BinaryFile(BzrError):
2205
 
    
 
2207
 
2206
2208
    _fmt = "File is binary but should be text."
2207
2209
 
2208
2210
 
2228
2230
 
2229
2231
 
2230
2232
class NotABundle(BzrError):
2231
 
    
 
2233
 
2232
2234
    _fmt = "Not a bzr revision-bundle: %(text)r"
2233
2235
 
2234
2236
    def __init__(self, text):
2236
2238
        self.text = text
2237
2239
 
2238
2240
 
2239
 
class BadBundle(BzrError): 
2240
 
    
 
2241
class BadBundle(BzrError):
 
2242
 
2241
2243
    _fmt = "Bad bzr revision-bundle: %(text)r"
2242
2244
 
2243
2245
    def __init__(self, text):
2245
2247
        self.text = text
2246
2248
 
2247
2249
 
2248
 
class MalformedHeader(BadBundle): 
2249
 
    
 
2250
class MalformedHeader(BadBundle):
 
2251
 
2250
2252
    _fmt = "Malformed bzr revision-bundle header: %(text)r"
2251
2253
 
2252
2254
 
2253
 
class MalformedPatches(BadBundle): 
2254
 
    
 
2255
class MalformedPatches(BadBundle):
 
2256
 
2255
2257
    _fmt = "Malformed patches in bzr revision-bundle: %(text)r"
2256
2258
 
2257
2259
 
2258
 
class MalformedFooter(BadBundle): 
2259
 
    
 
2260
class MalformedFooter(BadBundle):
 
2261
 
2260
2262
    _fmt = "Malformed footer in bzr revision-bundle: %(text)r"
2261
2263
 
2262
2264
 
2263
2265
class UnsupportedEOLMarker(BadBundle):
2264
 
    
2265
 
    _fmt = "End of line marker was not \\n in bzr revision-bundle"    
 
2266
 
 
2267
    _fmt = "End of line marker was not \\n in bzr revision-bundle"
2266
2268
 
2267
2269
    def __init__(self):
2268
 
        # XXX: BadBundle's constructor assumes there's explanatory text, 
 
2270
        # XXX: BadBundle's constructor assumes there's explanatory text,
2269
2271
        # but for this there is not
2270
2272
        BzrError.__init__(self)
2271
2273
 
2272
2274
 
2273
2275
class IncompatibleBundleFormat(BzrError):
2274
 
    
 
2276
 
2275
2277
    _fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
2276
2278
 
2277
2279
    def __init__(self, bundle_format, other):
2281
2283
 
2282
2284
 
2283
2285
class BadInventoryFormat(BzrError):
2284
 
    
 
2286
 
2285
2287
    _fmt = "Root class for inventory serialization errors"
2286
2288
 
2287
2289
 
2340
2342
        self.revision_id = revision_id
2341
2343
        self.ghost_revision_id = ghost_revision_id
2342
2344
 
2343
 
        
 
2345
 
2344
2346
class GhostRevisionUnusableHere(BzrError):
2345
2347
 
2346
2348
    _fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2438
2440
 
2439
2441
 
2440
2442
class UnsupportedInventoryKind(BzrError):
2441
 
    
 
2443
 
2442
2444
    _fmt = """Unsupported entry kind %(kind)s"""
2443
2445
 
2444
2446
    def __init__(self, kind):
2456
2458
 
2457
2459
 
2458
2460
class SubsumeTargetNeedsUpgrade(BzrError):
2459
 
    
 
2461
 
2460
2462
    _fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2461
2463
 
2462
2464
    def __init__(self, other_tree):
2490
2492
    def __init__(self, branch):
2491
2493
        self.branch = branch
2492
2494
 
2493
 
        
 
2495
 
2494
2496
class TagAlreadyExists(BzrError):
2495
2497
 
2496
2498
    _fmt = "Tag %(tag_name)s already exists."
2579
2581
        """
2580
2582
        self.error_from_smart_server = error_from_smart_server
2581
2583
        self.error_tuple = error_from_smart_server.error_tuple
2582
 
        
 
2584
 
2583
2585
 
2584
2586
class ContainerError(BzrError):
2585
2587
    """Base class of container errors."""
2588
2590
class UnknownContainerFormatError(ContainerError):
2589
2591
 
2590
2592
    _fmt = "Unrecognised container format: %(container_format)r"
2591
 
    
 
2593
 
2592
2594
    def __init__(self, container_format):
2593
2595
        self.container_format = container_format
2594
2596
 
2815
2817
 
2816
2818
 
2817
2819
class CommandAvailableInPlugin(StandardError):
2818
 
    
 
2820
 
2819
2821
    internal_error = False
2820
2822
 
2821
2823
    def __init__(self, cmd_name, plugin_metadata, provider):
2822
 
        
 
2824
 
2823
2825
        self.plugin_metadata = plugin_metadata
2824
2826
        self.cmd_name = cmd_name
2825
2827
        self.provider = provider
2826
2828
 
2827
2829
    def __str__(self):
2828
2830
 
2829
 
        _fmt = ('"%s" is not a standard bzr command. \n' 
 
2831
        _fmt = ('"%s" is not a standard bzr command. \n'
2830
2832
                'However, the following official plugin provides this command: %s\n'
2831
2833
                'You can install it by going to: %s'
2832
 
                % (self.cmd_name, self.plugin_metadata['name'], 
 
2834
                % (self.cmd_name, self.plugin_metadata['name'],
2833
2835
                    self.plugin_metadata['url']))
2834
2836
 
2835
2837
        return _fmt
2836
2838
 
2837
2839
 
2838
2840
class NoPluginAvailable(BzrError):
2839
 
    pass    
 
2841
    pass
2840
2842
 
2841
2843
 
2842
2844
class NotATerminal(BzrError):
2926
2928
    """A pre_change_branch_tip hook function may raise this to cleanly and
2927
2929
    explicitly abort a change to a branch tip.
2928
2930
    """
2929
 
    
 
2931
 
2930
2932
    _fmt = u"Tip change rejected: %(msg)s"
2931
2933
 
2932
2934
    def __init__(self, msg):
2965
2967
 
2966
2968
    def __init__(self, format, url):
2967
2969
        BzrError.__init__(self, format=format, url=url)
 
2970
 
 
2971
 
 
2972
class NoSuchView(BzrError):
 
2973
    """A view does not exist.
 
2974
    """
 
2975
 
 
2976
    _fmt = u"No such view: %(view_name)s."
 
2977
 
 
2978
    def __init__(self, view_name):
 
2979
        self.view_name = view_name
 
2980
 
 
2981
 
 
2982
class ViewsNotSupported(BzrError):
 
2983
    """Views are not supported by a tree format.
 
2984
    """
 
2985
 
 
2986
    _fmt = ("Views are not supported by %(tree)s;"
 
2987
            " use 'bzr upgrade' to change your tree to a later format.")
 
2988
 
 
2989
    def __init__(self, tree):
 
2990
        self.tree = tree
 
2991
 
 
2992
 
 
2993
class FileOutsideView(BzrError):
 
2994
 
 
2995
    _fmt = ('Specified file "%(file_name)s" is outside the current view: '
 
2996
            '%(view_str)s')
 
2997
 
 
2998
    def __init__(self, file_name, view_files):
 
2999
        self.file_name = file_name
 
3000
        self.view_str = ", ".join(view_files)
 
3001
 
 
3002
 
 
3003
class UnresumableWriteGroup(BzrError):
 
3004
 
 
3005
    _fmt = ("Repository %(repository)s cannot resume write group "
 
3006
            "%(write_groups)r: %(reason)s")
 
3007
 
 
3008
    internal_error = True
 
3009
 
 
3010
    def __init__(self, repository, write_groups, reason):
 
3011
        self.repository = repository
 
3012
        self.write_groups = write_groups
 
3013
        self.reason = reason
 
3014
 
 
3015
 
 
3016
class UnsuspendableWriteGroup(BzrError):
 
3017
 
 
3018
    _fmt = ("Repository %(repository)s cannot suspend a write group.")
 
3019
 
 
3020
    internal_error = True
 
3021
 
 
3022
    def __init__(self, repository):
 
3023
        self.repository = repository