/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

MergeĀ mainline

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
 
203
216
        self.path = path
204
217
 
205
218
 
 
219
class NoRepositoryPresent(BzrNewError):
 
220
    """Not repository present: %(path)r"""
 
221
    def __init__(self, bzrdir):
 
222
        BzrNewError.__init__(self)
 
223
        self.path = bzrdir.transport.clone('..').base
 
224
 
 
225
 
206
226
class FileInWrongBranch(BzrNewError):
207
227
    """File %(path)s in not in branch %(branch_base)s."""
 
228
 
208
229
    def __init__(self, branch, path):
209
230
        BzrNewError.__init__(self)
210
231
        self.branch = branch
224
245
        return 'unknown branch format: %s' % self.args[0]
225
246
 
226
247
 
 
248
class IncompatibleFormat(BzrNewError):
 
249
    """Format %(format)s is not compatible with .bzr version %(bzrdir)s."""
 
250
 
 
251
    def __init__(self, format, bzrdir_format):
 
252
        BzrNewError.__init__(self)
 
253
        self.format = format
 
254
        self.bzrdir = bzrdir_format
 
255
 
 
256
 
227
257
class NotVersionedError(BzrNewError):
228
258
    """%(path)s is not versioned"""
229
259
    def __init__(self, path):
241
271
    """Cannot operate on a file because it is a control file."""
242
272
 
243
273
 
244
 
class LockError(Exception):
245
 
    """Lock error"""
 
274
class LockError(BzrNewError):
 
275
    """Lock error: %(message)s"""
246
276
    # All exceptions from the lock/unlock functions should be from
247
277
    # this exception class.  They will be translated as necessary. The
248
278
    # original exception is available as e.original_error
 
279
    #
 
280
    # New code should prefer to raise specific subclasses
 
281
    def __init__(self, message):
 
282
        self.message = message
249
283
 
250
284
 
251
285
class CommitNotPossible(LockError):
252
286
    """A commit was attempted but we do not have a write lock open."""
 
287
    def __init__(self):
 
288
        pass
253
289
 
254
290
 
255
291
class AlreadyCommitted(LockError):
256
292
    """A rollback was requested, but is not able to be accomplished."""
 
293
    def __init__(self):
 
294
        pass
257
295
 
258
296
 
259
297
class ReadOnlyError(LockError):
260
 
    """A write attempt was made in a read only transaction."""
 
298
    """A write attempt was made in a read only transaction on %(obj)s"""
 
299
    def __init__(self, obj):
 
300
        self.obj = obj
 
301
 
 
302
 
 
303
class BranchNotLocked(LockError):
 
304
    """Branch %(branch)r is not locked"""
 
305
    def __init__(self, branch):
 
306
        # XXX: sometimes called with a LockableFiles instance not a Branch
 
307
        self.branch = branch
 
308
 
 
309
 
 
310
class ReadOnlyObjectDirtiedError(ReadOnlyError):
 
311
    """Cannot change object %(obj)r in read only transaction"""
 
312
    def __init__(self, obj):
 
313
        self.obj = obj
 
314
 
 
315
 
 
316
class UnlockableTransport(LockError):
 
317
    """Cannot lock: transport is read only: %(transport)s"""
 
318
    def __init__(self, transport):
 
319
        self.transport = transport
 
320
 
 
321
 
 
322
class LockContention(LockError):
 
323
    """Could not acquire lock %(lock)s"""
 
324
    # TODO: show full url for lock, combining the transport and relative bits?
 
325
    def __init__(self, lock):
 
326
        self.lock = lock
 
327
 
 
328
 
 
329
class LockBroken(LockError):
 
330
    """Lock was broken while still open: %(lock)s - check storage consistency!"""
 
331
    def __init__(self, lock):
 
332
        self.lock = lock
 
333
 
 
334
 
 
335
class LockBreakMismatch(LockError):
 
336
    """Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"""
 
337
    def __init__(self, lock, holder, target):
 
338
        self.lock = lock
 
339
        self.holder = holder
 
340
        self.target = target
 
341
 
 
342
 
 
343
class LockNotHeld(LockError):
 
