/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: Martin Pool
  • Date: 2007-09-14 06:31:28 UTC
  • mfrom: (2822 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2823.
  • Revision ID: mbp@sourcefrog.net-20070914063128-0p7mh6zfb4pzdg9p
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
        self.current = current
199
199
 
200
200
 
 
201
class InProcessTransport(BzrError):
 
202
 
 
203
    _fmt = "The transport '%(transport)s' is only accessible within this " \
 
204
        "process."
 
205
 
 
206
    def __init__(self, transport):
 
207
        self.transport = transport
 
208
 
 
209
 
201
210
class InvalidEntryName(BzrError):
202
211
    
203
212
    _fmt = "Invalid entry name: %(name)s"
247
256
 
248
257
class NoSuchId(BzrError):
249
258
 
250
 
    _fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
 
259
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
251
260
    
252
261
    def __init__(self, tree, file_id):
253
262
        BzrError.__init__(self)
255
264
        self.tree = tree
256
265
 
257
266
 
 
267
class NoSuchIdInRepository(NoSuchId):
 
268
 
 
269
    _fmt = ('The file id "%(file_id)s" is not present in the repository'
 
270
            ' %(repository)r')
 
271
 
 
272
    def __init__(self, repository, file_id):
 
273
        BzrError.__init__(self, repository=repository, file_id=file_id)
 
274
 
 
275
 
258
276
class InventoryModified(BzrError):
259
277
 
260
278
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
268
286
 
269
287
class NoWorkingTree(BzrError):
270
288
 
271
 
    _fmt = "No WorkingTree exists for %(base)s."
 
289
    _fmt = 'No WorkingTree exists for "%(base)s".'
272
290
    
273
291
    def __init__(self, base):
274
292
        BzrError.__init__(self)
290
308
 
291
309
class WorkingTreeAlreadyPopulated(BzrError):
292
310
 
293
 
    _fmt = """Working tree already populated in %(base)s"""
 
311
    _fmt = 'Working tree already populated in "%(base)s"'
294
312
 
295
313
    internal_error = True
296
314
 
450
468
 
451
469
class NotADirectory(PathError):
452
470
 
453
 
    _fmt = "%(path)r is not a directory %(extra)s"
 
471
    _fmt = '"%(path)s" is not a directory %(extra)s'
454
472
 
455
473
 
456
474
class NotInWorkingDirectory(PathError):
457
475
 
458
 
    _fmt = "%(path)r is not in the working directory %(extra)s"
 
476
    _fmt = '"%(path)s" is not in the working directory %(extra)s'
459
477
 
460
478
 
461
479
class DirectoryNotEmpty(PathError):
462
480
 
463
 
    _fmt = "Directory not empty: %(path)r%(extra)s"
 
481
    _fmt = 'Directory not empty: "%(path)s"%(extra)s'
464
482
 
465
483
 
466
484
class ReadingCompleted(BzrError):
477
495
 
478
496
class ResourceBusy(PathError):
479
497
 
480
 
    _fmt = "Device or resource busy: %(path)r%(extra)s"
 
498
    _fmt = 'Device or resource busy: "%(path)s"%(extra)s'
481
499
 
482
500
 
483
501
class PermissionDenied(PathError):
484
502
 
485
 
    _fmt = "Permission denied: %(path)r%(extra)s"
 
503
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
486
504
 
487
505
 
488
506
class InvalidURL(PathError):
489
507
 
490
 
    _fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
 
508
    _fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
491
509
 
492
510
 
493
511
class InvalidURLJoin(PathError):
494
512
 
495
 
    _fmt = "Invalid URL join request: %(args)s%(extra)s"
 
513
    _fmt = 'Invalid URL join request: "%(args)s"%(extra)s'
496
514
 
497
515
    def __init__(self, msg, base, args):
498
516
        PathError.__init__(self, base, msg)
524
542
 
525
543
class ShortReadvError(PathError):
526
544
 
527
 
    _fmt = ("readv() read %(actual)s bytes rather than %(length)s bytes"
528
 
            " at %(offset)s for %(path)s%(extra)s")
 
545
    _fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
 
546
            ' at %(offset)s for "%(path)s"%(extra)s')
