/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: Robert Collins
  • Date: 2005-11-04 23:27:47 UTC
  • Revision ID: robertc@robertcollins.net-20051104232747-5872c68d759bc7be
Bugfix the config test suite to not create .bazaar in the dir where it is run.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical
 
1
# (C) 2005 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
34
34
... except:
35
35
...   print sys.exc_type
36
36
...   print sys.exc_value
37
 
...   path = getattr(sys.exc_value, 'path')
38
 
...   if path is not None:
39
 
...     print path
 
37
...   print sys.exc_value.path
40
38
bzrlib.errors.NotBranchError
41
39
Not a branch: /foo/bar
42
40
/foo/bar
48
46
 
49
47
 * the printable form of an exception is generated by the base class
50
48
   __str__ method
51
 
 
52
 
Exception strings should start with a capital letter and not have a final
53
 
fullstop.
54
49
"""
55
50
 
56
 
from warnings import warn
57
 
 
58
51
# based on Scott James Remnant's hct error classes
59
52
 
60
53
# TODO: is there any value in providing the .args field used by standard
107
100
 
108
101
class BzrCheckError(BzrNewError):
109
102
    """Internal check failed: %(message)s"""
110
 
 
111
103
    def __init__(self, message):
112
104
        BzrNewError.__init__(self)
113
105
        self.message = message
141
133
    def __init__(self, base):
142
134
        BzrNewError.__init__(self)
143
135
        self.base = base
144
 
 
145
 
 
146
 
class NotLocalUrl(BzrNewError):
147
 
    """%s(url) is not a local path."""
148
 
    
149
 
    def __init__(self, url):
150
 
        BzrNewError.__init__(self)
151
 
        self.url = url
152
 
 
 
136
        
153
137
 
154
138
class BzrCommandError(BzrError):
155
139
    # Error from malformed user command
156
140
    # This is being misused as a generic exception
157
141
    # pleae subclass. RBC 20051030
158
 
    #
159
 
    # I think it's a waste of effort to differentiate between errors that
160
 
    # are not intended to be caught anyway.  UI code need not subclass
161
 
    # BzrCommandError, and non-UI code should not throw a subclass of
162
 
    # BzrCommandError.  ADHB 20051211
163
142
    def __str__(self):
164
143
        return self.args[0]
165
144
 
171
150
class StrictCommitFailed(Exception):
172
151
    """Commit refused because there are unknowns in the tree."""
173
152
 
174
 
 
175
 
class PathError(BzrNewError):
176
 
    """Generic path error: %(path)r%(extra)s)"""
177
 
 
178
 
    def __init__(self, path, extra=None):
179
 
        BzrNewError.__init__(self)
180
 
        self.path = path
181
 
        if extra:
182
 
            self.extra = ': ' + str(extra)
183
 
        else:
184
 
            self.extra = ''
185
 
 
186
 
 
187
 
class NoSuchFile(PathError):
188
 
    """No such file: %(path)r%(extra)s"""
189
 
 
190
 
 
191
 
class FileExists(PathError):
192
 
    """File exists: %(path)r%(extra)s"""
193
 
 
194
 
 
195
 
class DirectoryNotEmpty(PathError):
196
 
    """Directory not empty: %(path)r%(extra)s"""
197
 
 
198
 
 
199
 
class ResourceBusy(PathError):
200
 
    """Device or resource busy: %(path)r%(extra)s"""
201
 
 
202
 
 
203
 
class PermissionDenied(PathError):
204
 
    """Permission denied: %(path)r%(extra)s"""
205
 
 
206
 
 
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)
211
 
        self.path = path
212
 
        self.base = base
213
 
        if extra:
214
 
            self.extra = ': ' + str(extra)
215
 
        else:
216
 
            self.extra = ''
217
 
 
218
 
 
219
 
class NotBranchError(PathError):
 
153
class NotBranchError(BzrNewError):
220
154
    """Not a branch: %(path)s"""
221
 
 
222
 
 
223
 
class AlreadyBranchError(PathError):
224
 
    """Already a branch: %(path)s. Use `bzr checkout` to build a working tree."""
225
 
 
226
 
 
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
232
 
 
233
 
 
234
 
class FileInWrongBranch(BzrNewError):
235
 
    """File %(path)s in not in branch %(branch_base)s."""
236
 
 
237
 
    def __init__(self, branch, path):
238
 
        BzrNewError.__init__(self)
239
 
        self.branch = branch
240
 
        self.branch_base = branch.base
 
155
    def __init__(self, path):
 
156
        BzrNewError.__init__(self)
241
157
        self.path = path
242
158
 
243
159
 
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]
248
164
 
249
165
 
250
 
class UnknownFormatError(BzrError):
251
 
    """Specified path is a bzr branch whose format we do not recognize."""
252
 
    def __str__(self):
253
 
        return 'unknown branch format: %s' % self.args[0]
254
 
 
255
 
 
256
 
class IncompatibleFormat(BzrNewError):
257
 
    """Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
