/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: John Arbash Meinel
  • Date: 2006-03-08 14:31:23 UTC
  • mfrom: (1598 +trunk)
  • mto: (1685.1.1 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060308143123-448308b0db4de410
[merge] bzr.dev 1573, lots of updates

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) 2005 Canonical
 
1
# Copyright (C) 2005, 2006 Canonical
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
105
105
 
106
106
class BzrCheckError(BzrNewError):
107
107
    """Internal check failed: %(message)s"""
 
108
 
108
109
    def __init__(self, message):
109
110
        BzrNewError.__init__(self)
110
111
        self.message = message
140
141
        self.base = base
141
142
 
142
143
 
 
144
class NotLocalUrl(BzrNewError):
 
145
    """%s(url) is not a local path."""
 
146
    
 
147
    def __init__(self, url):
 
148
        BzrNewError.__init__(self)
 
149
        self.url = url
 
150
 
 
151
 
143
152
class BzrCommandError(BzrError):
144
153
    # Error from malformed user command
145
154
    # This is being misused as a generic exception
180
189
    """File exists: %(path)r%(extra)s"""
181
190
 
182
191
 
 
192
class DirectoryNotEmpty(PathError):
 
193
    """Directory not empty: %(path)r%(extra)s"""
 
194
 
 
195
 
183
196
class PermissionDenied(PathError):
184
197
    """Permission denied: %(path)r%(extra)s"""
185
198
 
207
220
        self.path = path
208
221
 
209
222
 
 
223
class NoRepositoryPresent(BzrNewError):
 
224
    """Not repository present: %(path)r"""
 
225
    def __init__(self, bzrdir):
 
226
        BzrNewError.__init__(self)
 
227
        self.path = bzrdir.transport.clone('..').base
 
228
 
 
229
 
210
230
class FileInWrongBranch(BzrNewError):
211
231
    """File %(path)s in not in branch %(branch_base)s."""
 
232
 
212
233
    def __init__(self, branch, path):
213
234
        BzrNewError.__init__(self)
214
235
        self.branch = branch
228
249
        return 'unknown branch format: %s' % self.args[0]
229
250
 
230
251
 
 
252
class IncompatibleFormat(BzrNewError):
 
253
    """Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
 
254
 
 
255
    def __init__(self, format, bzrdir_format):
 
256
        BzrNewError.__init__(self)
 
257
        self.format = format
 
258
        self.bzrdir = bzrdir_format
 
259
 
 
260
 
231
261
class NotVersionedError(BzrNewError):
232
262
    """%(path)s is not versioned"""
233
263
    def __init__(self, path):
245
275
    """Cannot operate on a file because it is a control file."""
246
276
 
247
277
 
248
 
class LockError(Exception):
249
 
    """Lock error"""
 
278
class LockError(BzrNewError):
 
279
    """Lock error: %(message)s"""
250
280
    # All exceptions from the lock/unlock functions should be from
251
281
    # this exception class.  They will be translated as necessary. The
252
282
    # original exception is available as e.original_error
 
283
    #
 
284
    # New code should prefer to raise specific subclasses
 
285
    def __init__(self, message):
 
286
        self.message = message
253
287
 
254
288
 
255
289
class CommitNotPossible(LockError):
256
290
    """A commit was attempted but we do not have a write lock open."""
 
291
    def __init__(self):
 
292
        pass
257
293
 
258
294
 
259
295
class AlreadyCommitted(LockError):
260
296
    """A rollback was requested, but is not able to be accomplished."""
 
297
    def __init__(self):
 
298
        pass
261
299
 
262
300
 
263
301
class ReadOnlyError(LockError):
264
 
    """A write attempt was made in a read only transaction."""
 
302
    """A write attempt was made in a read only transaction on %(obj)s"""
 
303
    def __init__(self, obj):
 
304
        self.obj = obj
 
305
 
 
306
 
 
307
class ObjectNotLocked(LockError):
 
308
    """%(obj)r is not locked"""
 
309
    # this can indicate that any particular object is not locked; see also
 
310
    # LockNotHeld which means that a particular *lock* object is not held by
 
311
    # the caller -- perhaps they should be unified.
 
312
    def __init__(self, obj):
 
313
        self.obj = obj
 
314
 
 
315
 
 
316
class ReadOnlyObjectDirtiedError(ReadOnlyError):
 
317
    """Cannot change object %(obj)r in read only transaction"""
 
318
    def __init__(self, obj):
 
319
        self.obj = obj
 
320
 
 
321
 
 
322
class UnlockableTransport(LockError):
 
323
    """Cannot lock: transport is read only: %(transport)s"""
 
324
    def __init__(self, transport):
 
325
        self.transport = transport
 
326
 
 
327
 
 
328
class LockContention(LockError):
 
329
    """Could not acquire lock %(lock)s"""
 
330
    # TODO: show full url for lock, combining the transport and relative bits?
 
331
    def __init__(self, lock):
 
332
        self.lock = lock
 
333
 
 
334
 
 
335
class LockBroken(LockError):
 
336
    """Lock was broken while still open: %(lock)s - check storage consistency!"""
 
337
    def __init__(self, lock):
 
338
        self.lock = lock
 
339
 
 
340
 
 
341
class LockBreakMismatch(LockError):
 
342
    """Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"""
 
343
    def __init__(self, lock, holder, target):
 
344
        self.lock = lock
 
345
        self.holder = holder
 
346
        self.target = target
 
347
 
 
348
 
 
349
class LockNotHeld(LockError):
 
350
    """Lock not held: %(lock)s"""
 
351
    def __init__(self, lock):
 
352
        self.lock = lock
265
353
 
266
354
 
267
355
class PointlessCommit(BzrNewError):
272
360
    """Upgrade URL cannot work with readonly URL's."""