529
547
 
530
548
    internal_error = True
531
549
 
536
554
        self.actual = actual
537
555
 
538
556
 
539
 
class PathNotChild(BzrError):
 
557
class PathNotChild(PathError):
540
558
 
541
 
    _fmt = "Path %(path)r is not a child of path %(base)r%(extra)s"
 
559
    _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
542
560
 
543
561
    internal_error = True
544
562
 
554
572
 
555
573
class InvalidNormalization(PathError):
556
574
 
557
 
    _fmt = "Path %(path)r is not unicode normalized"
 
575
    _fmt = 'Path "%(path)s" is not unicode normalized'
558
576
 
559
577
 
560
578
# TODO: This is given a URL; we try to unescape it but doing that from inside
562
580
# TODO: Probably this behavior of should be a common superclass 
563
581
class NotBranchError(PathError):
564
582
 
565
 
    _fmt = "Not a branch: %(path)s"
 
583
    _fmt = 'Not a branch: "%(path)s".'
566
584
 
567
585
    def __init__(self, path):
568
586
       import bzrlib.urlutils as urlutils
580
598
 
581
599
class AlreadyBranchError(PathError):
582
600
 
583
 
    _fmt = "Already a branch: %(path)s."
 
601
    _fmt = 'Already a branch: "%(path)s".'
584
602
 
585
603
 
586
604
class BranchExistsWithoutWorkingTree(PathError):
587
605
 
588
 
    _fmt = "Directory contains a branch, but no working tree \
589
 
(use bzr checkout if you wish to build a working tree): %(path)s"
 
606
    _fmt = 'Directory contains a branch, but no working tree \
 
607
(use bzr checkout if you wish to build a working tree): "%(path)s"'
590
608
 
591
609
 
592
610
class AtomicFileAlreadyClosed(PathError):
593
611
 
594
 
    _fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
595
 
            " %(path)s")
 
612
    _fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
 
613
            ' "%(path)s"')
596
614
 
597
615
    def __init__(self, path, function):
598
616
        PathError.__init__(self, path=path, extra=None)
601
619
 
602
620
class InaccessibleParent(PathError):
603
621
 
604
 
    _fmt = ("Parent not accessible given base %(base)s and"
605
 
            " relative path %(path)s")
 
622
    _fmt = ('Parent not accessible given base "%(base)s" and'
 
623
            ' relative path "%(path)s"')
606
624
 
607
625
    def __init__(self, path, base):
608
626
        PathError.__init__(self, path)
611
629
 
612
630
class NoRepositoryPresent(BzrError):
613
631
 
614
 
    _fmt = "No repository present: %(path)r"
 
632
    _fmt = 'No repository present: "%(path)s"'
615
633
    def __init__(self, bzrdir):
616
634
        BzrError.__init__(self)
617
635
        self.path = bzrdir.transport.clone('..').base
619
637
 
620
638
class FileInWrongBranch(BzrError):
621
639
 
622
 
    _fmt = "File %(path)s in not in branch %(branch_base)s."
 
640
    _fmt = 'File "%(path)s" in not in branch %(branch_base)s.'
623
641
 
624
642
    def __init__(self, branch, path):
625
643
        BzrError.__init__(self)
669
687
class AlreadyVersionedError(BzrError):
670
688
    """Used when a path is expected not to be versioned, but it is."""
671
689
 
672
 
    _fmt = "%(context_info)s%(path)s is already versioned"
 
690
    _fmt = "%(context_info)s%(path)s is already versioned."
673
691
 
674
692
    def __init__(self, path, context_info=None):
675
693
        """Construct a new AlreadyVersionedError.
690
708
class NotVersionedError(BzrError):
691
709
    """Used when a path is expected to be versioned, but it is not."""
692
710
 
693
 
    _fmt = "%(context_info)s%(path)s is not versioned"
 
711
    _fmt = "%(context_info)s%(path)s is not versioned."
694
712
 
695
713
    def __init__(self, path, context_info=None):
696
714
        """Construct a new NotVersionedError.
749
767
 
750
768
class ForbiddenControlFileError(BzrError):
751
769
 
