~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

Late bind to PatienceSequenceMatcher to allow plugin to override.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: UTF-8 -*-
 
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
34
34
... except:
35
35
...   print sys.exc_type
36
36
...   print sys.exc_value
37
 
...   print sys.exc_value.path
 
37
...   path = getattr(sys.exc_value, 'path', None)
 
38
...   if path is not None:
 
39
...     print path
38
40
bzrlib.errors.NotBranchError
39
41
Not a branch: /foo/bar
40
42
/foo/bar
46
48
 
47
49
 * the printable form of an exception is generated by the base class
48
50
   __str__ method
 
51
 
 
52
Exception strings should start with a capital letter and not have a final
 
53
fullstop.
49
54
"""
50
55
 
 
56
from warnings import warn
 
57
 
51
58
# based on Scott James Remnant's hct error classes
52
59
 
53
60
# TODO: is there any value in providing the .args field used by standard
61
68
# TODO: Convert all the other error classes here to BzrNewError, and eliminate
62
69
# the old one.
63
70
 
 
71
# TODO: The pattern (from hct) of using classes docstrings as message
 
72
# templates is cute but maybe not such a great idea - perhaps should have a
 
73
# separate static message_template.
 
74
 
64
75
 
65
76
class BzrError(StandardError):
66
77
    def __str__(self):
100
111
 
101
112
class BzrCheckError(BzrNewError):
102
113
    """Internal check failed: %(message)s"""
 
114
 
103
115
    def __init__(self, message):
 
116
        BzrNewError.__init__(self)
104
117
        self.message = message
105
118
 
106
119
 
107
120
class InvalidEntryName(BzrNewError):
108
121
    """Invalid entry name: %(name)s"""
109
122
    def __init__(self, name):
 
123
        BzrNewError.__init__(self)
110
124
        self.name = name
111
125
 
112
126
 
113
127
class InvalidRevisionNumber(BzrNewError):
114
128
    """Invalid revision number %(revno)d"""
115
129
    def __init__(self, revno):
 
130
        BzrNewError.__init__(self)
116
131
        self.revno = revno
117
132
 
118
133
 
119
134
class InvalidRevisionId(BzrNewError):
120
 
    """Invalid revision-id"""
 
135
    """Invalid revision-id {%(revision_id)s} in %(branch)s"""
 
136
    def __init__(self, revision_id, branch):
 
137
        # branch can be any string or object with __str__ defined
 
138
        BzrNewError.__init__(self)
 
139
        self.revision_id = revision_id
 
140
        self.branch = branch
 
141
 
 
142
 
 
143
class NoWorkingTree(BzrNewError):
 
144
    """No WorkingTree exists for %(base)s."""
 
145
    
 
146
    def __init__(self, base):
 
147
        BzrNewError.__init__(self)
 
148
        self.base = base
 
149
 
 
150
 
 
151
class NotLocalUrl(BzrNewError):
 
152
    """%(url)s is not a local path."""
 
153
    
 
154
    def __init__(self, url):
 
155
        BzrNewError.__init__(self)
 
156
        self.url = url
121
157
 
122
158
 
123
159
class BzrCommandError(BzrError):
124
160
    # Error from malformed user command
 
161
    # This is being misused as a generic exception
 
162
    # pleae subclass. RBC 20051030
 
163
    #
 
164
    # I think it's a waste of effort to differentiate between errors that
 
165
    # are not intended to be caught anyway.  UI code need not subclass
 
166
    # BzrCommandError, and non-UI code should not throw a subclass of
 
167
    # BzrCommandError.  ADHB 20051211
125
168
    def __str__(self):
126
169
        return self.args[0]
127
170
 
 
171
 
 
172
class BzrOptionError(BzrCommandError):
 
173
    """Some missing or otherwise incorrect option was supplied."""
 
174
 
 
175
    
128
176
class StrictCommitFailed(Exception):
129
177
    """Commit refused because there are unknowns in the tree."""
130
178
 
131
 
class NotBranchError(BzrNewError):
 
179
 
 
180
# XXX: Should be unified with TransportError; they seem to represent the
 
181
# same thing
 
182
class PathError(BzrNewError):
 
183
    """Generic path error: %(path)r%(extra)s)"""
 
184
 
 
185
    def __init__(self, path, extra=None):
 
186
        BzrNewError.__init__(self)
 
187
        self.path = path
 
188
        if extra:
 
189
            self.extra = ': ' + str(extra)
 
190
        else:
 
191
            self.extra = ''
 
192
 
 
193
 
 
194
class NoSuchFile(PathError):
 
195
    """No such file: %(path)r%(extra)s"""
 
196
 
 
197
 
 
198
class FileExists(PathError):
 
199
    """File exists: %(path)r%(extra)s"""
 
200
 
 
201
 
 
202
class DirectoryNotEmpty(PathError):
 
203
    """Directory not empty: %(path)r%(extra)s"""
 
204
 
 
205
 
 
206
class ResourceBusy(PathError):
 
207
    """Device or resource busy: %(path)r%(extra)s"""
 
208
 
 
209
 
 
210
class PermissionDenied(PathError):
 
211
    """Permission denied: %(path)r%(extra)s"""
 
212
 
 
213
 
 
214
class PathNotChild(BzrNewError):
 
215
    """Path %(path)r is not a child of path %(base)r%(extra)s"""
 
216
    def __init__(self, path, base, extra=None):
 
217
        BzrNewError.__init__(self)
 
218
        self.path = path
 
219
        self.base = base
 
220
        if extra:
 
221
            self.extra = ': ' + str(extra)
 
222
        else:
 
223
            self.extra = ''
 
224
 
 
225
 
 
226
class NotBranchError(PathError):
132
227
    """Not a branch: %(path)s"""
133
 
    def __init__(self, path):
134
 
        BzrNewError.__init__(self)
 
228
 
 
229
 
 
230
class AlreadyBranchError(PathError):
 
231
    """Already a branch: %(path)s."""
 
232
 
 
233
 
 
234
class BranchExistsWithoutWorkingTree(PathError):
 
235
    """Directory contains a branch, but no working tree \
 
