/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: 2008-05-27 03:00:53 UTC
  • mfrom: (3452 +trunk)
  • mto: (3724.1.1 lock-hooks)
  • mto: This revision was merged to the branch mainline in revision 3730.
  • Revision ID: mbp@sourcefrog.net-20080527030053-0mct6dypek0ysjc3
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
185
185
    _fmt = "The tree builder is already building a tree."
186
186
 
187
187
 
 
188
class BranchError(BzrError):
 
189
    """Base class for concrete 'errors about a branch'."""
 
190
 
 
191
    def __init__(self, branch):
 
192
        BzrError.__init__(self, branch=branch)
 
193
 
 
194
 
188
195
class BzrCheckError(InternalBzrError):
189
196
    
190
197
    _fmt = "Internal check failed: %(message)s"
305
312
        BzrError.__init__(self, repository=repository, file_id=file_id)
306
313
 
307
314
 
 
315
class NotStacked(BranchError):
 
316
 
 
317
    _fmt = "The branch '%(branch)s' is not stacked."
 
318
 
 
319
 
308
320
class InventoryModified(InternalBzrError):
309
321
 
310
322
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
550
562
        PathError.__init__(self, base, reason)
551
563
 
552
564
 
 
565
class UnavailableRepresentation(InternalBzrError):
 
566
 
 
567
    _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
 
568
        "is encoded as '%(native)s'.")
 
569
 
 
570
    def __init__(self, key, wanted, native):
 
571
        InternalBzrError.__init__(self)
 
572
        self.wanted = wanted
 
573
        self.native = native
 
574
        self.key = key
 
575
 
 
576
 
553
577
class UnknownHook(BzrError):
554
578
 
555
579
    _fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
568
592
        PathError.__init__(self, url, extra=extra)
569
593
 
570
594
 
 
595
class UnstackableBranchFormat(BzrError):
 
596
 
 
597
    _fmt = ("The branch '%(url)s'(%(format)s) is not a stackable format. "
 
598
        "You will need to upgrade the branch to permit branch stacking.")
 
599
 
 
600
    def __init__(self, format, url):
 
601
        BzrError.__init__(self)
 
602
        self.format = format
 
603
        self.url = url
 
604
 
 
605
 
 
606
class UnstackableRepositoryFormat(BzrError):
 
607
 
 
608
    _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
 
609
        "You will need to upgrade the repository to permit branch stacking.")
 
610
 
 
611
    def __init__(self, format, url):
 
612
        BzrError.__init__(self)
 
613
        self.format = format
 
614
        self.url = url
 
615
 
 
616
 
571
617
class ReadError(PathError):
572
618
    
573
619
    _fmt = """Error reading from %(path)r."""
860
906
        self.obj = obj
861
907
 
862
908
 
863
 
class ReadOnlyLockError(LockError):
864
 
 
865
 
    _fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
866
 
 
867
 
    @symbol_versioning.deprecated_method(symbol_versioning.zero_ninetytwo)
868
 
    def __init__(self, fname, msg):
869
 
        LockError.__init__(self, '')
870
 
        self.fname = fname
871
 
        self.msg = msg
872
 
 
873
 
 
874
909
class LockFailed(LockError):
875
910
 
876
911
    internal_error = False
1032
1067
        BzrError.__init__(self, branch=branch, revision=revision)
1033
1068
 
1034
1069
 
1035
 
# zero_ninetyone: this exception is no longer raised and should be removed
1036
 
class NotLeftParentDescendant(InternalBzrError):
1037
 
 
1038
 
    _fmt = ("Revision %(old_revision)s is not the left parent of"
1039
 
            " %(new_revision)s, but branch %(branch_location)s expects this")
1040
 
 
1041
 
    def __init__(self, branch, old_revision, new_revision):
1042
 
        BzrError.__init__(self, branch_location=branch.base,
1043
 
                          old_revision=old_revision,
1044
 
                          new_revision=new_revision)
1045
 
 
1046
 
 
1047
1070
class RangeInChangeOption(BzrError):
1048
1071
 
1049
1072
    _fmt = "Option --change does not accept revision ranges"
1175
1198
        self.bases = bases
1176
1199
 
1177
1200
 
1178
 
class NoCommits(BzrError):
 
1201
class NoCommits(BranchError):
1179
1202
 
1180
1203
    _fmt = "Branch %(branch)s has no commits."
1181
1204
 
1182
 
    def __init__(self, branch):
1183
 
        BzrError.__init__(self, branch=branch)
1184
 
 
1185
1205
 
1186
1206
class UnlistableStore(BzrError):
1187
1207
 
1445
1465
        self.details = details
1446
1466
 
1447
1467
 
 
1468
class UnexpectedProtocolVersionMarker(TransportError):
 
1469
 
 
1470
    _fmt = "Received bad protocol version marker: %(marker)r"
 
1471
 
 
1472
    def __init__(self, marker):
 
1473
        self.marker = marker
 
1474
 
 
1475
 
 
1476
class UnknownSmartMethod(InternalBzrError):
 