273
361
 
274
362
 
 
363
class UpToDateFormat(BzrNewError):
 
364
    """The branch format %(format)s is already at the most recent format."""
 
365
 
 
366
    def __init__(self, format):
 
367
        BzrNewError.__init__(self)
 
368
        self.format = format
 
369
 
 
370
 
 
371
 
275
372
class StrictCommitFailed(Exception):
276
373
    """Commit refused because there are unknowns in the tree."""
277
374
 
320
417
        BzrError.__init__(self, msg)
321
418
 
322
419
 
 
420
 
323
421
class NotAncestor(BzrError):
324
422
    def __init__(self, rev_id, not_ancestor_id):
325
423
        msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id, 
355
453
        BzrError.__init__(self, "Store %s is not listable" % store)
356
454
 
357
455
 
 
456
 
358
457
class UnlistableBranch(BzrError):
359
458
    def __init__(self, br):
360
459
        BzrError.__init__(self, "Stores for branch %s are not listable" % br)
361
460
 
362
461
 
 
462
class BoundBranchOutOfDate(BzrNewError):
 
463
    """Bound branch %(branch)s is out of date with master branch %(master)s."""
 
464
    def __init__(self, branch, master):
 
465
        BzrNewError.__init__(self)
 
466
        self.branch = branch
 
467
        self.master = master
 
468
 
 
469
        
 
470
class CommitToDoubleBoundBranch(BzrNewError):
 
471
    """Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."""
 
472
    def __init__(self, branch, master, remote):
 
473
        BzrNewError.__init__(self)
 
474
        self.branch = branch
 
475
        self.master = master
 
476
        self.remote = remote
 
477
 
 
478
 
 
479
class OverwriteBoundBranch(BzrNewError):
 
480
    """Cannot pull --overwrite to a branch which is bound %(branch)s"""
 
481
    def __init__(self, branch):
 
482
        BzrNewError.__init__(self)
 
483
        self.branch = branch
 
484
 
 
485
 
 
486
class BoundBranchConnectionFailure(BzrNewError):
 
487
    """Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"""
 
488
    def __init__(self, branch, target, error):
 
489
        BzrNewError.__init__(self)
 
490
        self.branch = branch
 
491
        self.target = target
 
492
        self.error = error
 
493
 
 
494
 
363
495
class WeaveError(BzrNewError):
364
496
    """Error in processing weave: %(message)s"""
 
497
 
365
498
    def __init__(self, message=None):
366
499
        BzrNewError.__init__(self)
367
500
        self.message = message
370
503
class WeaveRevisionAlreadyPresent(WeaveError):
371
504
    """Revision {%(revision_id)s} already present in %(weave)s"""
372
505
    def __init__(self, revision_id, weave):
 
506
 
373
507
        WeaveError.__init__(self)
374
508
        self.revision_id = revision_id
375
509
        self.weave = weave
377
511
 
378
512
class WeaveRevisionNotPresent(WeaveError):
379
513
    """Revision {%(revision_id)s} not present in %(weave)s"""
 
514
 
380
515
    def __init__(self, revision_id, weave):
381
516
        WeaveError.__init__(self)
382
517
        self.revision_id = revision_id
385
520
 
386
521
class WeaveFormatError(WeaveError):
387
522
    """Weave invariant violated: %(what)s"""
 
523
 
388
524
    def __init__(self, what):
389
525
        WeaveError.__init__(self)
390
526
        self.what = what
408
544
        self.weave_b = weave_b
409
545
 
410
546
 
 
547
class WeaveTextDiffers(WeaveError):
 