236
(use bzr checkout if you wish to build a working tree): %(path)s"""
 
237
 
 
238
 
 
239
class NoRepositoryPresent(BzrNewError):
 
240
    """No repository present: %(path)r"""
 
241
    def __init__(self, bzrdir):
 
242
        BzrNewError.__init__(self)
 
243
        self.path = bzrdir.transport.clone('..').base
 
244
 
 
245
 
 
246
class FileInWrongBranch(BzrNewError):
 
247
    """File %(path)s in not in branch %(branch_base)s."""
 
248
 
 
249
    def __init__(self, branch, path):
 
250
        BzrNewError.__init__(self)
 
251
        self.branch = branch
 
252
        self.branch_base = branch.base
135
253
        self.path = path
136
254
 
137
255
 
138
256
class UnsupportedFormatError(BzrError):
139
 
    """Specified path is a bzr branch that we cannot read."""
 
257
    """Specified path is a bzr branch that we recognize but cannot read."""
140
258
    def __str__(self):
141
259
        return 'unsupported branch format: %s' % self.args[0]
142
260
 
143
261
 
 
262
class UnknownFormatError(BzrError):
 
263
    """Specified path is a bzr branch whose format we do not recognize."""
 
264
    def __str__(self):
 
265
        return 'unknown branch format: %s' % self.args[0]
 
266
 
 
267
 
 
268
class IncompatibleFormat(BzrNewError):
 
269
    """Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
 
270
 
 
271
    def __init__(self, format, bzrdir_format):
 
272
        BzrNewError.__init__(self)
 
273
        self.format = format
 
274
        self.bzrdir = bzrdir_format
 
275
 
 
276
 
144
277
class NotVersionedError(BzrNewError):
145
278
    """%(path)s is not versioned"""
146
279
    def __init__(self, path):
148
281
        self.path = path
149
282
 
150
283
 
 
284
class PathsNotVersionedError(BzrNewError):
 
285
    # used when reporting several paths are not versioned
 