344
    """Lock not held: %(lock)s"""
 
345
    def __init__(self, lock):
 
346
        self.lock = lock
 
347
 
 
348
 
 
349
class BranchNotLocked(LockError):
 
350
    """Branch %(branch)r not locked"""
 
351
    def __init__(self, branch):
 
352
        self.branch = branch
261
353
 
262
354
 
263
355
class PointlessCommit(BzrNewError):
268
360
    """Upgrade URL cannot work with readonly URL's."""
269
361
 
270
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
 
271
371
class StrictCommitFailed(Exception):
272
372
    """Commit refused because there are unknowns in the tree."""
273
373
 
274
 
 
275
374
class NoSuchRevision(BzrError):
276
375
    def __init__(self, branch, revision):
277
376
        self.branch = branch
404
503
        self.weave_b = weave_b
405
504
 
406
505
 
 
506
class WeaveTextDiffers(WeaveError):
 
507
    """Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"""
 
508
 
 
509
    def __init__(self, revision_id, weave_a, weave_b):
 
510
        WeaveError.__init__(self)
 
511
        self.revision_id = revision_id
 
512
        self.weave_a = weave_a
 
513
        self.weave_b = weave_b
 
514
 
 
515
 
407
516
class NoSuchExportFormat(BzrNewError):
408
517
    """Export format %(format)r not supported"""
409
518
    def __init__(self, format):
509
618
        self.text_revision = text_revision
510
619
        self.file_id = file_id
511
620
 
 
621
class DuplicateKey(BzrNewError):
 
622
    """Key %(key)s is already present in map"""
 
623
 
 
624
class MalformedTransform(BzrNewError):
 
625
    """Tree transform is malformed %(conflicts)r"""
 
626
 
512
627
 
513
628
class BzrBadParameter(BzrNewError):
514
629
    """A bad parameter : %(param)s is not usable.
525
640
    """Parameter %(param)s is neither unicode nor utf8."""
526
641
 
527
642
 
 
643
class ReusingTransform(BzrNewError):
 
644
    """Attempt to reuse a transform that has already been applied."""
 
645
 
 
646
 
 
647
class CantMoveRoot(BzrNewError):
 
648
    """Moving the root directory is not supported at this time"""
 
649
 
 
650
 
528
651
class BzrBadParameterNotString(BzrBadParameter):
529
652
    """Parameter %(param)s is not a string or unicode string."""
530
653
 
531
654
 
 
655
class BzrBadParameterMissing(BzrBadParameter):
 
656
    """Parameter $(param)s is required but not present."""
 
657
 
 
658
 
532
659
class DependencyNotPresent(BzrNewError):
533
660
    """Unable to import library: %(library)s, %(error)s"""
534
661
 
549
676
    def __init__(self, format):
550
677
        BzrNewError.__init__(self)
551
678
        self.format = format
 
679
 
 
680
 
 
681
class NoDiff3(BzrNewError):
 
682
    """Diff3 is not installed on this machine."""
 
683
 
 
684
 
 
685
class ExistingLimbo(BzrNewError):
 
686
    """This tree contains left-over files from a failed operation.
 
687
    Please examine %(limbo_dir)s to see if it contains any files you wish to
 
688
    keep, and delete it when you are done.
 
689
    """
 
690
    def __init__(self, limbo_dir):
 
691
       BzrNewError.__init__(self)
 
692
       self.limbo_dir = limbo_dir
 
693
 
 
694
 
 
695
class ImmortalLimbo(BzrNewError):
 
696
    """Unable to delete transform temporary directory $(limbo_dir)s.
 
697
    Please examine %(limbo_dir)s to see if it contains any files you wish to
 
698
    keep, and delete it when you are done.
 
699
    """
 
700
    def __init__(self, limbo_dir):
 
701
       BzrNewError.__init__(self)
 
702
       self.limbo_dir = limbo_dir
 
703
 
 
704
 
 
705
class OutOfDateTree(BzrNewError):
 
706
    """Working tree is out of date, please run 'bzr update'."""
 
707
 
 
708
    def __init__(self, tree):
 
709
        BzrNewError.__init__(self)
 
710
        self.tree = tree