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
199
204
self.revision_id = revision_id
200
205
self.branch = branch
207
class ReservedId(BzrError):
209
_fmt = "Reserved revision-id {%(revision_id)s}"
211
def __init__(self, revision_id):
212
self.revision_id = revision_id
203
214
class NoSuchId(BzrError):
289
300
_fmt = "Error in command line options"
303
class BadOptionValue(BzrError):
305
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
307
def __init__(self, name, value):
308
BzrError.__init__(self, name=name, value=value)
292
311
class StrictCommitFailed(BzrError):
319
338
_fmt = "File exists: %(path)r%(extra)s"
341
class RenameFailedFilesExist(BzrError):
342
"""Used when renaming and both source and dest exist."""
344
_fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
347
def __init__(self, source, dest, extra=None):
348
BzrError.__init__(self)
349
self.source = str(source)
350
self.dest = str(dest)
352
self.extra = ' ' + str(extra)
357
class NotADirectory(PathError):
359
_fmt = "%(path)r is not a directory %(extra)s"
362
class NotInWorkingDirectory(PathError):
364
_fmt = "%(path)r is not in the working directory %(extra)s"
322
367
class DirectoryNotEmpty(PathError):
324
369
_fmt = "Directory not empty: %(path)r%(extra)s"
360
405
self.args = [base] + list(args)
408
class UnknownHook(BzrError):
410
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
412
def __init__(self, hook_type, hook_name):
413
BzrError.__init__(self)
414
self.type = hook_type
415
self.hook = hook_name
363
418
class UnsupportedProtocol(PathError):
365
420
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
491
546
self.repo_format = repo_format
549
class AlreadyVersionedError(BzrError):
550
"""Used when a path is expected not to be versioned, but it is."""
552
_fmt = "%(context_info)s%(path)s is already versioned"
554
def __init__(self, path, context_info=None):
555
"""Construct a new NotVersionedError.
557
:param path: This is the path which is versioned,
558
which should be in a user friendly form.
559
:param context_info: If given, this is information about the context,
560
which could explain why this is expected to not be versioned.
562
BzrError.__init__(self)
564
if context_info is None:
565
self.context_info = ''
567
self.context_info = context_info + ". "
494
570
class NotVersionedError(BzrError):
496
_fmt = "%(path)s is not versioned"
498
def __init__(self, path):
571
"""Used when a path is expected to be versioned, but it is not."""
573
_fmt = "%(context_info)s%(path)s is not versioned"
575
def __init__(self, path, context_info=None):
576
"""Construct a new NotVersionedError.
578
:param path: This is the path which is not versioned,
579
which should be in a user friendly form.
580
:param context_info: If given, this is information about the context,
581
which could explain why this is expected to be versioned.
499
583
BzrError.__init__(self)
585
if context_info is None:
586
self.context_info = ''
588
self.context_info = context_info + ". "
503
591
class PathsNotVersionedError(BzrError):
504
# used when reporting several paths are not versioned
592
"""Used when reporting several paths which are not versioned"""
506
594
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
515
603
class PathsDoNotExist(BzrError):
517
_fmt = "Path(s) do not exist: %(paths_as_string)s"
605
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
519
607
# used when reporting that paths are neither versioned nor in the working
522
def __init__(self, paths):
610
def __init__(self, paths, extra=None):
523
611
# circular import
524
612
from bzrlib.osutils import quotefn
525
613
BzrError.__init__(self)
526
614
self.paths = paths
527
615
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
617
self.extra = ': ' + str(extra)
530
622
class BadFileKindError(BzrError):
542
634
_fmt = "Lock error: %(message)s"
636
internal_error = True
544
638
# All exceptions from the lock/unlock functions should be from
545
639
# this exception class. They will be translated as necessary. The
546
640
# original exception is available as e.original_error
584
678
_fmt = "%(obj)r is not locked"
586
internal_error = True
588
680
# this can indicate that any particular object is not locked; see also
589
681
# LockNotHeld which means that a particular *lock* object is not held by
590
682
# the caller -- perhaps they should be unified.
611
703
class LockContention(LockError):
613
705
_fmt = "Could not acquire lock %(lock)s"
614
# TODO: show full url for lock, combining the transport and relative bits?
706
# TODO: show full url for lock, combining the transport and relative
709
internal_error = False
616
711
def __init__(self, lock):
1269
1370
_fmt = "Moving the root directory is not supported at this time"
1373
class BzrMoveFailedError(BzrError):
1375
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1377
def __init__(self, from_path='', to_path='', extra=None):
1378
BzrError.__init__(self)
1380
self.extra = ': ' + str(extra)
1384
has_from = len(from_path) > 0
1385
has_to = len(to_path) > 0
1387
self.from_path = osutils.splitpath(from_path)[-1]
1392
self.to_path = osutils.splitpath(to_path)[-1]
1397
if has_from and has_to:
1398
self.operator = " =>"
1400
self.from_path = "from " + from_path
1402
self.operator = "to"
1404
self.operator = "file"
1407
class BzrRenameFailedError(BzrMoveFailedError):
1409
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1411
def __init__(self, from_path, to_path, extra=None):
1412
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1272
1415
class BzrBadParameterNotString(BzrBadParameter):
1274
1417
_fmt = "Parameter %(param)s is not a string or unicode string."