286
    """Path(s) are not versioned: %(paths_as_string)s"""
 
287
 
 
288
    def __init__(self, paths):
 
289
        from bzrlib.osutils import quotefn
 
290
        BzrNewError.__init__(self)
 
291
        self.paths = paths
 
292
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
 
293
 
 
294
 
 
295
class PathsDoNotExist(BzrNewError):
 
296
    """Path(s) do not exist: %(paths_as_string)s"""
 
297
 
 
298
    # used when reporting that paths are neither versioned nor in the working
 
299
    # tree
 
300
 
 
301
    def __init__(self, paths):
 
302
        # circular import
 
303
        from bzrlib.osutils import quotefn
 
304
        BzrNewError.__init__(self)
 
305
        self.paths = paths
 
306
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
 
307
 
 
308
 
151
309
class BadFileKindError(BzrError):
152
310
    """Specified file is of a kind that cannot be added.
153
311
 
158
316
    """Cannot operate on a file because it is a control file."""
159
317
 
160
318
 
161
 
class LockError(Exception):
162
 
    """Lock error"""
 
319
class LockError(BzrNewError):
 
320
    """Lock error: %(message)s"""
163
321
    # All exceptions from the lock/unlock functions should be from
164
322
    # this exception class.  They will be translated as necessary. The
165
323
    # original exception is available as e.original_error
 
324
    #
 
325
    # New code should prefer to raise specific subclasses
 
326
    def __init__(self, message):
 
327
        self.message = message
166
328
 
167
329
 
168
330
class CommitNotPossible(LockError):
169
331
    """A commit was attempted but we do not have a write lock open."""
 
332
    def __init__(self):
 
333
        pass
170
334
 
171
335
 
172
336
class AlreadyCommitted(LockError):
173
337
    """A rollback was requested, but is not able to be accomplished."""
 
338
    def __init__(self):
 
339
        pass
174
340
 
175
341
 
176
342
class ReadOnlyError(LockError):
177
 
    """A write attempt was made in a read only transaction."""
 
343
    """A write attempt was made in a read only transaction on %(obj)s"""
 
344
    def __init__(self, obj):
 
345
        self.obj = obj
 
346
 
 
347
 
 
348
class OutSideTransaction(BzrNewError):
 
349
    """A transaction related operation was attempted after the transaction finished."""
 
350
 
 
351
 
 
352
class ObjectNotLocked(LockError):
 
353
    """%(obj)r is not locked"""
 
354
    # this can indicate that any particular object is not locked; see also
 
355
    # LockNotHeld which means that a particular *lock* object is not held by
 
356
    # the caller -- perhaps they should be unified.
 
357
    def __init__(self, obj):
 
358
        self.obj = obj
 
359
 
 
360
 
 
361
class ReadOnlyObjectDirtiedError(ReadOnlyError):
 
362
    """Cannot change object %(obj)r in read only transaction"""
 
363
    def __init__(self, obj):
 
364
        self.obj = obj
 
365
 
 
366
 
 
367
class UnlockableTransport(LockError):
 
368
    """Cannot lock: transport is read only: %(transport)s"""
 
369
    def __init__(self, transport):
 
370
        self.transport = transport
 
371
 
 
372
 
 
373
class LockContention(LockError):
 
374
    """Could not acquire lock %(lock)s"""
 
375
    # TODO: show full url for lock, combining the transport and relative bits?
 
376
    def __init__(self, lock):
 
377
        self.lock = lock
 
378
 
 
379
 
 
380
class LockBroken(LockError):
 
381
    """Lock was broken while still open: %(lock)s - check storage consistency!"""
 
382
    def __init__(self, lock):
 
383
        self.lock = lock
 
384
 
 
385
 
 
386
class LockBreakMismatch(LockError):
 
387
    """Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"""
 
388
    def __init__(self, lock, holder, target):
 
389
        self.lock = lock
 
390
        self.holder = holder
 
391
        self.target = target
 
392
 
 
393
 
 
394
class LockNotHeld(LockError):
 
395
    """Lock not held: %(lock)s"""
 
396
    def __init__(self, lock):
 
397
        self.lock = lock
178
398
 
179
399
 
180
400
class PointlessCommit(BzrNewError):
181
401
    """No changes to commit"""
182
402
 
183
403
 
 
404
class UpgradeReadonly(BzrNewError):
 
405
    """Upgrade URL cannot work with readonly URL's."""
 
