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):
327
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"
330
367
class DirectoryNotEmpty(PathError):
332
369
_fmt = "Directory not empty: %(path)r%(extra)s"
368
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
371
418
class UnsupportedProtocol(PathError):
373
420
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
499
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 + ". "
502
570
class NotVersionedError(BzrError):
504
_fmt = "%(path)s is not versioned"
506
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.
507
583
BzrError.__init__(self)
585
if context_info is None:
586
self.context_info = ''
588
self.context_info = context_info + ". "
511
591
class PathsNotVersionedError(BzrError):
512
# used when reporting several paths are not versioned
592
"""Used when reporting several paths which are not versioned"""
514
594
_fmt = "Path(s) are not versioned: %(paths_as_string)s"
523
603
class PathsDoNotExist(BzrError):
525
_fmt = "Path(s) do not exist: %(paths_as_string)s"
605
_fmt = "Path(s) do not exist: %(paths_as_string)s%(extra)s"
527
607
# used when reporting that paths are neither versioned nor in the working
530
def __init__(self, paths):
610
def __init__(self, paths, extra=None):
531
611
# circular import
532
612
from bzrlib.osutils import quotefn
533
613
BzrError.__init__(self)
534
614
self.paths = paths
535
615
self.paths_as_string = ' '.join([quotefn(p) for p in paths])
617
self.extra = ': ' + str(extra)
538
622
class BadFileKindError(BzrError):
1286
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)
1289
1415
class BzrBadParameterNotString(BzrBadParameter):
1291
1417
_fmt = "Parameter %(param)s is not a string or unicode string."
1551
1677
class NoSmartMedium(BzrError):
1553
1679
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1680
internal_error = True
1555
1682
def __init__(self, transport):
1556
1683
self.transport = transport