258
 
 
259
 
    def __init__(self, format, bzrdir_format):
260
 
        BzrNewError.__init__(self)
261
 
        self.format = format
262
 
        self.bzrdir = bzrdir_format
263
 
 
264
 
 
265
166
class NotVersionedError(BzrNewError):
266
167
    """%(path)s is not versioned"""
267
168
    def __init__(self, path):
269
170
        self.path = path
270
171
 
271
172
 
272
 
class PathsNotVersionedError(BzrNewError):
273
 
    # used when reporting several paths are not versioned
274
 
    """Path(s) are not versioned: %(paths_as_string)s"""
275
 
 
276
 
    def __init__(self, paths):
277
 
        from bzrlib.osutils import quotefn
278
 
        BzrNewError.__init__(self)
279
 
        self.paths = paths
280
 
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
281
 
 
282
 
 
283
173
class BadFileKindError(BzrError):
284
174
    """Specified file is of a kind that cannot be added.
285
175
 
290
180
    """Cannot operate on a file because it is a control file."""
291
181
 
292
182
 
293
 
class LockError(BzrNewError):
294
 
    """Lock error: %(message)s"""
 
183
class LockError(Exception):
 
184
    """Lock error"""
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
298
 
    #
299
 
    # New code should prefer to raise specific subclasses
300
 
    def __init__(self, message):
301
 
        self.message = message
302
188
 
303
189
 
304
190
class CommitNotPossible(LockError):
305
191
    """A commit was attempted but we do not have a write lock open."""
306
 
    def __init__(self):
307
 
        pass
308
192
 
309
193
 
310
194
class AlreadyCommitted(LockError):
311
195
    """A rollback was requested, but is not able to be accomplished."""
312
 
    def __init__(self):
313
 
        pass
314
196
 
315
197
 
316
198
class ReadOnlyError(LockError):
317
 
    """A write attempt was made in a read only transaction on %(obj)s"""
318
 
    def __init__(self, obj):
319
 
        self.obj = obj
320
 
 
321
 
 
322
 
class OutSideTransaction(BzrNewError):
323
 
    """A transaction related operation was attempted after the transaction finished."""
324
 
 
325
 
 
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):
332
 
        self.obj = obj
333
 
 
334
 
 
335
 
class ReadOnlyObjectDirtiedError(ReadOnlyError):
336
 
    """Cannot change object %(obj)r in read only transaction"""
337
 
    def __init__(self, obj):
338
 
        self.obj = obj
339
 
 
340
 
 
341
 
class UnlockableTransport(LockError):
342
 
    """Cannot lock: transport is read only: %(transport)s"""
343
 
    def __init__(self, transport):
344
 
        self.transport = transport
345
 
 
346
 
 
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):
351
 
        self.lock = lock
352
 
 
353
 
 
354
 
class LockBroken(LockError):
355
 
    """Lock was broken while still open: %(lock)s - check storage consistency!"""
356
 
    def __init__(self, lock):
357
 
        self.lock = lock
358
 
 
359
 
 
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):
363
 
        self.lock = lock
364
 
        self.holder = holder
365
 
        self.target = target
366
 
 
367
 
 
368
 
class LockNotHeld(LockError):
369
 
    """Lock not held: %(lock)s"""
370
 
    def __init__(self, lock):
371
 
        self.lock = lock
 
199
    """A write attempt was made in a read only transaction."""
372
200
 
373
201
 
374
202
class PointlessCommit(BzrNewError):
375
203
    """No changes to commit"""
376
204
 
377
 
 
378
 
class UpgradeReadonly(BzrNewError):
379
 
    """Upgrade URL cannot work with readonly URL's."""