406
 
 
407
 
 
408
class UpToDateFormat(BzrNewError):
 
409
    """The branch format %(format)s is already at the most recent format."""
 
410
 
 
411
    def __init__(self, format):
 
412
        BzrNewError.__init__(self)
 
413
        self.format = format
 
414
 
 
415
 
 
416
 
 
417
class StrictCommitFailed(Exception):
 
418
    """Commit refused because there are unknowns in the tree."""
 
419
 
 
420
 
184
421
class NoSuchRevision(BzrError):
185
422
    def __init__(self, branch, revision):
186
423
        self.branch = branch
198
435
 
199
436
 
200
437
class DivergedBranches(BzrError):
 
438
 
201
439
    def __init__(self, branch1, branch2):
202
 
        BzrError.__init__(self, "These branches have diverged.")
 
440
        BzrError.__init__(self, "These branches have diverged.  Try merge.")
203
441
        self.branch1 = branch1
204
442
        self.branch2 = branch2
205
443
 
210
448
            " specified."
211
449
        BzrCommandError.__init__(self, msg)
212
450
 
 
451
 
213
452
class NoCommonAncestor(BzrError):
214
453
    def __init__(self, revision_a, revision_b):
215
454
        msg = "Revisions have no common ancestor: %s %s." \
216
455
            % (revision_a, revision_b) 
217
456
        BzrError.__init__(self, msg)
218
457
 
 
458
 
219
459
class NoCommonRoot(BzrError):
220
460
    def __init__(self, revision_a, revision_b):
221
461
        msg = "Revisions are not derived from the same root: %s %s." \
222
462
            % (revision_a, revision_b) 
223
463
        BzrError.__init__(self, msg)
224
464
 
225
 
class NotAncestor(BzrError):
226
 
    def __init__(self, rev_id, not_ancestor_id):
227
 
        msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id, 
228
 
                                                        rev_id)
229
 
        BzrError.__init__(self, msg)
230
 
        self.rev_id = rev_id
231
 
        self.not_ancestor_id = not_ancestor_id
232
 
 
233
 
 
234
 
class NotAncestor(BzrError):
235
 
    def __init__(self, rev_id, not_ancestor_id):
236
 
        self.rev_id = rev_id
237
 
        self.not_ancestor_id = not_ancestor_id
238
 
        msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id, 
239
 
                                                        rev_id)
240
 
        BzrError.__init__(self, msg)
 
465
 
 
466
 
 
467
class NotAncestor(BzrError):
 
468
    def __init__(self, rev_id, not_ancestor_id):
 
469
        msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id, 
 
470
                                                        rev_id)
 
471
        BzrError.__init__(self, msg)
 
472
        self.rev_id = rev_id
 
473
        self.not_ancestor_id = not_ancestor_id
241
474
 
242
475
 
243
476
class InstallFailed(BzrError):
249
482
 
250
483
class AmbiguousBase(BzrError):
251
484
    def __init__(self, bases):
 
485
        warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
 
486
                DeprecationWarning)
252
487
        msg = "The correct base is unclear, becase %s are all equally close" %\
253
488
            ", ".join(bases)
254
489
        BzrError.__init__(self, msg)
255
490
        self.bases = bases
256
491
 
 
492
 
257
493
class NoCommits(BzrError):
258
494
    def __init__(self, branch):
259
495
        msg = "Branch %s has no commits." % branch
260
496
        BzrError.__init__(self, msg)
261
497
 
 
498
 
262
499
class UnlistableStore(BzrError):
263
500
    def __init__(self, store):
264
501
        BzrError.__init__(self, "Store %s is not listable" % store)
265
502
 
 
503
 
 
504
 