752
 
    _fmt = "Cannot operate on %(filename)s because it is a control file"
 
770
    _fmt = 'Cannot operate on "%(filename)s" because it is a control file'
753
771
 
754
772
 
755
773
class LockError(BzrError):
852
870
 
853
871
class LockContention(LockError):
854
872
 
855
 
    _fmt = "Could not acquire lock %(lock)s"
 
873
    _fmt = 'Could not acquire lock "%(lock)s"'
856
874
    # TODO: show full url for lock, combining the transport and relative
857
875
    # bits?
858
876
 
932
950
        BzrError.__init__(self, files=files, files_str=files_str)
933
951
 
934
952
 
 
953
class BadCommitMessageEncoding(BzrError):
 
954
 
 
955
    _fmt = 'The specified commit message contains characters unsupported by '\
 
956
        'the current encoding.'
 
957
 
 
958
 
935
959
class UpgradeReadonly(BzrError):
936
960
 
937
961
    _fmt = "Upgrade URL cannot work with readonly URLs."
953
977
 
954
978
class NoSuchRevision(BzrError):
955
979
 
956
 
    _fmt = "Branch %(branch)s has no revision %(revision)s"
 
980
    _fmt = "%(branch)s has no revision %(revision)s"
957
981
 
958
982
    internal_error = True
959
983
 
960
984
    def __init__(self, branch, revision):
 
985
        # 'branch' may sometimes be an internal object like a KnitRevisionStore
961
986
        BzrError.__init__(self, branch=branch, revision=revision)
962
987
 
963
988
 
 
989
# zero_ninetyone: this exception is no longer raised and should be removed
964
990
class NotLeftParentDescendant(BzrError):
965
991
 
966
992
    _fmt = ("Revision %(old_revision)s is not the left parent of"
974
1000
                          new_revision=new_revision)
975
1001
 
976
1002
 
 
1003
class RangeInChangeOption(BzrError):
 
1004
 
 
1005
    _fmt = "Option --change does not accept revision ranges"
 
1006
 
 
1007
 
977
1008
class NoSuchRevisionSpec(BzrError):
978
1009
 
979
1010
    _fmt = "No namespace registered for string: %(spec)r"
985
1016
class NoSuchRevisionInTree(NoSuchRevision):
986
1017
    """When using Tree.revision_tree, and the revision is not accessible."""
987
1018
    
988
 
    _fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
 
1019
    _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
989
1020
 
990
1021
    def __init__(self, tree, revision_id):
991
1022
        BzrError.__init__(self)
1123
1154
 
1124
1155
class BoundBranchOutOfDate(BzrError):
1125
1156
 
1126
 
    _fmt = ("Bound branch %(branch)s is out of date"
1127
 
            " with master branch %(master)s.")
 
1157
    _fmt = ("Bound branch %(branch)s is out of date with master branch"
 
1158
            " %(master)s.")
1128
1159
 
1129
1160
    def __init__(self, branch, master):
1130
1161
        BzrError.__init__(self)
1245
1276
 
1246
1277
class RevisionNotPresent(VersionedFileError):
1247
1278
    
1248
 
    _fmt = "Revision {%(revision_id)s} not present in %(file_id)s."
 
1279
    _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1249
1280
 
1250
1281
    def __init__(self, revision_id, file_id):
1251
1282
        VersionedFileError.__init__(self)
1255
1286
 
1256
1287
class RevisionAlreadyPresent(VersionedFileError):
1257
1288
    
1258
 
    _fmt = "Revision {%(revision_id)s} already present in %(file_id)s."
 
1289
    _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1259
1290
 
1260
1291
    def __init__(self, revision_id, file_id):
1261
1292
        VersionedFileError.__init__(self)
1263
1294
        self.file_id = file_id
1264
1295
 
1265
1296
 
 
1297
class VersionedFileInvalidChecksum(VersionedFileError):
 
1298
 
 
1299
    _fmt = "Text did not match its checksum: %(message)s"
 
1300
 
 
1301
 
1266
1302
class KnitError(BzrError):
1267
1303
    
1268
1304
    _fmt = "Knit error"
1270
1306
    internal_error = True
1271
1307
 
1272
1308
 
1273
 
