~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

merge with get_file_sha1

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
        self.message = message
225
225
 
226
226
 
 
227
class DirstateCorrupt(BzrError):
 
228
 
 
229
    _fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s"
 
230
 
 
231
    def __init__(self, state, msg):
 
232
        BzrError.__init__(self)
 
233
        self.state = state
 
234
        self.msg = msg
 
235
 
 
236
 
227
237
class DisabledMethod(InternalBzrError):
228
238
 
229
239
    _fmt = "The smart server method '%(class_name)s' is disabled."
774
784
 
775
785
class IncompatibleRepositories(BzrError):
776
786
 
777
 
    _fmt = "Repository %(target)s is not compatible with repository"\
778
 
        " %(source)s"
 
787
    _fmt = "%(target)s\n" \
 
788
            "is not compatible with\n" \
 
789
            "%(source)s\n" \
 
790
            "%(details)s"
779
791
 
780
 
    def __init__(self, source, target):
781
 
        BzrError.__init__(self, target=target, source=source)
 
792
    def __init__(self, source, target, details=None):
 
793
        if details is None:
 
794
            details = "(no details)"
 
795
        BzrError.__init__(self, target=target, source=source, details=details)
782
796
 
783
797
 
784
798
class IncompatibleRevision(BzrError):
2381
2395
        self.patch_type = patch_type
2382
2396
 
2383
2397
 
 
2398
class TargetNotBranch(BzrError):
 
2399
    """A merge directive's target branch is required, but isn't a branch"""
 
2400
 
 
2401
    _fmt = ("Your branch does not have all of the revisions required in "
 
2402
            "order to merge this merge directive and the target "
 
2403
            "location specified in the merge directive is not a branch: "
 
2404
            "%(location)s.")
 
2405
 
 
2406
    def __init__(self, location):
 
2407
        BzrError.__init__(self)
 
2408
        self.location = location
 
2409
 
 
2410
 
2384
2411
class UnsupportedInventoryKind(BzrError):
2385
2412
    
2386
2413
    _fmt = """Unsupported entry kind %(kind)s"""
2429
2456
class TagsNotSupported(BzrError):
2430
2457
 
2431
2458
    _fmt = ("Tags not supported by %(branch)s;"
2432
 
            " you may be able to use bzr upgrade --dirstate-tags.")
 
2459
            " you may be able to use bzr upgrade.")
2433
2460
 
2434
2461
    def __init__(self, branch):
2435
2462
        self.branch = branch
2481
2508
 
2482
2509
 
2483
2510
class ErrorFromSmartServer(BzrError):
 
2511
    """An error was received from a smart server.
 
2512
 
 
2513
    :seealso: UnknownErrorFromSmartServer
 
2514
    """
2484
2515
 
2485
2516
    _fmt = "Error received from smart server: %(error_tuple)r"
2486
2517
 
2495
2526
        self.error_args = error_tuple[1:]
2496
2527
 
2497
2528
 
 
2529
class UnknownErrorFromSmartServer(BzrError):
 
2530
    """An ErrorFromSmartServer could not be translated into a typical bzrlib
 
2531
    error.
 
2532
 
 
2533
    This is distinct from ErrorFromSmartServer so that it is possible to
 
2534
    distinguish between the following two cases:
 
2535
      - ErrorFromSmartServer was uncaught.  This is logic error in the client
 
2536
        and so should provoke a traceback to the user.
 
2537
      - ErrorFromSmartServer was caught but its error_tuple could not be
 
2538
        translated.  This is probably because the server sent us garbage, and
 
2539
        should not provoke a traceback.
 
2540
    """
 
2541
 
 
2542
    _fmt = "Server sent an unexpected error: %(error_tuple)r"
 
2543
 
 
2544
    internal_error = False
 
2545
 
 
2546
    def __init__(self, error_from_smart_server):
 
2547
        """Constructor.
 
2548
 
 
2549
        :param error_from_smart_server: An ErrorFromSmartServer instance.
 
2550
        """
 
2551
        self.error_from_smart_server = error_from_smart_server
 
2552
        self.error_tuple = error_from_smart_server.error_tuple
 
2553
        
 
2554
 
2498
2555
class ContainerError(BzrError):
2499
2556
    """Base class of container errors."""
2500
2557