266
505
class UnlistableBranch(BzrError):
267
506
    def __init__(self, br):
268
507
        BzrError.__init__(self, "Stores for branch %s are not listable" % br)
269
508
 
270
509
 
271
 
from bzrlib.weave import WeaveError, WeaveParentMismatch
 
510
class BoundBranchOutOfDate(BzrNewError):
 
511
    """Bound branch %(branch)s is out of date with master branch %(master)s."""
 
512
    def __init__(self, branch, master):
 
513
        BzrNewError.__init__(self)
 
514
        self.branch = branch
 
515
        self.master = master
 
516
 
 
517
        
 
518
class CommitToDoubleBoundBranch(BzrNewError):
 
519
    """Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."""
 
520
    def __init__(self, branch, master, remote):
 
521
        BzrNewError.__init__(self)
 
522
        self.branch = branch
 
523
        self.master = master
 
524
        self.remote = remote
 
525
 
 
526
 
 
527
class OverwriteBoundBranch(BzrNewError):
 
528
    """Cannot pull --overwrite to a branch which is bound %(branch)s"""
 
529
    def __init__(self, branch):
 
530
        BzrNewError.__init__(self)
 
531
        self.branch = branch
 
532
 
 
533
 
 
534
class BoundBranchConnectionFailure(BzrNewError):
 
535
    """Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"""
 
536
    def __init__(self, branch, target, error):
 
537
        BzrNewError.__init__(self)
 
538
        self.branch = branch
 
539
        self.target = target
 
540
        self.error = error
 
541
 
 
542
 
 
543
class WeaveError(BzrNewError):
 
544
    """Error in processing weave: %(message)s"""
 
545
 
 
546
    def __init__(self, message=None):
 
547
        BzrNewError.__init__(self)
 
548
        self.message = message
 
549
 
 
550
 
 
551
class WeaveRevisionAlreadyPresent(WeaveError):
 
552
    """Revision {%(revision_id)s} already present in %(weave)s"""
 
553
    def __init__(self, revision_id, weave):
 
554
 
 
555
        WeaveError.__init__(self)
 
556
        self.revision_id = revision_id
 
557
        self.weave = weave
 
558
 
 
559
 
 
560
class WeaveRevisionNotPresent(WeaveError):
 
561
    """Revision {%(revision_id)s} not present in %(weave)s"""
 
562
 
 
563
    def __init__(self, revision_id, weave):
 
564
        WeaveError.__init__(self)
 
565
        self.revision_id = revision_id
 
566
        self.weave = weave
 
567
 
 
568
 
 
569
class WeaveFormatError(WeaveError):
 
570
    """Weave invariant violated: %(what)s"""
 
571
 
 
572
    def __init__(self, what):
 
573
        WeaveError.__init__(self)
 
574
        self.what = what
 
575
 
 
576
 
 
577
class WeaveParentMismatch(WeaveError):
 
578
    """Parents are mismatched between two revisions."""
 
579
    
 
580
 
 
581
class WeaveInvalidChecksum(WeaveError):
 
582
    """Text did not match it's checksum: %(message)s"""
 
583
 
 
584
 
 
585
class WeaveTextDiffers(WeaveError):
 
586
    """Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
 
587
 
 
588
    def __init__(self, revision_id, weave_a, weave_b):
 
589
        WeaveError.__init__(self)
 
590
        self.revision_id = revision_id
 
591
        self.weave_a = weave_a
 
592
        self.weave_b = weave_b
 
593
 
 
594
 
 
595
class WeaveTextDiffers(WeaveError):
 
596
    """Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
 
597
 
 
598
    def __init__(self, revision_id, weave_a, weave_b):
 
599
        WeaveError.__init__(self)
 
600
        self.revision_id = revision_id
 
601
        self.weave_a = weave_a
 
602
        self.weave_b = weave_b
 
603
 
 
604
 
 
605
class VersionedFileError(BzrNewError):
 
606
    """Versioned file error."""
 
607
 
 
608
 
 
609
class RevisionNotPresent(VersionedFileError):
 