class KnitHeaderError(KnitError):
1274
 
 
1275
 
    _fmt = "Knit header error: %(badline)r unexpected for file %(filename)s"
1276
 
 
1277
 
    def __init__(self, badline, filename):
1278
 
        KnitError.__init__(self)
1279
 
        self.badline = badline
1280
 
        self.filename = filename
1281
 
 
1282
 
 
1283
1309
class KnitCorrupt(KnitError):
1284
1310
 
1285
1311
    _fmt = "Knit %(filename)s corrupt: %(how)s"
1290
1316
        self.how = how
1291
1317
 
1292
1318
 
 
1319
class KnitDataStreamIncompatible(KnitError):
 
1320
 
 
1321
    _fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
 
1322
 
 
1323
    def __init__(self, stream_format, target_format):
 
1324
        self.stream_format = stream_format
 
1325
        self.target_format = target_format
 
1326
        
 
1327
 
 
1328
class KnitHeaderError(KnitError):
 
1329
 
 
1330
    _fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
 
1331
 
 
1332
    def __init__(self, badline, filename):
 
1333
        KnitError.__init__(self)
 
1334
        self.badline = badline
 
1335
        self.filename = filename
 
1336
 
1293
1337
class KnitIndexUnknownMethod(KnitError):
1294
1338
    """Raised when we don't understand the storage method.
1295
1339
 
1502
1546
 
1503
1547
class SigningFailed(BzrError):
1504
1548
 
1505
 
    _fmt = "Failed to gpg sign data with command %(command_line)r"
 
1549
    _fmt = 'Failed to gpg sign data with command "%(command_line)s"'
1506
1550
 
1507
1551
    def __init__(self, command_line):
1508
1552
        BzrError.__init__(self, command_line=command_line)
1582
1626
 
1583
1627
class NoBundleFound(BzrError):
1584
1628
 
1585
 
    _fmt = "No bundle was found in %(filename)s"
 
1629
    _fmt = 'No bundle was found in "%(filename)s".'
1586
1630
 
1587
1631
    def __init__(self, filename):
1588
1632
        BzrError.__init__(self)
1611
1655
        self.text_revision = text_revision
1612
1656
        self.file_id = file_id
1613
1657
 
 
1658
 
1614
1659
class DuplicateFileId(BzrError):
1615
1660
 
1616
1661
    _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1724
1769
class BzrRemoveChangedFilesError(BzrError):
1725
1770
    """Used when user is trying to remove changed files."""
1726
1771
 
1727
 
    _fmt = ("Can't remove changed or unknown files:\n%(changes_as_text)s"
 
1772
    _fmt = ("Can't safely remove modified or unknown files:\n"
 
1773
        "%(changes_as_text)s"
1728
1774
        "Use --keep to not delete them, or --force to delete them regardless.")
1729
1775
 
1730
1776
    def __init__(self, tree_delta):
1808
1854
    _fmt = "Diff3 is not installed on this machine."
1809
1855
 
1810
1856
 
 
1857
class ExistingContent(BzrError):
 
1858
    # Added in bzrlib 0.92, used by VersionedFile.add_lines.
 
1859
 
 
1860
    _fmt = "The content being inserted is already present."
 
1861
 
 
1862
 
1811
1863
class ExistingLimbo(BzrError):
1812
1864
 
1813
1865
    _fmt = """This tree contains left-over files from a failed operation.
1819
1871
       self.limbo_dir = limbo_dir
1820
1872
 
1821
1873
 
 
1874
class ExistingPendingDeletion(BzrError):
 
1875
 
 
1876
    _fmt = """This tree contains left-over files from a failed operation.
 
1877
    Please examine %(pending_deletion)s to see if it contains any files you
 
1878
    wish to keep, and delete it when you are done."""
 
1879
 
 
1880
    def __init__(self, pending_deletion):
 
1881
       BzrError.__init__(self, pending_deletion=pending_deletion)
 
1882
 
 
1883
 
1822
1884
class ImmortalLimbo(BzrError):
1823
1885
 
1824
 
    _fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
 
1886
    _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1825
1887
    Please examine %(limbo_dir)s to see if it contains any files you wish to
