171
150
class StrictCommitFailed(Exception):
172
151
"""Commit refused because there are unknowns in the tree."""
175
class PathError(BzrNewError):
176
"""Generic path error: %(path)r%(extra)s)"""
178
def __init__(self, path, extra=None):
179
BzrNewError.__init__(self)
182
self.extra = ': ' + str(extra)
187
class NoSuchFile(PathError):
188
"""No such file: %(path)r%(extra)s"""
191
class FileExists(PathError):
192
"""File exists: %(path)r%(extra)s"""
195
class DirectoryNotEmpty(PathError):
196
"""Directory not empty: %(path)r%(extra)s"""
199
class ResourceBusy(PathError):
200
"""Device or resource busy: %(path)r%(extra)s"""
203
class PermissionDenied(PathError):
204
"""Permission denied: %(path)r%(extra)s"""
207
class PathNotChild(BzrNewError):
208
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
209
def __init__(self, path, base, extra=None):
210
BzrNewError.__init__(self)
214
self.extra = ': ' + str(extra)
219
class NotBranchError(PathError):
153
class NotBranchError(BzrNewError):
220
154
"""Not a branch: %(path)s"""
223
class AlreadyBranchError(PathError):
224
"""Already a branch: %(path)s. Use `bzr checkout` to build a working tree."""
227
class NoRepositoryPresent(BzrNewError):
228
"""Not repository present: %(path)r"""
229
def __init__(self, bzrdir):
230
BzrNewError.__init__(self)
231
self.path = bzrdir.transport.clone('..').base
234
class FileInWrongBranch(BzrNewError):
235
"""File %(path)s in not in branch %(branch_base)s."""
237
def __init__(self, branch, path):
238
BzrNewError.__init__(self)
240
self.branch_base = branch.base
155
def __init__(self, path):
156
BzrNewError.__init__(self)
244
160
class UnsupportedFormatError(BzrError):
245
"""Specified path is a bzr branch that we recognize but cannot read."""
161
"""Specified path is a bzr branch that we cannot read."""
246
162
def __str__(self):
247
163
return 'unsupported branch format: %s' % self.args[0]
250
class UnknownFormatError(BzrError):
251
"""Specified path is a bzr branch whose format we do not recognize."""
253
return 'unknown branch format: %s' % self.args[0]
256
class IncompatibleFormat(BzrNewError):
257
"""Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
259
def __init__(self, format, bzrdir_format):
260
BzrNewError.__init__(self)
262
self.bzrdir = bzrdir_format
265
166
class NotVersionedError(BzrNewError):
266
167
"""%(path)s is not versioned"""
267
168
def __init__(self, path):
290
180
"""Cannot operate on a file because it is a control file."""
293
class LockError(BzrNewError):
294
"""Lock error: %(message)s"""
183
class LockError(Exception):
295
185
# All exceptions from the lock/unlock functions should be from
296
186
# this exception class. They will be translated as necessary. The
297
187
# original exception is available as e.original_error
299
# New code should prefer to raise specific subclasses
300
def __init__(self, message):
301
self.message = message
304
190
class CommitNotPossible(LockError):
305
191
"""A commit was attempted but we do not have a write lock open."""
310
194
class AlreadyCommitted(LockError):
311
195
"""A rollback was requested, but is not able to be accomplished."""
316
198
class ReadOnlyError(LockError):
317
"""A write attempt was made in a read only transaction on %(obj)s"""
318
def __init__(self, obj):
322
class OutSideTransaction(BzrNewError):
323
"""A transaction related operation was attempted after the transaction finished."""
326
class ObjectNotLocked(LockError):
327
"""%(obj)r is not locked"""
328
# this can indicate that any particular object is not locked; see also
329
# LockNotHeld which means that a particular *lock* object is not held by
330
# the caller -- perhaps they should be unified.
331
def __init__(self, obj):
335
class ReadOnlyObjectDirtiedError(ReadOnlyError):
336
"""Cannot change object %(obj)r in read only transaction"""
337
def __init__(self, obj):
341
class UnlockableTransport(LockError):
342
"""Cannot lock: transport is read only: %(transport)s"""
343
def __init__(self, transport):
344
self.transport = transport
347
class LockContention(LockError):
348
"""Could not acquire lock %(lock)s"""
349
# TODO: show full url for lock, combining the transport and relative bits?
350
def __init__(self, lock):
354
class LockBroken(LockError):
355
"""Lock was broken while still open: %(lock)s - check storage consistency!"""
356
def __init__(self, lock):
360
class LockBreakMismatch(LockError):
361
"""Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"""
362
def __init__(self, lock, holder, target):
368
class LockNotHeld(LockError):
369
"""Lock not held: %(lock)s"""
370
def __init__(self, lock):
199
"""A write attempt was made in a read only transaction."""
374
202
class PointlessCommit(BzrNewError):
375
203
"""No changes to commit"""
378
class UpgradeReadonly(BzrNewError):
379
"""Upgrade URL cannot work with readonly URL's."""
382
class UpToDateFormat(BzrNewError):
383
"""The branch format %(format)s is already at the most recent format."""
385
def __init__(self, format):
386
BzrNewError.__init__(self)
391
205
class StrictCommitFailed(Exception):
392
206
"""Commit refused because there are unknowns in the tree."""
395
208
class NoSuchRevision(BzrError):
396
209
def __init__(self, branch, revision):
397
210
self.branch = branch
423
235
BzrCommandError.__init__(self, msg)
426
237
class NoCommonAncestor(BzrError):
427
238
def __init__(self, revision_a, revision_b):
428
239
msg = "Revisions have no common ancestor: %s %s." \
429
240
% (revision_a, revision_b)
430
241
BzrError.__init__(self, msg)
433
243
class NoCommonRoot(BzrError):
434
244
def __init__(self, revision_a, revision_b):
435
245
msg = "Revisions are not derived from the same root: %s %s." \
436
246
% (revision_a, revision_b)
437
247
BzrError.__init__(self, msg)
441
class NotAncestor(BzrError):
442
def __init__(self, rev_id, not_ancestor_id):
443
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
445
BzrError.__init__(self, msg)
447
self.not_ancestor_id = not_ancestor_id
249
class NotAncestor(BzrError):
250
def __init__(self, rev_id, not_ancestor_id):
251
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
253
BzrError.__init__(self, msg)
255
self.not_ancestor_id = not_ancestor_id
258
class NotAncestor(BzrError):
259
def __init__(self, rev_id, not_ancestor_id):
261
self.not_ancestor_id = not_ancestor_id
262
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
264
BzrError.__init__(self, msg)
450
267
class InstallFailed(BzrError):
457
274
class AmbiguousBase(BzrError):
458
275
def __init__(self, bases):
459
warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
461
276
msg = "The correct base is unclear, becase %s are all equally close" %\
463
278
BzrError.__init__(self, msg)
464
279
self.bases = bases
467
281
class NoCommits(BzrError):
468
282
def __init__(self, branch):
469
283
msg = "Branch %s has no commits." % branch
470
284
BzrError.__init__(self, msg)
473
286
class UnlistableStore(BzrError):
474
287
def __init__(self, store):
475
288
BzrError.__init__(self, "Store %s is not listable" % store)
479
290
class UnlistableBranch(BzrError):
480
291
def __init__(self, br):
481
292
BzrError.__init__(self, "Stores for branch %s are not listable" % br)
484
class BoundBranchOutOfDate(BzrNewError):
485
"""Bound branch %(branch)s is out of date with master branch %(master)s."""
486
def __init__(self, branch, master):
487
BzrNewError.__init__(self)
492
class CommitToDoubleBoundBranch(BzrNewError):
493
"""Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."""
494
def __init__(self, branch, master, remote):
495
BzrNewError.__init__(self)
501
class OverwriteBoundBranch(BzrNewError):
502
"""Cannot pull --overwrite to a branch which is bound %(branch)s"""
503
def __init__(self, branch):
504
BzrNewError.__init__(self)
508
class BoundBranchConnectionFailure(BzrNewError):
509
"""Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"""
510
def __init__(self, branch, target, error):
511
BzrNewError.__init__(self)
517
295
class WeaveError(BzrNewError):
518
296
"""Error in processing weave: %(message)s"""
520
297
def __init__(self, message=None):
521
298
BzrNewError.__init__(self)
522
299
self.message = message
552
326
"""Parents are mismatched between two revisions."""
555
class WeaveInvalidChecksum(WeaveError):
556
"""Text did not match it's checksum: %(message)s"""
559
class WeaveTextDiffers(WeaveError):
560
"""Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
562
def __init__(self, revision_id, weave_a, weave_b):
563
WeaveError.__init__(self)
564
self.revision_id = revision_id
565
self.weave_a = weave_a
566
self.weave_b = weave_b
569
class WeaveTextDiffers(WeaveError):
570
"""Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
572
def __init__(self, revision_id, weave_a, weave_b):
573
WeaveError.__init__(self)
574
self.revision_id = revision_id
575
self.weave_a = weave_a
576
self.weave_b = weave_b
579
class VersionedFileError(BzrNewError):
580
"""Versioned file error."""
583
class RevisionNotPresent(VersionedFileError):
584
"""Revision {%(revision_id)s} not present in %(file_id)s."""
586
def __init__(self, revision_id, file_id):
587
VersionedFileError.__init__(self)
588
self.revision_id = revision_id
589
self.file_id = file_id
592
class RevisionAlreadyPresent(VersionedFileError):
593
"""Revision {%(revision_id)s} already present in %(file_id)s."""
595
def __init__(self, revision_id, file_id):
596
VersionedFileError.__init__(self)
597
self.revision_id = revision_id
598
self.file_id = file_id
601
class KnitError(BzrNewError):
605
class KnitHeaderError(KnitError):
606
"""Knit header error: %(badline)r unexpected"""
608
def __init__(self, badline):
609
KnitError.__init__(self)
610
self.badline = badline
613
class KnitCorrupt(KnitError):
614
"""Knit %(filename)s corrupt: %(how)s"""
616
def __init__(self, filename, how):
617
KnitError.__init__(self)
618
self.filename = filename
622
class NoSuchExportFormat(BzrNewError):
623
"""Export format %(format)r not supported"""
624
def __init__(self, format):
625
BzrNewError.__init__(self)
629
329
class TransportError(BzrError):
630
330
"""All errors thrown by Transport implementations should derive
649
class ConnectionError(TransportError):
650
"""A connection problem prevents file retrieval.
651
This does not indicate whether the file exists or not; it indicates that a
652
precondition for requesting the file was not met.
654
def __init__(self, msg=None, orig_error=None):
655
TransportError.__init__(self, msg=msg, orig_error=orig_error)
347
class NonRelativePath(TransportError):
348
"""An absolute path was supplied, that could not be decoded into
353
class NoSuchFile(TransportError, IOError):
354
"""A get() was issued for a file that doesn't exist."""
356
# XXX: Is multiple inheritance for exceptions really needed?
359
return 'no such file: ' + self.msg
361
def __init__(self, msg=None, orig_error=None):
363
TransportError.__init__(self, msg=msg, orig_error=orig_error)
364
IOError.__init__(self, errno.ENOENT, self.msg)
366
class FileExists(TransportError, OSError):
367
"""An operation was attempted, which would overwrite an entry,
368
but overwritting is not supported.
370
mkdir() can throw this, but put() just overwites existing files.
372
# XXX: Is multiple inheritance for exceptions really needed?
373
def __init__(self, msg=None, orig_error=None):
375
TransportError.__init__(self, msg=msg, orig_error=orig_error)
376
OSError.__init__(self, errno.EEXIST, self.msg)
378
class PermissionDenied(TransportError):
379
"""An operation cannot succeed because of a lack of permissions."""
658
382
class ConnectionReset(TransportError):
659
383
"""The connection has been closed."""
663
386
class ConflictsInTree(BzrError):
664
387
def __init__(self):
665
388
BzrError.__init__(self, "Working tree has conflicts.")
668
390
class ParseConfigError(BzrError):
669
391
def __init__(self, errors, filename):
670
392
if filename is None:
673
395
(filename, ('\n'.join(e.message for e in errors)))
674
396
BzrError.__init__(self, message)
677
398
class SigningFailed(BzrError):
678
399
def __init__(self, command_line):
679
400
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
683
403
class WorkingTreeNotRevision(BzrError):
684
404
def __init__(self, tree):
685
405
BzrError.__init__(self, "The working tree for %s has changed since"
686
406
" last commit, but weave merge requires that it be"
687
407
" unchanged." % tree.basedir)
690
409
class CantReprocessAndShowBase(BzrNewError):
691
410
"""Can't reprocess and show base.
692
411
Reprocessing obscures relationship of conflicting lines to base."""
695
413
class GraphCycleError(BzrNewError):
696
414
"""Cycle in graph %(graph)r"""
697
415
def __init__(self, graph):
698
416
BzrNewError.__init__(self)
699
417
self.graph = graph
702
class NotConflicted(BzrNewError):
703
"""File %(filename)s is not conflicted."""
705
def __init__(self, filename):
706
BzrNewError.__init__(self)
707
self.filename = filename
710
419
class MustUseDecorated(Exception):
711
420
"""A decorating function has requested its original command be used.
713
422
This should never escape bzr, so does not need to be printable.
717
class MissingText(BzrNewError):
718
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
720
def __init__(self, branch, text_revision, file_id):
721
BzrNewError.__init__(self)
723
self.base = branch.base
724
self.text_revision = text_revision
725
self.file_id = file_id
728
class DuplicateKey(BzrNewError):
729
"""Key %(key)s is already present in map"""
732
class MalformedTransform(BzrNewError):
733
"""Tree transform is malformed %(conflicts)r"""
736
class BzrBadParameter(BzrNewError):
737
"""A bad parameter : %(param)s is not usable.
739
This exception should never be thrown, but it is a base class for all
740
parameter-to-function errors.
742
def __init__(self, param):
743
BzrNewError.__init__(self)
747
class BzrBadParameterNotUnicode(BzrBadParameter):
748
"""Parameter %(param)s is neither unicode nor utf8."""
751
class ReusingTransform(BzrNewError):
752
"""Attempt to reuse a transform that has already been applied."""
755
class CantMoveRoot(BzrNewError):
756
"""Moving the root directory is not supported at this time"""
759
class BzrBadParameterNotString(BzrBadParameter):
760
"""Parameter %(param)s is not a string or unicode string."""
763
class BzrBadParameterMissing(BzrBadParameter):
764
"""Parameter $(param)s is required but not present."""
767
class DependencyNotPresent(BzrNewError):
768
"""Unable to import library "%(library)s": %(error)s"""
770
def __init__(self, library, error):
771
BzrNewError.__init__(self, library=library, error=error)
774
class ParamikoNotPresent(DependencyNotPresent):
775
"""Unable to import paramiko (required for sftp support): %(error)s"""
777
def __init__(self, error):
778
DependencyNotPresent.__init__(self, 'paramiko', error)
781
class UninitializableFormat(BzrNewError):
782
"""Format %(format)s cannot be initialised by this version of bzr."""
784
def __init__(self, format):
785
BzrNewError.__init__(self)
789
class NoDiff3(BzrNewError):
790
"""Diff3 is not installed on this machine."""
793
class ExistingLimbo(BzrNewError):
794
"""This tree contains left-over files from a failed operation.
795
Please examine %(limbo_dir)s to see if it contains any files you wish to
796
keep, and delete it when you are done.
798
def __init__(self, limbo_dir):
799
BzrNewError.__init__(self)
800
self.limbo_dir = limbo_dir
803
class ImmortalLimbo(BzrNewError):
804
"""Unable to delete transform temporary directory $(limbo_dir)s.
805
Please examine %(limbo_dir)s to see if it contains any files you wish to
806
keep, and delete it when you are done.
808
def __init__(self, limbo_dir):
809
BzrNewError.__init__(self)
810
self.limbo_dir = limbo_dir
813
class OutOfDateTree(BzrNewError):
814
"""Working tree is out of date, please run 'bzr update'."""
816
def __init__(self, tree):
817
BzrNewError.__init__(self)
821
class MergeModifiedFormatError(BzrNewError):
822
"""Error in merge modified format"""
825
class ConflictFormatError(BzrNewError):
826
"""Format error in conflict listings"""
829
class CorruptRepository(BzrNewError):
830
"""An error has been detected in the repository %(repo_path)s.
831
Please run bzr reconcile on this repository."""
833
def __init__(self, repo):
834
BzrNewError.__init__(self)
835
self.repo_path = repo.bzrdir.root_transport.base
838
class UpgradeRequired(BzrNewError):
839
"""To use this feature you must upgrade your branch at %(path)s."""
841
def __init__(self, path):
842
BzrNewError.__init__(self)
846
class LocalRequiresBoundBranch(BzrNewError):
847
"""Cannot perform local-only commits on unbound branches."""
850
class MissingProgressBarFinish(BzrNewError):
851
"""A nested progress bar was not 'finished' correctly."""
854
class UnsupportedOperation(BzrNewError):
855
"""The method %(mname)s is not supported on objects of type %(tname)s."""
856
def __init__(self, method, method_self):
858
self.mname = method.__name__
859
self.tname = type(method_self).__name__