610
    """Revision {%(revision_id)s} not present in %(file_id)s."""
 
611
 
 
612
    def __init__(self, revision_id, file_id):
 
613
        VersionedFileError.__init__(self)
 
614
        self.revision_id = revision_id
 
615
        self.file_id = file_id
 
616
 
 
617
 
 
618
class RevisionAlreadyPresent(VersionedFileError):
 
619
    """Revision {%(revision_id)s} already present in %(file_id)s."""
 
620
 
 
621
    def __init__(self, revision_id, file_id):
 
622
        VersionedFileError.__init__(self)
 
623
        self.revision_id = revision_id
 
624
        self.file_id = file_id
 
625
 
 
626
 
 
627
class KnitError(BzrNewError):
 
628
    """Knit error"""
 
629
 
 
630
 
 
631
class KnitHeaderError(KnitError):
 
632
    """Knit header error: %(badline)r unexpected"""
 
633
 
 
634
    def __init__(self, badline):
 
635
        KnitError.__init__(self)
 
636
        self.badline = badline
 
637
 
 
638
 
 
639
class KnitCorrupt(KnitError):
 
640
    """Knit %(filename)s corrupt: %(how)s"""
 
641
 
 
642
    def __init__(self, filename, how):
 
643
        KnitError.__init__(self)
 
644
        self.filename = filename
 
645
        self.how = how
 
646
 
 
647
 
 
648
class NoSuchExportFormat(BzrNewError):
 
649
    """Export format %(format)r not supported"""
 
650
    def __init__(self, format):
 
651
        BzrNewError.__init__(self)
 
652
        self.format = format
 
653
 
272
654
 
273
655
class TransportError(BzrError):
274
656
    """All errors thrown by Transport implementations should derive
281
663
        self.msg = msg
282
664
        self.orig_error = orig_error
283
665
 
 
666
 
284
667
# A set of semi-meaningful errors which can be thrown
285
668
class TransportNotPossible(TransportError):
286
669
    """This is for transports where a specific function is explicitly not
288
671
    """
289
672
    pass
290
673
 
291
 
class NonRelativePath(TransportError):
292
 
    """An absolute path was supplied, that could not be decoded into
293
 
    a relative path.
294
 
    """
295
 
    pass
296
 
 
297
 
class NoSuchFile(TransportError, IOError):
298
 
    """A get() was issued for a file that doesn't exist."""
299
 
 
300
 
    # XXX: Is multiple inheritance for exceptions really needed?
301
 
 
302
 
    def __str__(self):
303
 
        return 'no such file: ' + self.msg
304
 
 
305
 
    def __init__(self, msg=None, orig_error=None):
306
 
        import errno
307
 
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
308
 
        IOError.__init__(self, errno.ENOENT, self.msg)
309
 
 
310
 
class FileExists(TransportError, OSError):
311
 
    """An operation was attempted, which would overwrite an entry,
312
 
    but overwritting is not supported.
313
 
 
314
 
    mkdir() can throw this, but put() just overwites existing files.
315
 
    """
316
 
    # XXX: Is multiple inheritance for exceptions really needed?
317
 
    def __init__(self, msg=None, orig_error=None):
318
 
        import errno
319
 
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
320
 
        OSError.__init__(self, errno.EEXIST, self.msg)
321
 
 
322
 
class PermissionDenied(TransportError):
323
 
    """An operation cannot succeed because of a lack of permissions."""
324
 
    pass
 
674
 
 
675
class ConnectionError(TransportError):
 
676
    """A connection problem prevents file retrieval.
 
677
    This does not indicate whether the file exists or not; it indicates that a
 
678
    precondition for requesting the file was not met.
 
679
    """
 
680
    def __init__(self, msg=None, orig_error=None):
 
681
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
 
682
 
325
683
 
326
684
class ConnectionReset(TransportError):
327
685
    """The connection has been closed."""
328
686
    pass
329
687
 
 
688
 
330
689
class ConflictsInTree(BzrError):
331
690
    def __init__(self):
332
691
        BzrError.__init__(self, "Working tree has conflicts.")
