21
from bzrlib import symbol_versioning
22
from bzrlib.patches import (PatchSyntax,
25
from bzrlib.patches import (
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
218
class ReservedId(BzrError):
220
_fmt = "Reserved revision-id {%(revision_id)s}"
222
def __init__(self, revision_id):
223
self.revision_id = revision_id
214
225
class NoSuchId(BzrError):
300
311
_fmt = "Error in command line options"
314
class BadOptionValue(BzrError):
316
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
318
def __init__(self, name, value):
319
BzrError.__init__(self, name=name, value=value)
303
322
class StrictCommitFailed(BzrError):
330
349
_fmt = "File exists: %(path)r%(extra)s"
352
class RenameFailedFilesExist(BzrError):
353
"""Used when renaming and both source and dest exist."""
355
_fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
358
def __init__(self, source, dest, extra=None):
359
BzrError.__init__(self)
360
self.source = str(source)
361
self.dest = str(dest)
363
self.extra = ' ' + str(extra)
368
class NotADirectory(PathError):
370
_fmt = "%(path)r is not a directory %(extra)s"
373
class NotInWorkingDirectory(PathError):
375
_fmt = "%(path)r is not in the working directory %(extra)s"
333
378
class DirectoryNotEmpty(PathError):
335
380
_fmt = "Directory not empty: %(path)r%(extra)s"
371
416
self.args = [base] + list(args)
419
class UnknownHook(BzrError):
421
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
423
def __init__(self, hook_type, hook_name):
424
BzrError.__init__(self)
425
self.type = hook_type
426
self.hook = hook_name
374
429
class UnsupportedProtocol(PathError):
376
431
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
502
557
self.repo_format = repo_format
560
class AlreadyVersionedError(BzrError):
561
"""Used when a path is expected not to be versioned, but it is."""
563
_fmt = "%(context_info)s%(path)s is already versioned"
565
def __init__(self, path, context_info=None):
566
"""Construct a new NotVersionedError.
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.
573
BzrError.__init__(self)
575
if context_info is None:
576
self.context_info = ''
578
self.context_info = context_info + ". "
505
581
class NotVersionedError(BzrError):
507
_fmt = "%(path)s is not versioned"
509
def __init__(self, path):
582
"""Used when a path is expected to be versioned, but it is not."""
584
_fmt = "%(context_info)s%(path)s is not versioned"
586
def __init__(self, path, context_info=None):
587
"""Construct a new NotVersionedError.
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.
510
594
BzrError.__init__(self)
596
if context_info is None:
597
self.context_info = ''
599
self.context_info = context_info + ". "
514
602
class PathsNotVersionedError(BzrError):
515
# used when reporting several paths are not versioned
603
"""Used when reporting several paths which are not versioned"""
517
605
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
526
614
class PathsDoNotExist(BzrError):
528
_fmt = "Path(s) do not exist: %(paths_as_string)s"
616
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
530
618
# used when reporting that paths are neither versioned nor in the working
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])
628
self.extra = ': ' + str(extra)
541
633
class BadFileKindError(BzrError):
553
645
_fmt = "Lock error: %(message)s"
647
internal_error = True
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
595
689
_fmt = "%(obj)r is not locked"
597
internal_error = True
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):
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
720
internal_error = False
627
722
def __init__(self, lock):
1067
class KnitIndexUnknownMethod(KnitError):
1068
"""Raised when we don't understand the storage method.
1070
Currently only 'fulltext' and 'line-delta' are supported.
1073
_fmt = ("Knit index %(filename)s does not have a known method"
1074
" in options: %(options)r")
1076
def __init__(self, filename, options):
1077
KnitError.__init__(self)
1078
self.filename = filename
1079
self.options = options
964
1082
class NoSuchExportFormat(BzrError):
966
1084
_fmt = "Export format %(format)r not supported"
1263
1381
_fmt = "Moving the root directory is not supported at this time"
1384
class BzrMoveFailedError(BzrError):
1386
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1388
def __init__(self, from_path='', to_path='', extra=None):
1389
BzrError.__init__(self)
1391
self.extra = ': ' + str(extra)
1395
has_from = len(from_path) > 0
1396
has_to = len(to_path) > 0
1398
self.from_path = osutils.splitpath(from_path)[-1]
1403
self.to_path = osutils.splitpath(to_path)[-1]
1408
if has_from and has_to:
1409
self.operator = " =>"
1411
self.from_path = "from " + from_path
1413
self.operator = "to"
1415
self.operator = "file"
1418
class BzrRenameFailedError(BzrMoveFailedError):
1420
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1422
def __init__(self, from_path, to_path, extra=None):
1423
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1266
1426
class BzrBadParameterNotString(BzrBadParameter):
1268
1428
_fmt = "Parameter %(param)s is not a string or unicode string."