1826
1888
    keep, and delete it when you are done."""
1827
1889
 
1830
1892
       self.limbo_dir = limbo_dir
1831
1893
 
1832
1894
 
 
1895
class ImmortalPendingDeletion(BzrError):
 
1896
 
 
1897
    _fmt = """Unable to delete transform temporary directory
 
1898
    %(pending_deletion)s.  Please examine %(pending_deletions)s to see if it
 
1899
    contains any files you wish to keep, and delete it when you are done."""
 
1900
 
 
1901
    def __init__(self, pending_deletion):
 
1902
       BzrError.__init__(self, pending_deletion=pending_deletion)
 
1903
 
 
1904
 
1833
1905
class OutOfDateTree(BzrError):
1834
1906
 
1835
1907
    _fmt = "Working tree is out of date, please run 'bzr update'."
2114
2186
        " branch location."
2115
2187
 
2116
2188
 
 
2189
class IllegalMergeDirectivePayload(BzrError):
 
2190
    """A merge directive contained something other than a patch or bundle"""
 
2191
 
 
2192
    _fmt = "Bad merge directive payload %(start)r"
 
2193
 
 
2194
    def __init__(self, start):
 
2195
        BzrError(self)
 
2196
        self.start = start
 
2197
 
 
2198
 
 
2199
class PatchVerificationFailed(BzrError):
 
2200
    """A patch from a merge directive could not be verified"""
 
2201
 
 
2202
    _fmt = "Preview patch does not match requested changes."
 
2203
 
 
2204
 
2117
2205
class PatchMissing(BzrError):
2118
2206
    """Raise a patch type was specified but no patch supplied"""
2119
2207
 
2134
2222
 
2135
2223
class BadSubsumeSource(BzrError):
2136
2224
 
2137
 
    _fmt = """Can't subsume %(other_tree)s into %(tree)s.  %(reason)s"""
 
2225
    _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2138
2226
 
2139
2227
    def __init__(self, tree, other_tree, reason):
2140
2228
        self.tree = tree
2152
2240
 
2153
2241
class BadReferenceTarget(BzrError):
2154
2242
 
2155
 
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s.  %(reason)s"
 
2243
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
 
2244
           "%(reason)s"
2156
2245
 
2157
2246
    internal_error = True
2158
2247
 
2259
2348
 
2260
2349
class DuplicateRecordNameError(ContainerError):
2261
2350
 
2262
 
    _fmt = "Container has multiple records with the same name: \"%(name)s\""
 
2351
    _fmt = "Container has multiple records with the same name: %(name)s"
2263
2352
 
2264
2353
    def __init__(self, name):
2265
2354
        self.name = name
2278
2367
 
2279
2368
    def __init__(self, error):
2280
2369
        self.error = error
 
2370
 
 
2371
 
 
2372
class NoMessageSupplied(BzrError):
 
2373
 
 
2374
    _fmt = "No message supplied."
 
2375
 
 
2376
 
 
2377
class UnknownMailClient(BzrError):
 
2378
 
 
2379
    _fmt = "Unknown mail client: %(mail_client)s"
 
2380
 
 
2381
    def __init__(self, mail_client):
 
2382
        BzrError.__init__(self, mail_client=mail_client)
 
2383
 
 
2384
 
 
2385
class MailClientNotFound(BzrError):
 
2386
 
 
2387
    _fmt = "Unable to find mail client with the following names:"\
 
2388
        " %(mail_command_list_string)s"
 
2389
 
 
2390
    def __init__(self, mail_command_list):
 
2391
        mail_command_list_string = ', '.join(mail_command_list)
 
2392
        BzrError.__init__(self, mail_command_list=mail_command_list,
 
2393
                          mail_command_list_string=mail_command_list_string)
 
2394
 
 
2395
class SMTPConnectionRefused(SMTPError):
 
2396
 
 
2397
    _fmt = "SMTP connection to %(host)s refused"
 
2398
 
 
2399
    def __init__(self, error, host):
 
2400
        self.error = error
 
2401
        self.host = host
 
2402
 
 
2403
 
 
2404
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
 
2405
 
 
2406
    _fmt = "Please specify smtp_server.  No server at default %(host)s."