333
692
 
 
693
 
334
694
class ParseConfigError(BzrError):
335
695
    def __init__(self, errors, filename):
336
696
        if filename is None:
339
699
            (filename, ('\n'.join(e.message for e in errors)))
340
700
        BzrError.__init__(self, message)
341
701
 
 
702
 
342
703
class SigningFailed(BzrError):
343
704
    def __init__(self, command_line):
344
705
        BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
345
706
                               % command_line)
 
707
 
 
708
 
 
709
class WorkingTreeNotRevision(BzrError):
 
710
    def __init__(self, tree):
 
711
        BzrError.__init__(self, "The working tree for %s has changed since"
 
712
                          " last commit, but weave merge requires that it be"
 
713
                          " unchanged." % tree.basedir)
 
714
 
 
715
 
 
716
class CantReprocessAndShowBase(BzrNewError):
 
717
    """Can't reprocess and show base.
 
718
Reprocessing obscures relationship of conflicting lines to base."""
 
719
 
 
720
 
 
721
class GraphCycleError(BzrNewError):
 
722
    """Cycle in graph %(graph)r"""
 
723
    def __init__(self, graph):
 
724
        BzrNewError.__init__(self)
 
725
        self.graph = graph
 
726
 
 
727
 
 
728
class NotConflicted(BzrNewError):
 
729
    """File %(filename)s is not conflicted."""
 
730
 
 
731
    def __init__(self, filename):
 
732
        BzrNewError.__init__(self)
 
733
        self.filename = filename
 
734
 
 
735
 
 
736
class MustUseDecorated(Exception):
 
737
    """A decorating function has requested its original command be used.
 
738
    
 
739
    This should never escape bzr, so does not need to be printable.
 
740
    """
 
741
 
 
742
 
 
743
class MissingText(BzrNewError):
 
744
    """Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
 
745
 
 
746
    def __init__(self, branch, text_revision, file_id):
 
747
        BzrNewError.__init__(self)
 
748
        self.branch = branch
 
749
        self.base = branch.base
 
750
        self.text_revision = text_revision
 
751
        self.file_id = file_id
 
752
 
 
753
 
 
754
class DuplicateKey(BzrNewError):
 
755
    """Key %(key)s is already present in map"""
 
756
 
 
757
 
 
758
class MalformedTransform(BzrNewError):
 
759
    """Tree transform is malformed %(conflicts)r"""
 
760
 
 
761
 
 
762
class BzrBadParameter(BzrNewError):
 
763
    """A bad parameter : %(param)s is not usable.
 
764
    
 
765
    This exception should never be thrown, but it is a base class for all
 
766
    parameter-to-function errors.
 
767
    """
 
768
    def __init__(self, param):
 
769
        BzrNewError.__init__(self)
 
770
        self.param = param
 
771
 
 
772
 
 
773
class BzrBadParameterNotUnicode(BzrBadParameter):
 
774
    """Parameter %(param)s is neither unicode nor utf8."""
 
775
 
 
776
 
 
777
class ReusingTransform(BzrNewError):
 
778
    """Attempt to reuse a transform that has already been applied."""
 
779
 
 
780
 
 
781
class CantMoveRoot(BzrNewError):
 
782
    """Moving the root directory is not supported at this time"""
 
783
 
 
784
 
 
785
class BzrBadParameterNotString(BzrBadParameter):
 
786
    """Parameter %(param)s is not a string or unicode string."""
 
787
 
 
788
 
 
789
class BzrBadParameterMissing(BzrBadParameter):
 
790
    """Parameter $(param)s is required but not present."""
 
791
 
 
792
 
 
793
class BzrBadParameterUnicode(BzrBadParameter):
 
794
    """Parameter %(param)s is unicode but only byte-strings are permitted."""
 
795
 
 
796
 
 
797
class BzrBadParameterContainsNewline(BzrBadParameter):
 
798
    """Parameter %(param)s contains a newline."""
 
799
 
 
800
 
 
801
class DependencyNotPresent(BzrNewError):
 
802
    """Unable to import library "%(library)s": %(error)s"""
 
803
 
 
804
    def __init__(self, library, error):
 
805
        BzrNewError.__init__(self, library=library, error=error)
 
806
 
 
807
 
 
808
class ParamikoNotPresent(DependencyNotPresent):
 
809
    """Unable to import paramiko (required for sftp support): %(error)s"""
 
810
 
 
811
    def __init__(self, error):
 
812
        DependencyNotPresent.__init__(self, 'paramiko', error)
 
813
 
 
814
 
 
815
class UninitializableFormat(BzrNewError):
 
816
    """Format %(format)s cannot be initialised by this version of bzr."""
 
817
 
 
818
    def __init__(self, format):
 
819
        BzrNewError.__init__(self)
 
820
        self.format = format
 
821
 
 
822
 
 
823
class NoDiff3(BzrNewError):
 
824
    """Diff3 is not installed on this machine."""
 
825
 
 
826
 
 
827
class ExistingLimbo(BzrNewError):
 
828
    """This tree contains left-over files from a failed operation.
 