1477
 
 
1478
    _fmt = "The server does not recognise the '%(verb)s' request."
 
1479
 
 
1480
    def __init__(self, verb):
 
1481
        self.verb = verb
 
1482
 
 
1483
 
 
1484
class SmartMessageHandlerError(InternalBzrError):
 
1485
 
 
1486
    _fmt = "The message handler raised an exception: %(exc_value)s."
 
1487
 
 
1488
    def __init__(self, exc_info):
 
1489
        self.exc_type, self.exc_value, self.tb = exc_info
 
1490
        
 
1491
 
1448
1492
# A set of semi-meaningful errors which can be thrown
1449
1493
class TransportNotPossible(TransportError):
1450
1494
 
2035
2079
        self.path = path
2036
2080
 
2037
2081
 
 
2082
class RepositoryUpgradeRequired(UpgradeRequired):
 
2083
 
 
2084
    _fmt = "To use this feature you must upgrade your repository at %(path)s."
 
2085
 
 
2086
 
2038
2087
class LocalRequiresBoundBranch(BzrError):
2039
2088
 
2040
2089
    _fmt = "Cannot perform local-only commits on unbound branches."
2386
2435
        self.response_tuple = response_tuple
2387
2436
 
2388
2437
 
 
2438
class ErrorFromSmartServer(BzrError):
 
2439
 
 
2440
    _fmt = "Error received from smart server: %(error_tuple)r"
 
2441
 
 
2442
    internal_error = True
 
2443
 
 
2444
    def __init__(self, error_tuple):
 
2445
        self.error_tuple = error_tuple
 
2446
        try:
 
2447
            self.error_verb = error_tuple[0]
 
2448
        except IndexError:
 
2449
            self.error_verb = None
 
2450
        self.error_args = error_tuple[1:]
 
2451
 
 
2452
 
2389
2453
class ContainerError(BzrError):
2390
2454
    """Base class of container errors."""
2391
2455
 
2507
2571
        BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2508
2572
 
2509
2573
 
 
2574
class UnsyncedBranches(BzrDirError):
 
2575
 
 
2576
    _fmt = ("'%(display_url)s' is not in sync with %(target_url)s.  See"
 
2577
            " bzr help sync-for-reconfigure.")
 
2578
 
 
2579
    def __init__(self, bzrdir, target_branch):
 
2580
        BzrDirError.__init__(self, bzrdir)
 
2581
        import bzrlib.urlutils as urlutils
 
2582
        self.target_url = urlutils.unescape_for_display(target_branch.base,
 
2583
                                                        'ascii')
 
2584
 
 
2585
 
2510
2586
class AlreadyBranch(BzrDirError):
2511
2587
 
2512
2588
    _fmt = "'%(display_url)s' is already a branch."
2527
2603
    _fmt = "'%(display_url)s' is already a lightweight checkout."
2528
2604
 
2529
2605
 
 
2606
class AlreadyUsingShared(BzrDirError):
 
2607
 
 
2608
    _fmt = "'%(display_url)s' is already using a shared repository."
 
2609
 
 
2610
 
 
2611
class AlreadyStandalone(BzrDirError):
 
2612
 
 
2613
    _fmt = "'%(display_url)s' is already standalone."
 
2614
 
 
2615
 
2530
2616
class ReconfigurationNotSupported(BzrDirError):
2531
2617
 
2532
2618
    _fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2585
2671
        self.timezone = timezone
2586
2672
 
2587
2673
 
 
2674
class CommandAvailableInPlugin(StandardError):
 
2675
    
 
2676
    internal_error = False
 
2677
 
 
2678
    def __init__(self, cmd_name, plugin_metadata, provider):
 
2679
        
 
2680
        self.plugin_metadata = plugin_metadata
 
2681
        self.cmd_name = cmd_name
 
2682
        self.provider = provider
 
2683
 
 
2684
    def __str__(self):
 
2685
 
 
2686
        _fmt = ('"%s" is not a standard bzr command. \n' 
 
2687
                'However, the following official plugin provides this command: %s\n'
 
2688
                'You can install it by going to: %s'
 
2689
                % (self.cmd_name, self.plugin_metadata['name'], 
 
2690
                    self.plugin_metadata['url']))
 
2691
 
 
2692
        return _fmt
 
2693
 
 
2694
 
 
2695
class NoPluginAvailable(BzrError):
 
2696
    pass    
 
2697
 
 
2698
 
2588
2699
class NotATerminal(BzrError):
2589
2700
 
2590
2701
    _fmt = 'Unable to ask for a password without real terminal.'
2599
2710
        self.path = path
2600
2711
        self.kind = kind
2601
2712
        self.user_encoding = osutils.get_user_encoding()
 
2713
 
 
2714
 
 
2715
class CannotBindAddress(BzrError):
 
2716
 
 
2717
    _fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
 
2718
 
 
2719
    def __init__(self, host, port, orig_error):
 
2720
        BzrError.__init__(self, host=host, port=port,
 
2721
            orig_error=orig_error[1])