380
 
 
381
 
 
382
 
class UpToDateFormat(BzrNewError):
383
 
    """The branch format %(format)s is already at the most recent format."""
384
 
 
385
 
    def __init__(self, format):
386
 
        BzrNewError.__init__(self)
387
 
        self.format = format
388
 
 
389
 
 
390
 
 
391
205
class StrictCommitFailed(Exception):
392
206
    """Commit refused because there are unknowns in the tree."""
393
207
 
394
 
 
395
208
class NoSuchRevision(BzrError):
396
209
    def __init__(self, branch, revision):
397
210
        self.branch = branch
409
222
 
410
223
 
411
224
class DivergedBranches(BzrError):
412
 
 
413
225
    def __init__(self, branch1, branch2):
414
 
        BzrError.__init__(self, "These branches have diverged.  Try merge.")
 
226
        BzrError.__init__(self, "These branches have diverged.")
415
227
        self.branch1 = branch1
416
228
        self.branch2 = branch2
417
229
 
422
234
            " specified."
423
235
        BzrCommandError.__init__(self, msg)
424
236
 
425
 
 
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)
431
242
 
432
 
 
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)
438
248
 
439
 
 
440
 
 
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, 
444
 
                                                        rev_id)
445
 
        BzrError.__init__(self, msg)
446
 
        self.rev_id = rev_id
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, 
 
252
                                                        rev_id)
 
253
        BzrError.__init__(self, msg)
 
254
        self.rev_id = rev_id
 
255
        self.not_ancestor_id = not_ancestor_id
 
256
 
 
257
 
 
258
class NotAncestor(BzrError):
 
259
    def __init__(self, rev_id, not_ancestor_id):
 
260
        self.rev_id = rev_id
 
261
        self.not_ancestor_id = not_ancestor_id
 
262
        msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id, 
 
263
                                                        rev_id)
 
264
        BzrError.__init__(self, msg)
448
265
 
449
266
 
450
267
class InstallFailed(BzrError):
456
273
 
457
274
class AmbiguousBase(BzrError):
458
275
    def __init__(self, bases):
459
 
        warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
460
 
                DeprecationWarning)
461
276
        msg = "The correct base is unclear, becase %s are all equally close" %\
462
277
            ", ".join(bases)
463
278
        BzrError.__init__(self, msg)
464
279
        self.bases = bases
465
280
 
466
 
 
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)
471
285
 
472
 
 
473
286
class UnlistableStore(BzrError):
474
287
    def __init__(self, store):
475
288
        BzrError.__init__(self, "Store %s is not listable" % store)
476
289
 
477
 
 
478
 
 
479
290
class UnlistableBranch(BzrError):
480
291
    def __init__(self, br):
481
292
        BzrError.__init__(self, "Stores for branch %s are not listable" % br)
482
293
 
483
294
 
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)
488
 
        self.branch = branch
489
 
        self.master = master
490
 
 
491
 
        
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)
496
 
        self.branch = branch
497
 
        self.master = master
498
 
        self.remote = remote
499
 
 
500
 
 
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)
505
 
        self.branch = branch