829
    Please examine %(limbo_dir)s to see if it contains any files you wish to
 
830
    keep, and delete it when you are done.
 
831
    """
 
832
    def __init__(self, limbo_dir):
 
833
       BzrNewError.__init__(self)
 
834
       self.limbo_dir = limbo_dir
 
835
 
 
836
 
 
837
class ImmortalLimbo(BzrNewError):
 
838
    """Unable to delete transform temporary directory $(limbo_dir)s.
 
839
    Please examine %(limbo_dir)s to see if it contains any files you wish to
 
840
    keep, and delete it when you are done.
 
841
    """
 
842
    def __init__(self, limbo_dir):
 
843
       BzrNewError.__init__(self)
 
844
       self.limbo_dir = limbo_dir
 
845
 
 
846
 
 
847
class OutOfDateTree(BzrNewError):
 
848
    """Working tree is out of date, please run 'bzr update'."""
 
849
 
 
850
    def __init__(self, tree):
 
851
        BzrNewError.__init__(self)
 
852
        self.tree = tree
 
853
 
 
854
 
 
855
class MergeModifiedFormatError(BzrNewError):
 
856
    """Error in merge modified format"""
 
857
 
 
858
 
 
859
class ConflictFormatError(BzrNewError):
 
860
    """Format error in conflict listings"""
 
861
 
 
862
 
 
863
class CorruptRepository(BzrNewError):
 
864
    """An error has been detected in the repository %(repo_path)s.
 
865
Please run bzr reconcile on this repository."""
 
866
 
 
867
    def __init__(self, repo):
 
868
        BzrNewError.__init__(self)
 
869
        self.repo_path = repo.bzrdir.root_transport.base
 
870
 
 
871
 
 
872
class UpgradeRequired(BzrNewError):
 
873
    """To use this feature you must upgrade your branch at %(path)s."""
 
874
 
 
875
    def __init__(self, path):
 
876
        BzrNewError.__init__(self)
 
877
        self.path = path
 
878
 
 
879
 
 
880
class LocalRequiresBoundBranch(BzrNewError):
 
881
    """Cannot perform local-only commits on unbound branches."""
 
882
 
 
883
 
 
884
class MissingProgressBarFinish(BzrNewError):
 
885
    """A nested progress bar was not 'finished' correctly."""
 
886
 
 
887
 
 
888
class UnsupportedOperation(BzrNewError):
 
889
    """The method %(mname)s is not supported on objects of type %(tname)s."""
 
890
    def __init__(self, method, method_self):
 
891
        self.method = method
 
892
        self.mname = method.__name__
 
893
        self.tname = type(method_self).__name__
 
894
 
 
895
 
 
896
class BinaryFile(BzrNewError):
 
897
    """File is binary but should be text."""
 
898
 
 
899
 
 
900
class IllegalPath(BzrNewError):
 
901
    """The path %(path)s is not permitted on this platform"""
 
902
 
 
903
    def __init__(self, path):
 
904
        BzrNewError.__init__(self)
 
905
        self.path = path