/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

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""
19
19
 
20
20
 
21
 
from bzrlib import symbol_versioning
22
 
from bzrlib.patches import (PatchSyntax, 
23
 
                            PatchConflict, 
24
 
                            MalformedPatchHeader,
25
 
                            MalformedHunkHeader,
26
 
                            MalformedLine,)
 
21
from bzrlib import (
 
22
    osutils,
 
23
    symbol_versioning,
 
24
    )
 
25
from bzrlib.patches import (
 
26
    MalformedHunkHeader,
 
27
    MalformedLine,
 
28
    MalformedPatchHeader,
 
29
    PatchConflict,
 
30
    PatchSyntax,
 
31
    )
27
32
 
28
33
 
29
34
# TODO: is there any value in providing the .args field used by standard
210
215
        self.revision_id = revision_id
211
216
        self.branch = branch
212
217
 
 
218
class ReservedId(BzrError):
 
219
 
 
220
    _fmt = "Reserved revision-id {%(revision_id)s}"
 
221
 
 
222
    def __init__(self, revision_id):
 
223
        self.revision_id = revision_id
213
224
 
214
225
class NoSuchId(BzrError):
215
226
 
299
310
 
300
311
    _fmt = "Error in command line options"
301
312
 
 
313
 
 
314
class BadOptionValue(BzrError):
 
315
 
 
316
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
 
317
 
 
318
    def __init__(self, name, value):
 
319
        BzrError.__init__(self, name=name, value=value)
 
320
 
302
321
    
303
322
class StrictCommitFailed(BzrError):
304
323
 
330
349
    _fmt = "File exists: %(path)r%(extra)s"
331
350
 
332
351
 
 
352
class RenameFailedFilesExist(BzrError):
 
353
    """Used when renaming and both source and dest exist."""
 
354
 
 
355
    _fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
 
356
         "%(extra)s")
 
357
 
 
358
    def __init__(self, source, dest, extra=None):
 
359
        BzrError.__init__(self)
 
360
        self.source = str(source)
 
361
        self.dest = str(dest)
 
362
        if extra:
 
363
            self.extra = ' ' + str(extra)
 
364
        else:
 
365
            self.extra = ''
 
366
 
 
367
 
 
368
class NotADirectory(PathError):
 
369
 
 
370
    _fmt = "%(path)r is not a directory %(extra)s"
 
371
 
 
372
 
 
373
class NotInWorkingDirectory(PathError):
 
374
 
 
375
    _fmt = "%(path)r is not in the working directory %(extra)s"
 
376
 
 
377
 
333
378
class DirectoryNotEmpty(PathError):
334
379
 
335
380
    _fmt = "Directory not empty: %(path)r%(extra)s"
371
416
        self.args = [base] + list(args)
372
417
 
373
418
 
 
419
class UnknownHook(BzrError):
 
420
 
 
421
    _fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
 
422
 
 
423
    def __init__(self, hook_type, hook_name):
 
424
        BzrError.__init__(self)
 
425
        self.type = hook_type
 
426
        self.hook = hook_name
 
427
 
 
428
 
374
429
class UnsupportedProtocol(PathError):
375
430
 
376
431
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
502
557
        self.repo_format = repo_format
503
558
 
504
559
 
 
560
class AlreadyVersionedError(BzrError):
 
561
    """Used when a path is expected not to be versioned, but it is."""
 
562
 
 
563
    _fmt = "%(context_info)s%(path)s is already versioned"
 
564
 
 
565
    def __init__(self, path, context_info=None):
 
566
        """Construct a new NotVersionedError.
 
567
 
 
568
        :param path: This is the path which is versioned,
 
569
        which should be in a user friendly form.
 
570
        :param context_info: If given, this is information about the context,
 
571
        which could explain why this is expected to not be versioned.
 
572
        """
 
573
        BzrError.__init__(self)
 
574
        self.path = path
 
575
        if context_info is None:
 
576
            self.context_info = ''
 
577
        else:
 
578
            self.context_info = context_info + ". "
 
579
 
 
580
 
505
581
class NotVersionedError(BzrError):
506
 
 
507
 
    _fmt = "%(path)s is not versioned"
508
 
 
509
 
    def __init__(self, path):
 
582
    """Used when a path is expected to be versioned, but it is not."""
 
583
 
 
584
    _fmt = "%(context_info)s%(path)s is not versioned"
 
585
 
 
586
    def __init__(self, path, context_info=None):
 
587
        """Construct a new NotVersionedError.
 
588
 
 
589
        :param path: This is the path which is not versioned,
 
590
        which should be in a user friendly form.
 
591
        :param context_info: If given, this is information about the context,
 
592
        which could explain why this is expected to be versioned.
 
593
        """
510
594
        BzrError.__init__(self)
511
595
        self.path = path
 
596
        if context_info is None:
 
597
            self.context_info = ''
 
598
        else:
 
599
            self.context_info = context_info + ". "
512
600
 
513
601
 
514
602
class PathsNotVersionedError(BzrError):
515
 
    # used when reporting several paths are not versioned
 
603
    """Used when reporting several paths which are not versioned"""
516
604
 
517
605
    _fmt = "Path(s) are not versioned: %(paths_as_string)s"
518
606
 
525
613
 
526
614
class PathsDoNotExist(BzrError):
527
615
 
