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
333
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"
336
367
class DirectoryNotEmpty(PathError):
338
369
_fmt = "Directory not empty: %(path)r%(extra)s"
374
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
377
418
class UnsupportedProtocol(PathError):
379
420
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
505
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 + ". "
508
570
class NotVersionedError(BzrError):
510
_fmt = "%(path)s is not versioned"
512
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.
513
583
BzrError.__init__(self)
585
if context_info is None:
586
self.context_info = ''
588
self.context_info = context_info + ". "
517
591
class PathsNotVersionedError(BzrError):
518
# used when reporting several paths are not versioned
592
"""Used when reporting several paths which are not versioned"""
520
594
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
529
603
class PathsDoNotExist(BzrError):
531
_fmt = "Path(s) do not exist: %(paths_as_string)s"
605
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
533
607
# used when reporting that paths are neither versioned nor in the working
536
def __init__(self, paths):
610
def __init__(self, paths, extra=None):
537
611
# circular import
538
612
from bzrlib.osutils import quotefn
539
613
BzrError.__init__(self)
540
614
self.paths = paths
541
615
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
617
self.extra = ': ' + str(extra)
544
622
class BadFileKindError(BzrError):
1303
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)
1306
1426
class BzrBadParameterNotString(BzrBadParameter):
1308
1428
_fmt = "Parameter %(param)s is not a string or unicode string."