506
 
 
507
 
 
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)
512
 
        self.branch = branch
513
 
        self.target = target
514
 
        self.error = error
515
 
 
516
 
 
517
295
class WeaveError(BzrNewError):
518
296
    """Error in processing weave: %(message)s"""
519
 
 
520
297
    def __init__(self, message=None):
521
298
        BzrNewError.__init__(self)
522
299
        self.message = message
525
302
class WeaveRevisionAlreadyPresent(WeaveError):
526
303
    """Revision {%(revision_id)s} already present in %(weave)s"""
527
304
    def __init__(self, revision_id, weave):
528
 
 
529
305
        WeaveError.__init__(self)
530
306
        self.revision_id = revision_id
531
307
        self.weave = weave
533
309
 
534
310
class WeaveRevisionNotPresent(WeaveError):
535
311
    """Revision {%(revision_id)s} not present in %(weave)s"""
536
 
 
537
312
    def __init__(self, revision_id, weave):
538
313
        WeaveError.__init__(self)
539
314
        self.revision_id = revision_id
542
317
 
543
318
class WeaveFormatError(WeaveError):
544
319
    """Weave invariant violated: %(what)s"""
545
 
 
546
320
    def __init__(self, what):
547
321
        WeaveError.__init__(self)
548
322
        self.what = what
552
326
    """Parents are mismatched between two revisions."""
553
327
    
554
328
 
555
 
class WeaveInvalidChecksum(WeaveError):
556
 
    """Text did not match it's checksum: %(message)s"""
557
 
 
558
 
 
559
 
class WeaveTextDiffers(WeaveError):
560
 
    """Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
561
 
 
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
567
 
 
568
 
 
569
 
class WeaveTextDiffers(WeaveError):
570
 
    """Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
571
 
 
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
577
 
 
578
 
 
579
 
class VersionedFileError(BzrNewError):
580
 
    """Versioned file error."""
581
 
 
582
 
 
583
 
class RevisionNotPresent(VersionedFileError):
584
 
    """Revision {%(revision_id)s} not present in %(file_id)s."""
585
 
 
586
 
    def __init__(self, revision_id, file_id):
587
 
        VersionedFileError.__init__(self)
588
 
        self.revision_id = revision_id
589
 
        self.file_id = file_id
590
 
 
591
 
 
592
 
class RevisionAlreadyPresent(VersionedFileError):
593
 
    """Revision {%(revision_id)s} already present in %(file_id)s."""
594
 
 
595
 
    def __init__(self, revision_id, file_id):
596
 
        VersionedFileError.__init__(self)
597
 
        self.revision_id = revision_id
598
 
        self.file_id = file_id
599
 
 
600
 
 
601
 
class KnitError(BzrNewError):
602
 
    """Knit error"""
603
 
 
604
 
 
605
 
class KnitHeaderError(KnitError):
606
 
    """Knit header error: %(badline)r unexpected"""
607
 
 
608
 
    def __init__(self, badline):
609
 
        KnitError.__init__(self)
610
 
        self.badline = badline
611
 
 
612
 
 
613
 
class KnitCorrupt(KnitError):
614
 
    """Knit %(filename)s corrupt: %(how)s"""
615
 
 
616
 
    def __init__(self, filename, how):
617
 
        KnitError.__init__(self)
618
 
        self.filename = filename
619
 
        self.how = how
620
 
 
621
 
 
622
 
class NoSuchExportFormat(BzrNewError):
623
 
    """Export format %(format)r not supported"""
624
 
    def __init__(self, format):
625
 
        BzrNewError.__init__(self)
626
 
        self.format = format
627
 
 
628
 
 
629
329
class TransportError(BzrError):
630
330
    """All errors thrown by Transport implementations should derive
631
331
    from this class.
637
337
        self.msg = msg
638
338
        self.orig_error = orig_error
639
339
 
640
 
 
641
340
# A set of semi-meaningful errors which can be thrown
642
341
class TransportNotPossible(TransportError):
643
342
    """This is for transports where a specific function is explicitly not
