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"
491
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 + ". "
494
560
class NotVersionedError(BzrError):
496
_fmt = "%(path)s is not versioned"
498
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.
499
573
BzrError.__init__(self)
575
if context_info is None:
576
self.context_info = ''
578
self.context_info = context_info + ". "
503
581
class PathsNotVersionedError(BzrError):
504
# used when reporting several paths are not versioned
582
"""Used when reporting several paths which are not versioned"""
506
584
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
515
593
class PathsDoNotExist(BzrError):
517
_fmt = "Path(s) do not exist: %(paths_as_string)s"
595
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
519
597
# used when reporting that paths are neither versioned nor in the working
522
def __init__(self, paths):
600
def __init__(self, paths, extra=None):
523
601
# circular import
524
602
from bzrlib.osutils import quotefn
525
603
BzrError.__init__(self)
526
604
self.paths = paths
527
605
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
607
self.extra = ': ' + str(extra)
530
612
class BadFileKindError(BzrError):
1281
1363
_fmt = "Moving the root directory is not supported at this time"
1366
class BzrMoveFailedError(BzrError):
1368
_fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1370
def __init__(self, from_path='', to_path='', extra=None):
1371
BzrError.__init__(self)
1373
self.extra = ': ' + str(extra)
1377
has_from = len(from_path) > 0
1378
has_to = len(to_path) > 0
1380
self.from_path = osutils.splitpath(from_path)[-1]
1385
self.to_path = osutils.splitpath(to_path)[-1]
1390
if has_from and has_to:
1391
self.operator = " =>"
1393
self.from_path = "from " + from_path
1395
self.operator = "to"
1397
self.operator = "file"
1400
class BzrRenameFailedError(BzrMoveFailedError):
1402
_fmt = "Could not rename %(from_path)s%(operator)s %(to_path)s%(extra)s"
1404
def __init__(self, from_path, to_path, extra=None):
1405
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1284
1408
class BzrBadParameterNotString(BzrBadParameter):
1286
1410
_fmt = "Parameter %(param)s is not a string or unicode string."