528
 
    _fmt = "Path(s) do not exist: %(paths_as_string)s"
 
616
    _fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
529
617
 
530
618
    # used when reporting that paths are neither versioned nor in the working
531
619
    # tree
532
620
 
533
 
    def __init__(self, paths):
 
621
    def __init__(self, paths, extra=None):
534
622
        # circular import
535
623
        from bzrlib.osutils import quotefn
536
624
        BzrError.__init__(self)
537
625
        self.paths = paths
538
626
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
 
627
        if extra:
 
628
            self.extra = ': ' + str(extra)
 
629
        else:
 
630
            self.extra = ''
539
631
 
540
632
 
541
633
class BadFileKindError(BzrError):
552
644
 
553
645
    _fmt = "Lock error: %(message)s"
554
646
 
 
647
    internal_error = True
 
648
 
555
649
    # All exceptions from the lock/unlock functions should be from
556
650
    # this exception class.  They will be translated as necessary. The
557
651
    # original exception is available as e.original_error
594
688
 
595
689
    _fmt = "%(obj)r is not locked"
596
690
 
597
 
    internal_error = True
598
 
 
599
691
    # this can indicate that any particular object is not locked; see also
600
692
    # LockNotHeld which means that a particular *lock* object is not held by
601
693
    # the caller -- perhaps they should be unified.
622
714
class LockContention(LockError):
623
715
 
624
716
    _fmt = "Could not acquire lock %(lock)s"
625
 
    # TODO: show full url for lock, combining the transport and relative bits?
 
717
    # TODO: show full url for lock, combining the transport and relative
 
718
    # bits?
 
719
 
 
720
    internal_error = False
626
721
    
627
722
    def __init__(self, lock):
628
723
        self.lock = lock
632
727
 
633
728
    _fmt = "Lock was broken while still open: %(lock)s - check storage consistency!"
634
729
 
 
730
    internal_error = False
 
731
 
635
732
    def __init__(self, lock):
636
733
        self.lock = lock
637
734
 
640
737
 
641
738
    _fmt = "Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"
642
739
 
 
740
    internal_error = False
 
741
 
643
742
    def __init__(self, lock, holder, target):
644
743
        self.lock = lock
645
744
        self.holder = holder
650
749
 
651
750
    _fmt = "Lock not held: %(lock)s"
652
751
 
 
752
    internal_error = False
 
753
 
653
754
    def __init__(self, lock):
654
755
        self.lock = lock
655
756
 
940
1041
    
941
1042
    _fmt = "Knit error"
942
1043
 
 
1044
    internal_error = True
 
1045
 
943
1046
 
944
1047
class KnitHeaderError(KnitError):
945
1048
 
961
1064
        self.how = how
962
1065
 
963
1066
 
 
1067
class KnitIndexUnknownMethod(KnitError):
 
1068
    """Raised when we don't understand the storage method.
 
1069
 
 
1070
    Currently only 'fulltext' and 'line-delta' are supported.
 
1071
    """
 
1072
    
 
1073
    _fmt = ("Knit index %(filename)s does not have a known method"
 
1074
            " in options: %(options)r")
 
1075
 
 
1076
    def __init__(self, filename, options):
 
1077
        KnitError.__init__(self)
 
1078
        self.filename = filename
 
1079
        self.options = options
 
1080
 
 
1081
 
964
1082
class NoSuchExportFormat(BzrError):
965
1083
    
966
1084
    _fmt = "Export format %(format)r not supported"
1263
1381
    _fmt = "Moving the root directory is not supported at this time"
1264
1382
 
1265
1383
 
 
1384
class BzrMoveFailedError(BzrError):
 
1385
 
 
1386
    _fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
 
1387
 
 
1388
    def __init__(self, from_path='', to_path='', extra=None):
 
1389
        BzrError.__init__(self)
 
1390
        if extra:
 
1391
            self.extra = ': ' + str(extra)
 
1392
        else:
 
1393
            self.extra = ''
 
1394
 
 
1395
        has_from = len(from_path) > 0
 
1396
        has_to = len(to_path) > 0
 
1397
        if has_from:
 
1398
            self.from_path = osutils.splitpath(from_path)[-1]
 
1399
        else:
 
1400
            self.from_path = ''
 
1401
 
 
1402
        if has_to:
 
1403
            self.to_path = osutils.splitpath(to_path)[-1]
 
1404
        else:
 
1405
            self.to_path = ''
 
1406
 
 
1407
        self.operator = ""
 
1408
        if has_from and has_to:
 
1409
            self.operator = " =>"
 
1410
        elif has_from:
 
1411
            self.from_path = "from " + from_path
 
1412
        elif has_to:
 
1413
            self.operator = "to"
 
1414
        else:
 
1415
            self.operator = "file"
 
1416
 
 
1417
 
 
1418
class BzrRenameFailedError(BzrMoveFailedError):
 
1419
 
 
1420
    _fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
 
1421
 
 
1422
    def __init__(self, from_path, to_path, extra=None):
 
1423
        BzrMoveFailedError.__init__(self, from_path, to_path, extra)
 
1424
 
 
1425
 
1266
1426
class BzrBadParameterNotString(BzrBadParameter):
1267
1427
 
1268
1428
    _fmt = "Parameter %(param)s is not a string or unicode string."