645
344
    """
646
345
    pass
647
346
 
648
 
 
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.
653
 
    """
654
 
    def __init__(self, msg=None, orig_error=None):
655
 
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
656
 
 
 
347
class NonRelativePath(TransportError):
 
348
    """An absolute path was supplied, that could not be decoded into
 
349
    a relative path.
 
350
    """
 
351
    pass
 
352
 
 
353
class NoSuchFile(TransportError, IOError):
 
354
    """A get() was issued for a file that doesn't exist."""
 
355
 
 
356
    # XXX: Is multiple inheritance for exceptions really needed?
 
357
 
 
358
    def __str__(self):
 
359
        return 'no such file: ' + self.msg
 
360
 
 
361
    def __init__(self, msg=None, orig_error=None):
 
362
        import errno
 
363
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
 
364
        IOError.__init__(self, errno.ENOENT, self.msg)
 
365
 
 
366
class FileExists(TransportError, OSError):
 
367
    """An operation was attempted, which would overwrite an entry,
 
368
    but overwritting is not supported.
 
369
 
 
370
    mkdir() can throw this, but put() just overwites existing files.
 
371
    """
 
372
    # XXX: Is multiple inheritance for exceptions really needed?
 
373
    def __init__(self, msg=None, orig_error=None):
 
374
        import errno
 
375
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
 
376
        OSError.__init__(self, errno.EEXIST, self.msg)
 
377
 
 
378
class PermissionDenied(TransportError):
 
379
    """An operation cannot succeed because of a lack of permissions."""
 
380
    pass
657
381
 
658
382
class ConnectionReset(TransportError):
659
383
    """The connection has been closed."""
660
384
    pass
661
385
 
662
 
 
663
386
class ConflictsInTree(BzrError):
664
387
    def __init__(self):
665
388
        BzrError.__init__(self, "Working tree has conflicts.")
666
389
 
667
 
 
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)
675
397
 
676
 
 
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'"
680
401
                               % command_line)
681
402
 
682
 
 
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)
688
408
 
689
 
 
690
409
class CantReprocessAndShowBase(BzrNewError):
691
410
    """Can't reprocess and show base.
692
411
Reprocessing obscures relationship of conflicting lines to base."""
693
412
 
694
 
 
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
700
418
 
701
 
 
702
 
class NotConflicted(BzrNewError):
703
 
    """File %(filename)s is not conflicted."""
704
 
 
705
 
    def __init__(self, filename):
706
 
        BzrNewError.__init__(self)
707
 
        self.filename = filename
708
 
 
709
 
 
710
419
class MustUseDecorated(Exception):
711
420
    """A decorating function has requested its original command be used.
712
421
    
713
422
    This should never escape bzr, so does not need to be printable.
714
423
    """
715
424
 
716
 
 
717
 
class MissingText(BzrNewError):
718
 
    """Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
719
 
 
720
 
    def __init__(self, branch, text_revision, file_id):
721
 
        BzrNewError.__init__(self)
722
 
        self.branch = branch
723
 
        self.base = branch.base
724
 
        self.text_revision = text_revision
725
 
        self.file_id = file_id
726
 
 
727
 
 
728
 
class DuplicateKey(BzrNewError):
729
 
    """Key %(key)s is already present in map"""
730
 
 
731
 
 
732
 
class MalformedTransform(BzrNewError):
733
 
    """Tree transform is malformed %(conflicts)r"""
734
 
 
735
 
 
736
 
class BzrBadParameter(BzrNewError):
737
 
    """A bad parameter : %(param)s is not usable.
738
 
    
739
 
    This exception should never be thrown, but it is a base class for all
740
 
    parameter-to-function errors.
