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"
505
536
self.repo_format = repo_format
539
class AlreadyVersionedError(BzrError):
540
"""Used when a path is expected not to be versioned, but it is."""
542
_fmt = "%(context_info)s%(path)s is already versioned"
544
def __init__(self, path, context_info=None):
545
"""Construct a new NotVersionedError.
547
:param path: This is the path which is versioned,
548
which should be in a user friendly form.
549
:param context_info: If given, this is information about the context,
550
which could explain why this is expected to not be versioned.
552
BzrError.__init__(self)
554
if context_info is None:
555
self.context_info = ''
557
self.context_info = context_info + ". "
508
560
class NotVersionedError(BzrError):
510
_fmt = "%(path)s is not versioned"
512
def __init__(self, path):
561
"""Used when a path is expected to be versioned, but it is not."""
563
_fmt = "%(context_info)s%(path)s is not versioned"
565
def __init__(self, path, context_info=None):
566
"""Construct a new NotVersionedError.
568
:param path: This is the path which is not 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 be versioned.
513
573
BzrError.__init__(self)
575
if context_info is None:
576
self.context_info = ''
578
self.context_info = context_info + ". "
517
581
class PathsNotVersionedError(BzrError):
518
# used when reporting several paths are not versioned
582
"""Used when reporting several paths which are not versioned"""
520
584
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
529
593
class PathsDoNotExist(BzrError):
531
_fmt = "Path(s) do not exist: %(paths_as_string)s"
595
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
533
597
# used when reporting that paths are neither versioned nor in the working
536
def __init__(self, paths):
600
def __init__(self, paths, extra=None):
537
601
# circular import
538
602
from bzrlib.osutils import quotefn
539
603
BzrError.__init__(self)
540
604
self.paths = paths
541
605
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
607
self.extra = ': ' + str(extra)
544
612
class BadFileKindError(BzrError):
1292
1360
_fmt = "Moving the root directory is not supported at this time"
1363
class BzrMoveFailedError(BzrError):
1365
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1367
def __init__(self, from_path='', to_path='', extra=None):
1368
BzrError.__init__(self)
1370
self.extra = ': ' + str(extra)
1374
has_from = len(from_path) > 0
1375
has_to = len(to_path) > 0
1377
self.from_path = osutils.splitpath(from_path)[-1]
1382
self.to_path = osutils.splitpath(to_path)[-1]
1387
if has_from and has_to:
1388
self.operator = " =>"
1390
self.from_path = "from " + from_path
1392
self.operator = "to"
1394
self.operator = "file"
1397
class BzrRenameFailedError(BzrMoveFailedError):
1399
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1401
def __init__(self, from_path, to_path, extra=None):
1402
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1295
1405
class BzrBadParameterNotString(BzrBadParameter):
1297
1407
_fmt = "Parameter %(param)s is not a string or unicode string."