548
    """Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
 
549
 
 
550
    def __init__(self, revision_id, weave_a, weave_b):
 
551
        WeaveError.__init__(self)
 
552
        self.revision_id = revision_id
 
553
        self.weave_a = weave_a
 
554
        self.weave_b = weave_b
 
555
 
 
556
 
 
557
class VersionedFileError(BzrNewError):
 
558
    """Versioned file error."""
 
559
 
 
560
 
 
561
class RevisionNotPresent(VersionedFileError):
 
562
    """Revision {%(revision_id)s} not present in %(file_id)s."""
 
563
 
 
564
    def __init__(self, revision_id, file_id):
 
565
        VersionedFileError.__init__(self)
 
566
        self.revision_id = revision_id
 
567
        self.file_id = file_id
 
568
 
 
569
 
 
570
class RevisionAlreadyPresent(VersionedFileError):
 
571
    """Revision {%(revision_id)s} already present in %(file_id)s."""
 
572
 
 
573
    def __init__(self, revision_id, file_id):
 
574
        VersionedFileError.__init__(self)
 
575
        self.revision_id = revision_id
 
576
        self.file_id = file_id
 
577
 
 
578
 
 
579
class KnitError(BzrNewError):
 
580
    """Knit error"""
 
581
 
 
582
 
 
583
class KnitHeaderError(KnitError):
 
584
    """Knit header error: %(badline)r unexpected"""
 
585
 
 
586
    def __init__(self, badline):
 
587
        KnitError.__init__(self)
 
588
        self.badline = badline
 
589
 
 
590
 
 
591
class KnitCorrupt(KnitError):
 
592
    """Knit %(filename)s corrupt: %(how)s"""
 
593
 
 
594
    def __init__(self, filename, how):
 
595
        KnitError.__init__(self)
 
596
        self.filename = filename
 
597
        self.how = how
 
598
 
 
599
 
411
600
class NoSuchExportFormat(BzrNewError):
412
601
    """Export format %(format)r not supported"""
413
602
    def __init__(self, format):
514
703
        self.file_id = file_id
515
704
 
516
705
 
 
706
class DuplicateKey(BzrNewError):
 
707
    """Key %(key)s is already present in map"""
 
708
 
 
709
 
 
710
class MalformedTransform(BzrNewError):
 
711
    """Tree transform is malformed %(conflicts)r"""
 
712
 
 
713
 
517
714
class BzrBadParameter(BzrNewError):
518
715
    """A bad parameter : %(param)s is not usable.
519
716
    
529
726
    """Parameter %(param)s is neither unicode nor utf8."""
530
727
 
531
728
 
 
729
class ReusingTransform(BzrNewError):
 
730
    """Attempt to reuse a transform that has already been applied."""
 
731
 
 
732
 
 
733
class CantMoveRoot(BzrNewError):
 
734
    """Moving the root directory is not supported at this time"""
 
735
 
 
736
 
532
737
class BzrBadParameterNotString(BzrBadParameter):
533
738
    """Parameter %(param)s is not a string or unicode string."""
534
739
 
535
740
 
 
741
class BzrBadParameterMissing(BzrBadParameter):
 
742
    """Parameter $(param)s is required but not present."""
 
743
 
 
744
 
536
745
class DependencyNotPresent(BzrNewError):
537
746
    """Unable to import library: %(library)s, %(error)s"""
538
747
 
553
762
    def __init__(self, format):
554
763
        BzrNewError.__init__(self)
555
764
        self.format = format
 
765
 
 
766
 
 
767
class NoDiff3(BzrNewError):
 
768
    """Diff3 is not installed on this machine."""
 
769
 
 
770
 
 
771
class ExistingLimbo(BzrNewError):
 
772
    """This tree contains left-over files from a failed operation.
 
773
    Please examine %(limbo_dir)s to see if it contains any files you wish to
 
774
    keep, and delete it when you are done.
 
775
    """
 
776
    def __init__(self, limbo_dir):
 
777
       BzrNewError.__init__(self)
 
778
       self.limbo_dir = limbo_dir
 
779
 
 
780
 
 
781
class ImmortalLimbo(BzrNewError):
 
782
    """Unable to delete transform temporary directory $(limbo_dir)s.
 
783
    Please examine %(limbo_dir)s to see if it contains any files you wish to
 
784
    keep, and delete it when you are done.
 
785
    """
 
786
    def __init__(self, limbo_dir):
 
787
       BzrNewError.__init__(self)
 
788
       self.limbo_dir = limbo_dir
 
789
 
 
790
 
 
791
class OutOfDateTree(BzrNewError):
 
792
    """Working tree is out of date, please run 'bzr update'."""
 
793
 
 
794
    def __init__(self, tree):
 
795
        BzrNewError.__init__(self)
 
796
        self.tree = tree
 
797
 
 
798
 
 
799
class MergeModifiedFormatError(BzrNewError):
 
800
    """Error in merge modified format"""
 
801
 
 
802
 
 
803
class CorruptRepository(BzrNewError):
 
804
    """An error has been detected in the repository %(repo_path)s.
 
805
Please run bzr reconcile on this repository."""
 
806
 
 
807
    def __init__(self, repo):
 
808
        BzrNewError.__init__(self)
 
809
        self.repo_path = repo.bzrdir.root_transport.base
 
810
 
 
811
 
 
812
class UpgradeRequired(BzrNewError):
 
813
    """To use this feature you must upgrade your branch at %(path)s."""
 
814
 
 
815
    def __init__(self, path):
 
816
        BzrNewError.__init__(self)
 
817
        self.path = path
 
818
 
 
819
 
 
820
class LocalRequiresBoundBranch(BzrNewError):
 
821
    """Cannot perform local-only commits on unbound branches."""
 
822
 
 
823
 
 
824
class MissingProgressBarFinish(BzrNewError):
 
825
    """A nested progress bar was not 'finished' correctly."""