741
 
    """
742
 
    def __init__(self, param):
743
 
        BzrNewError.__init__(self)
744
 
        self.param = param
745
 
 
746
 
 
747
 
class BzrBadParameterNotUnicode(BzrBadParameter):
748
 
    """Parameter %(param)s is neither unicode nor utf8."""
749
 
 
750
 
 
751
 
class ReusingTransform(BzrNewError):
752
 
    """Attempt to reuse a transform that has already been applied."""
753
 
 
754
 
 
755
 
class CantMoveRoot(BzrNewError):
756
 
    """Moving the root directory is not supported at this time"""
757
 
 
758
 
 
759
 
class BzrBadParameterNotString(BzrBadParameter):
760
 
    """Parameter %(param)s is not a string or unicode string."""
761
 
 
762
 
 
763
 
class BzrBadParameterMissing(BzrBadParameter):
764
 
    """Parameter $(param)s is required but not present."""
765
 
 
766
 
 
767
 
class DependencyNotPresent(BzrNewError):
768
 
    """Unable to import library "%(library)s": %(error)s"""
769
 
 
770
 
    def __init__(self, library, error):
771
 
        BzrNewError.__init__(self, library=library, error=error)
772
 
 
773
 
 
774
 
class ParamikoNotPresent(DependencyNotPresent):
775
 
    """Unable to import paramiko (required for sftp support): %(error)s"""
776
 
 
777
 
    def __init__(self, error):
778
 
        DependencyNotPresent.__init__(self, 'paramiko', error)
779
 
 
780
 
 
781
 
class UninitializableFormat(BzrNewError):
782
 
    """Format %(format)s cannot be initialised by this version of bzr."""
783
 
 
784
 
    def __init__(self, format):
785
 
        BzrNewError.__init__(self)
786
 
        self.format = format
787
 
 
788
 
 
789
 
class NoDiff3(BzrNewError):
790
 
    """Diff3 is not installed on this machine."""
791
 
 
792
 
 
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.
797
 
    """
798
 
    def __init__(self, limbo_dir):
799
 
       BzrNewError.__init__(self)
800
 
       self.limbo_dir = limbo_dir
801
 
 
802
 
 
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.
807
 
    """
808
 
    def __init__(self, limbo_dir):
809
 
       BzrNewError.__init__(self)
810
 
       self.limbo_dir = limbo_dir
811
 
 
812
 
 
813
 
class OutOfDateTree(BzrNewError):
814
 
    """Working tree is out of date, please run 'bzr update'."""
815
 
 
816
 
    def __init__(self, tree):
817
 
        BzrNewError.__init__(self)
818
 
        self.tree = tree
819
 
 
820
 
 
821
 
class MergeModifiedFormatError(BzrNewError):
822
 
    """Error in merge modified format"""
823
 
 
824
 
 
825
 
class ConflictFormatError(BzrNewError):
826
 
    """Format error in conflict listings"""
827
 
 
828
 
 
829
 
class CorruptRepository(BzrNewError):
830
 
    """An error has been detected in the repository %(repo_path)s.
831
 
Please run bzr reconcile on this repository."""
832
 
 
833
 
    def __init__(self, repo):
834
 
        BzrNewError.__init__(self)
835
 
        self.repo_path = repo.bzrdir.root_transport.base
836
 
 
837
 
 
838
 
class UpgradeRequired(BzrNewError):
839
 
    """To use this feature you must upgrade your branch at %(path)s."""
840
 
 
841
 
    def __init__(self, path):
842
 
        BzrNewError.__init__(self)
843
 
        self.path = path
844
 
 
845
 
 
846
 
class LocalRequiresBoundBranch(BzrNewError):
847
 
    """Cannot perform local-only commits on unbound branches."""
848
 
 
849
 
 
850
 
class MissingProgressBarFinish(BzrNewError):
851
 
    """A nested progress bar was not 'finished' correctly."""
852
 
 
853
 
 
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):
857
 
        self.method = method
858
 
        self.mname = method.__name__
859
 
        self.tname = type(method_self).__name__