~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
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
44
44
# 'unprintable'.
45
45
 
46
46
 
 
47
# return codes from the bzr program
 
48
EXIT_OK = 0
 
49
EXIT_ERROR = 3
 
50
EXIT_INTERNAL_ERROR = 4
 
51
 
 
52
 
47
53
class BzrError(StandardError):
48
54
    """
49
55
    Base class for errors raised by bzrlib.
50
56
 
51
 
    :cvar internal_error: if true (or absent) this was probably caused by a
52
 
    bzr bug and should be displayed with a traceback; if False this was
 
57
    :cvar internal_error: if True this was probably caused by a bzr bug and
 
58
    should be displayed with a traceback; if False (or absent) this was
53
59
    probably a user or environment error and they don't need the gory details.
54
60
    (That can be overridden by -Derror on the command line.)
55
61
 
95
101
        try:
96
102
            fmt = self._get_format_string()
97
103
            if fmt:
98
 
                s = fmt % self.__dict__
 
104
                d = dict(self.__dict__)
 
105
                # special case: python2.5 puts the 'message' attribute in a
 
106
                # slot, so it isn't seen in __dict__
 
107
                d['message'] = getattr(self, 'message', 'no message')
 
108
                s = fmt % d
99
109
                # __str__() should always return a 'str' object
100
110
                # never a 'unicode' object.
101
111
                if isinstance(s, unicode):
126
136
               )
127
137
 
128
138
 
 
139
class InternalBzrError(BzrError):
 
140
    """Base class for errors that are internal in nature.
 
141
 
 
142
    This is a convenience class for errors that are internal. The
 
143
    internal_error attribute can still be altered in subclasses, if needed.
 
144
    Using this class is simply an easy way to get internal errors.
 
145
    """
 
146
 
 
147
    internal_error = True
 
148
 
 
149
 
129
150
class BzrNewError(BzrError):
130
151
    """Deprecated error base class."""
131
152
    # base classes should override the docstring with their human-
164
185
    _fmt = "The tree builder is already building a tree."
165
186
 
166
187
 
167
 
class BzrCheckError(BzrError):
 
188
class BzrCheckError(InternalBzrError):
168
189
    
169
190
    _fmt = "Internal check failed: %(message)s"
170
191
 
171
 
    internal_error = True
172
 
 
173
192
    def __init__(self, message):
174
193
        BzrError.__init__(self)
175
194
        self.message = message
176
195
 
177
196
 
178
 
class DisabledMethod(BzrError):
 
197
class DisabledMethod(InternalBzrError):
179
198
 
180
199
    _fmt = "The smart server method '%(class_name)s' is disabled."
181
200
 
182
 
    internal_error = True
183
 
 
184
201
    def __init__(self, class_name):
185
202
        BzrError.__init__(self)
186
203
        self.class_name = class_name
187
204
 
188
205
 
189
 
class InvalidEntryName(BzrError):
 
206
class IncompatibleAPI(BzrError):
 
207
 
 
208
    _fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
 
209
        'It supports versions "%(minimum)s" to "%(current)s".'
 
210
 
 
211
    def __init__(self, api, wanted, minimum, current):
 
212
        self.api = api
 
213
        self.wanted = wanted
 
214
        self.minimum = minimum
 
215
        self.current = current
 
216
 
 
217
 
 
218
class InProcessTransport(BzrError):
 
219
 
 
220
    _fmt = "The transport '%(transport)s' is only accessible within this " \
 
221
        "process."
 
222
 
 
223
    def __init__(self, transport):
 
224
        self.transport = transport
 
225
 
 
226
 
 
227
class InvalidEntryName(InternalBzrError):
190
228
    
191
229
    _fmt = "Invalid entry name: %(name)s"
192
230
 
193
 
    internal_error = True
194
 
 
195
231
    def __init__(self, name):
196
232
        BzrError.__init__(self)
197
233
        self.name = name
216
252
        self.revision_id = revision_id
217
253
        self.branch = branch
218
254
 
 
255
 
219
256
class ReservedId(BzrError):
220
257
 
221
258
    _fmt = "Reserved revision-id {%(revision_id)s}"
224
261
        self.revision_id = revision_id
225
262
 
226
263
 
 
264
class RootMissing(InternalBzrError):
 
265
 
 
266
    _fmt = ("The root entry of a tree must be the first entry supplied to "
 
267
        "record_entry_contents.")
 
268
 
 
269
 
 
270
class NoPublicBranch(BzrError):
 
271
 
 
272
    _fmt = 'There is no public branch set for "%(branch_url)s".'
 
273
 
 
274
    def __init__(self, branch):
 
275
        import bzrlib.urlutils as urlutils
 
276
        public_location = urlutils.unescape_for_display(branch.base, 'ascii')
 
277
        BzrError.__init__(self, branch_url=public_location)
 
278
 
 
279
 
227
280
class NoHelpTopic(BzrError):
228
281
 
229
282
    _fmt = ("No help could be found for '%(topic)s'. "
235
288
 
236
289
class NoSuchId(BzrError):
237
290
 
238
 
    _fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
 
291
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
239
292
    
240
293
    def __init__(self, tree, file_id):
241
294
        BzrError.__init__(self)
243
296
        self.tree = tree
244
297
 
245
298
 
246
 
class InventoryModified(BzrError):
 
299
class NoSuchIdInRepository(NoSuchId):
 
300
 
 
301
    _fmt = ('The file id "%(file_id)s" is not present in the repository'
 
302
            ' %(repository)r')
 
303
 
 
304
    def __init__(self, repository, file_id):
 
305
        BzrError.__init__(self, repository=repository, file_id=file_id)
 
306
 
 
307
 
 
308
class InventoryModified(InternalBzrError):
247
309
 
248
310
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
249
311
            " so a clean inventory cannot be read without data loss.")
250
312
 
251
 
    internal_error = True
252
 
 
253
313
    def __init__(self, tree):
254
314
        self.tree = tree
255
315
 
256
316
 
257
317
class NoWorkingTree(BzrError):
258
318
 
259
 
    _fmt = "No WorkingTree exists for %(base)s."
 
319
    _fmt = 'No WorkingTree exists for "%(base)s".'
260
320
    
261
321
    def __init__(self, base):
262
322
        BzrError.__init__(self)
276
336
        self.url = url
277
337
 
278
338
 
279
 
class WorkingTreeAlreadyPopulated(BzrError):
280
 
 
281
 
    _fmt = """Working tree already populated in %(base)s"""
282
 
 
283
 
    internal_error = True
 
339
class WorkingTreeAlreadyPopulated(InternalBzrError):
 
340
 
 
341
    _fmt = 'Working tree already populated in "%(base)s"'
284
342
 
285
343
    def __init__(self, base):
286
344
        self.base = base
287
345
 
 
346
 
288
347
class BzrCommandError(BzrError):
289
348
    """Error from user command"""
290
349
 
291
 
    internal_error = False
292
 
 
293
350
    # Error from malformed user command; please avoid raising this as a
294
351
    # generic exception not caused by user input.
295
352
    #
322
379
    _fmt = "Error in command line options"
323
380
 
324
381
 
 
382
class BadIndexFormatSignature(BzrError):
 
383
 
 
384
    _fmt = "%(value)s is not an index of type %(_type)s."
 
385
 
 
386
    def __init__(self, value, _type):
 
387
        BzrError.__init__(self)
 
388
        self.value = value
 
389
        self._type = _type
 
390
 
 
391
 
 
392
class BadIndexData(BzrError):
 
393
 
 
394
    _fmt = "Error in data for index %(value)s."
 
395
 
 
396
    def __init__(self, value):
 
397
        BzrError.__init__(self)
 
398
        self.value = value
 
399
 
 
400
 
 
401
class BadIndexDuplicateKey(BzrError):
 
402
 
 
403
    _fmt = "The key '%(key)s' is already in index '%(index)s'."
 
404
 
 
405
    def __init__(self, key, index):
 
406
        BzrError.__init__(self)
 
407
        self.key = key
 
408
        self.index = index
 
409
 
 
410
 
 
411
class BadIndexKey(BzrError):
 
412
 
 
413
    _fmt = "The key '%(key)s' is not a valid key."
 
414
 
 
415
    def __init__(self, key):
 
416
        BzrError.__init__(self)
 
417
        self.key = key
 
418
 
 
419
 
 
420
class BadIndexOptions(BzrError):
 
421
 
 
422
    _fmt = "Could not parse options for index %(value)s."
 
423
 
 
424
    def __init__(self, value):
 
425
        BzrError.__init__(self)
 
426
        self.value = value
 
427
 
 
428
 
 
429
class BadIndexValue(BzrError):
 
430
 
 
431
    _fmt = "The value '%(value)s' is not a valid value."
 
432
 
 
433
    def __init__(self, value):
 
434
        BzrError.__init__(self)
 
435
        self.value = value
 
436
 
 
437
 
325
438
class BadOptionValue(BzrError):
326
439
 
327
440
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
337
450
 
338
451
# XXX: Should be unified with TransportError; they seem to represent the
339
452
# same thing
 
453
# RBC 20060929: I think that unifiying with TransportError would be a mistake
 
454
# - this is finer than a TransportError - and more useful as such. It 
 
455
# differentiates between 'transport has failed' and 'operation on a transport
 
456
# has failed.'
340
457
class PathError(BzrError):
341
458
    
342
459
    _fmt = "Generic path error: %(path)r%(extra)s)"
364
481
    """Used when renaming and both source and dest exist."""
365
482
 
366
483
    _fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
367
 
            "%(extra)s")
 
484
            " (Use --after to tell bzr about a rename that has already"
 
485
            " happened)%(extra)s")
368
486
 
369
487
    def __init__(self, source, dest, extra=None):
370
488
        BzrError.__init__(self)
378
496
 
379
497
class NotADirectory(PathError):
380
498
 
381
 
    _fmt = "%(path)r is not a directory %(extra)s"
 
499
    _fmt = '"%(path)s" is not a directory %(extra)s'
382
500
 
383
501
 
384
502
class NotInWorkingDirectory(PathError):
385
503
 
386
 
    _fmt = "%(path)r is not in the working directory %(extra)s"
 
504
    _fmt = '"%(path)s" is not in the working directory %(extra)s'
387
505
 
388
506
 
389
507
class DirectoryNotEmpty(PathError):
390
508
 
391
 
    _fmt = "Directory not empty: %(path)r%(extra)s"
392
 
 
393
 
 
394
 
class ReadingCompleted(BzrError):
 
509
    _fmt = 'Directory not empty: "%(path)s"%(extra)s'
 
510
 
 
511
 
 
512
class HardLinkNotSupported(PathError):
 
513
 
 
514
    _fmt = 'Hard-linking "%(path)s" is not supported'
 
515
 
 
516
 
 
517
class ReadingCompleted(InternalBzrError):
395
518
    
396
519
    _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
397
520
            "called upon it - the request has been completed and no more "
398
521
            "data may be read.")
399
522
 
400
 
    internal_error = True
401
 
 
402
523
    def __init__(self, request):
403
524
        self.request = request
404
525
 
405
526
 
406
527
class ResourceBusy(PathError):
407
528
 
408
 
    _fmt = "Device or resource busy: %(path)r%(extra)s"
 
529
    _fmt = 'Device or resource busy: "%(path)s"%(extra)s'
409
530
 
410
531
 
411
532
class PermissionDenied(PathError):
412
533
 
413
 
    _fmt = "Permission denied: %(path)r%(extra)s"
 
534
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
414
535
 
415
536
 
416
537
class InvalidURL(PathError):
417
538
 
418
 
    _fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
 
539
    _fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
419
540
 
420
541
 
421
542
class InvalidURLJoin(PathError):
422
543
 
423
 
    _fmt = "Invalid URL join request: %(args)s%(extra)s"
 
544
    _fmt = 'Invalid URL join request: "%(args)s"%(extra)s'
424
545
 
425
546
    def __init__(self, msg, base, args):
426
547
        PathError.__init__(self, base, msg)
445
566
        PathError.__init__(self, url, extra=extra)
446
567
 
447
568
 
 
569
class ReadError(PathError):
 
570
    
 
571
    _fmt = """Error reading from %(path)r."""
 
572
 
 
573
 
448
574
class ShortReadvError(PathError):
449
575
 
450
 
    _fmt = ("readv() read %(actual)s bytes rather than %(length)s bytes"
451
 
            " at %(offset)s for %(path)s%(extra)s")
 
576
    _fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
 
577
            ' at %(offset)s for "%(path)s"%(extra)s')
452
578
 
453
579
    internal_error = True
454
580
 
459
585
        self.actual = actual
460
586
 
461
587
 
462
 
class PathNotChild(BzrError):
 
588
class PathNotChild(PathError):
463
589
 
464
 
    _fmt = "Path %(path)r is not a child of path %(base)r%(extra)s"
 
590
    _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
465
591
 
466
592
    internal_error = True
467
593
 
477
603
 
478
604
class InvalidNormalization(PathError):
479
605
 
480
 
    _fmt = "Path %(path)r is not unicode normalized"
 
606
    _fmt = 'Path "%(path)s" is not unicode normalized'
481
607
 
482
608
 
483
609
# TODO: This is given a URL; we try to unescape it but doing that from inside
485
611
# TODO: Probably this behavior of should be a common superclass 
486
612
class NotBranchError(PathError):
487
613
 
488
 
    _fmt = "Not a branch: %(path)s"
 
614
    _fmt = 'Not a branch: "%(path)s".'
489
615
 
490
616
    def __init__(self, path):
491
617
       import bzrlib.urlutils as urlutils
503
629
 
504
630
class AlreadyBranchError(PathError):
505
631
 
506
 
    _fmt = "Already a branch: %(path)s."
 
632
    _fmt = 'Already a branch: "%(path)s".'
507
633
 
508
634
 
509
635
class BranchExistsWithoutWorkingTree(PathError):
510
636
 
511
 
    _fmt = "Directory contains a branch, but no working tree \
512
 
(use bzr checkout if you wish to build a working tree): %(path)s"
 
637
    _fmt = 'Directory contains a branch, but no working tree \
 
638
(use bzr checkout if you wish to build a working tree): "%(path)s"'
513
639
 
514
640
 
515
641
class AtomicFileAlreadyClosed(PathError):
516
642
 
517
 
    _fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
518
 
            " %(path)s")
 
643
    _fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
 
644
            ' "%(path)s"')
519
645
 
520
646
    def __init__(self, path, function):
521
647
        PathError.__init__(self, path=path, extra=None)
524
650
 
525
651
class InaccessibleParent(PathError):
526
652
 
527
 
    _fmt = ("Parent not accessible given base %(base)s and"
528
 
            " relative path %(path)s")
 
653
    _fmt = ('Parent not accessible given base "%(base)s" and'
 
654
            ' relative path "%(path)s"')
529
655
 
530
656
    def __init__(self, path, base):
531
657
        PathError.__init__(self, path)
534
660
 
535
661
class NoRepositoryPresent(BzrError):
536
662
 
537
 
    _fmt = "No repository present: %(path)r"
 
663
    _fmt = 'No repository present: "%(path)s"'
538
664
    def __init__(self, bzrdir):
539
665
        BzrError.__init__(self)
540
666
        self.path = bzrdir.transport.clone('..').base
542
668
 
543
669
class FileInWrongBranch(BzrError):
544
670
 
545
 
    _fmt = "File %(path)s in not in branch %(branch_base)s."
 
671
    _fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
546
672
 
547
673
    def __init__(self, branch, path):
548
674
        BzrError.__init__(self)
558
684
 
559
685
class UnknownFormatError(BzrError):
560
686
    
561
 
    _fmt = "Unknown branch format: %(format)r"
 
687
    _fmt = "Unknown %(kind)s format: %(format)r"
 
688
 
 
689
    def __init__(self, format, kind='branch'):
 
690
        self.kind = kind
 
691
        self.format = format
562
692
 
563
693
 
564
694
class IncompatibleFormat(BzrError):
592
722
class AlreadyVersionedError(BzrError):
593
723
    """Used when a path is expected not to be versioned, but it is."""
594
724
 
595
 
    _fmt = "%(context_info)s%(path)s is already versioned"
 
725
    _fmt = "%(context_info)s%(path)s is already versioned."
596
726
 
597
727
    def __init__(self, path, context_info=None):
598
728
        """Construct a new AlreadyVersionedError.
613
743
class NotVersionedError(BzrError):
614
744
    """Used when a path is expected to be versioned, but it is not."""
615
745
 
616
 
    _fmt = "%(context_info)s%(path)s is not versioned"
 
746
    _fmt = "%(context_info)s%(path)s is not versioned."
617
747
 
618
748
    def __init__(self, path, context_info=None):
619
749
        """Construct a new NotVersionedError.
672
802
 
673
803
class ForbiddenControlFileError(BzrError):
674
804
 
675
 
    _fmt = "Cannot operate on %(filename)s because it is a control file"
676
 
 
677
 
 
678
 
class LockError(BzrError):
 
805
    _fmt = 'Cannot operate on "%(filename)s" because it is a control file'
 
806
 
 
807
 
 
808
class LockError(InternalBzrError):
679
809
 
680
810
    _fmt = "Lock error: %(msg)s"
681
811
 
682
 
    internal_error = True
683
 
 
684
812
    # All exceptions from the lock/unlock functions should be from
685
813
    # this exception class.  They will be translated as necessary. The
686
814
    # original exception is available as e.original_error
688
816
    # New code should prefer to raise specific subclasses
689
817
    def __init__(self, message):
690
818
        # Python 2.5 uses a slot for StandardError.message,
691
 
        # so use a different variable name
692
 
        # so it is exposed in self.__dict__
 
819
        # so use a different variable name.  We now work around this in
 
820
        # BzrError.__str__, but this member name is kept for compatability.
693
821
        self.msg = message
694
822
 
695
823
 
734
862
 
735
863
    _fmt = "Cannot acquire write lock on %(fname)s. %(msg)s"
736
864
 
 
865
    @symbol_versioning.deprecated_method(symbol_versioning.zero_ninetytwo)
737
866
    def __init__(self, fname, msg):
738
867
        LockError.__init__(self, '')
739
868
        self.fname = fname
740
869
        self.msg = msg
741
870
 
742
871
 
 
872
class LockFailed(LockError):
 
873
 
 
874
    internal_error = False
 
875
 
 
876
    _fmt = "Cannot lock %(lock)s: %(why)s"
 
877
 
 
878
    def __init__(self, lock, why):
 
879
        LockError.__init__(self, '')
 
880
        self.lock = lock
 
881
        self.why = why
 
882
 
 
883
 
743
884
class OutSideTransaction(BzrError):
744
885
 
745
886
    _fmt = ("A transaction related operation was attempted after"
767
908
 
768
909
class UnlockableTransport(LockError):
769
910
 
 
911
    internal_error = False
 
912
 
770
913
    _fmt = "Cannot lock: transport is read only: %(transport)s"
771
914
 
772
915
    def __init__(self, transport):
775
918
 
776
919
class LockContention(LockError):
777
920
 
778
 
    _fmt = "Could not acquire lock %(lock)s"
 
921
    _fmt = 'Could not acquire lock "%(lock)s"'
779
922
    # TODO: show full url for lock, combining the transport and relative
780
923
    # bits?
781
924
 
823
966
 
824
967
    _fmt = "The object %(obj)s does not support token specifying a token when locking."
825
968
 
826
 
    internal_error = True
827
 
 
828
969
    def __init__(self, obj):
829
970
        self.obj = obj
830
971
 
845
986
    _fmt = "No changes to commit"
846
987
 
847
988
 
 
989
class CannotCommitSelectedFileMerge(BzrError):
 
990
 
 
991
    _fmt = 'Selected-file commit of merges is not supported yet:'\
 
992
        ' files %(files_str)s'
 
993
 
 
994
    def __init__(self, files):
 
995
        files_str = ', '.join(files)
 
996
        BzrError.__init__(self, files=files, files_str=files_str)
 
997
 
 
998
 
 
999
class BadCommitMessageEncoding(BzrError):
 
1000
 
 
1001
    _fmt = 'The specified commit message contains characters unsupported by '\
 
1002
        'the current encoding.'
 
1003
 
 
1004
 
848
1005
class UpgradeReadonly(BzrError):
849
1006
 
850
1007
    _fmt = "Upgrade URL cannot work with readonly URLs."
864
1021
    _fmt = "Commit refused because there are unknowns in the tree."
865
1022
 
866
1023
 
867
 
class NoSuchRevision(BzrError):
868
 
 
869
 
    _fmt = "Branch %(branch)s has no revision %(revision)s"
870
 
 
871
 
    internal_error = True
 
1024
class NoSuchRevision(InternalBzrError):
 
1025
 
 
1026
    _fmt = "%(branch)s has no revision %(revision)s"
872
1027
 
873
1028
    def __init__(self, branch, revision):
 
1029
        # 'branch' may sometimes be an internal object like a KnitRevisionStore
874
1030
        BzrError.__init__(self, branch=branch, revision=revision)
875
1031
 
876
1032
 
877
 
class NotLeftParentDescendant(BzrError):
 
1033
# zero_ninetyone: this exception is no longer raised and should be removed
 
1034
class NotLeftParentDescendant(InternalBzrError):
878
1035
 
879
1036
    _fmt = ("Revision %(old_revision)s is not the left parent of"
880
1037
            " %(new_revision)s, but branch %(branch_location)s expects this")
881
1038
 
882
 
    internal_error = True
883
 
 
884
1039
    def __init__(self, branch, old_revision, new_revision):
885
1040
        BzrError.__init__(self, branch_location=branch.base,
886
1041
                          old_revision=old_revision,
887
1042
                          new_revision=new_revision)
888
1043
 
889
1044
 
 
1045
class RangeInChangeOption(BzrError):
 
1046
 
 
1047
    _fmt = "Option --change does not accept revision ranges"
 
1048
 
 
1049
 
890
1050
class NoSuchRevisionSpec(BzrError):
891
1051
 
892
1052
    _fmt = "No namespace registered for string: %(spec)r"
898
1058
class NoSuchRevisionInTree(NoSuchRevision):
899
1059
    """When using Tree.revision_tree, and the revision is not accessible."""
900
1060
    
901
 
    _fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
 
1061
    _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
902
1062
 
903
1063
    def __init__(self, tree, revision_id):
904
1064
        BzrError.__init__(self)
941
1101
    _fmt = ("These branches have diverged."
942
1102
            " Use the merge command to reconcile them.")
943
1103
 
944
 
    internal_error = False
945
 
 
946
1104
    def __init__(self, branch1, branch2):
947
1105
        self.branch1 = branch1
948
1106
        self.branch2 = branch2
949
1107
 
950
1108
 
951
 
class NotLefthandHistory(BzrError):
 
1109
class NotLefthandHistory(InternalBzrError):
952
1110
 
953
1111
    _fmt = "Supplied history does not follow left-hand parents"
954
1112
 
955
 
    internal_error = True
956
 
 
957
1113
    def __init__(self, history):
958
1114
        BzrError.__init__(self, history=history)
959
1115
 
963
1119
    _fmt = ("Branches have no common ancestor, and"
964
1120
            " no merge base revision was specified.")
965
1121
 
966
 
    internal_error = False
 
1122
 
 
1123
class CannotReverseCherrypick(BzrError):
 
1124
 
 
1125
    _fmt = ('Selected merge cannot perform reverse cherrypicks.  Try merge3'
 
1126
            ' or diff3.')
967
1127
 
968
1128
 
969
1129
class NoCommonAncestor(BzrError):
1036
1196
 
1037
1197
class BoundBranchOutOfDate(BzrError):
1038
1198
 
1039
 
    _fmt = ("Bound branch %(branch)s is out of date"
1040
 
            " with master branch %(master)s.")
 
1199
    _fmt = ("Bound branch %(branch)s is out of date with master branch"
 
1200
            " %(master)s.")
1041
1201
 
1042
1202
    def __init__(self, branch, master):
1043
1203
        BzrError.__init__(self)
1119
1279
 
1120
1280
class WeaveParentMismatch(WeaveError):
1121
1281
 
1122
 
    _fmt = "Parents are mismatched between two revisions."
 
1282
    _fmt = "Parents are mismatched between two revisions. %(message)s"
1123
1283
    
1124
1284
 
1125
1285
class WeaveInvalidChecksum(WeaveError):
1158
1318
 
1159
1319
class RevisionNotPresent(VersionedFileError):
1160
1320
    
1161
 
    _fmt = "Revision {%(revision_id)s} not present in %(file_id)s."
 
1321
    _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1162
1322
 
1163
1323
    def __init__(self, revision_id, file_id):
1164
1324
        VersionedFileError.__init__(self)
1168
1328
 
1169
1329
class RevisionAlreadyPresent(VersionedFileError):
1170
1330
    
1171
 
    _fmt = "Revision {%(revision_id)s} already present in %(file_id)s."
 
1331
    _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1172
1332
 
1173
1333
    def __init__(self, revision_id, file_id):
1174
1334
        VersionedFileError.__init__(self)
1176
1336
        self.file_id = file_id
1177
1337
 
1178
1338
 
1179
 
class KnitError(BzrError):
 
1339
class VersionedFileInvalidChecksum(VersionedFileError):
 
1340
 
 
1341
    _fmt = "Text did not match its checksum: %(message)s"
 
1342
 
 
1343
 
 
1344
class KnitError(InternalBzrError):
1180
1345
    
1181
1346
    _fmt = "Knit error"
1182
1347
 
1183
 
    internal_error = True
1184
 
 
1185
 
 
1186
 
class KnitHeaderError(KnitError):
1187
 
 
1188
 
    _fmt = "Knit header error: %(badline)r unexpected for file %(filename)s"
1189
 
 
1190
 
    def __init__(self, badline, filename):
1191
 
        KnitError.__init__(self)
1192
 
        self.badline = badline
1193
 
        self.filename = filename
1194
 
 
1195
1348
 
1196
1349
class KnitCorrupt(KnitError):
1197
1350
 
1203
1356
        self.how = how
1204
1357
 
1205
1358
 
 
1359
class KnitDataStreamIncompatible(KnitError):
 
1360
    # Not raised anymore, as we can convert data streams.  In future we may
 
1361
    # need it again for more exotic cases, so we're keeping it around for now.
 
1362
 
 
1363
    _fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
 
1364
 
 
1365
    def __init__(self, stream_format, target_format):
 
1366
        self.stream_format = stream_format
 
1367
        self.target_format = target_format
 
1368
        
 
1369
 
 
1370
class KnitDataStreamUnknown(KnitError):
 
1371
    # Indicates a data stream we don't know how to handle.
 
1372
 
 
1373
    _fmt = "Cannot parse knit data stream of format \"%(stream_format)s\"."
 
1374
 
 
1375
    def __init__(self, stream_format):
 
1376
        self.stream_format = stream_format
 
1377
        
 
1378
 
 
1379
class KnitHeaderError(KnitError):
 
1380
 
 
1381
    _fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
 
1382
 
 
1383
    def __init__(self, badline, filename):
 
1384
        KnitError.__init__(self)
 
1385
        self.badline = badline
 
1386
        self.filename = filename
 
1387
 
1206
1388
class KnitIndexUnknownMethod(KnitError):
1207
1389
    """Raised when we don't understand the storage method.
1208
1390
 
1243
1425
        BzrError.__init__(self)
1244
1426
 
1245
1427
 
1246
 
class TooManyConcurrentRequests(BzrError):
 
1428
class TooManyConcurrentRequests(InternalBzrError):
1247
1429
 
1248
1430
    _fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1249
1431
            " Be sure to finish_writing and finish_reading on the"
1250
1432
            " currently open request.")
1251
1433
 
1252
 
    internal_error = True
1253
 
 
1254
1434
    def __init__(self, medium):
1255
1435
        self.medium = medium
1256
1436
 
1300
1480
 
1301
1481
class InvalidRange(TransportError):
1302
1482
 
1303
 
    _fmt = "Invalid range access in %(path)s at %(offset)s."
1304
 
    
1305
 
    def __init__(self, path, offset):
1306
 
        TransportError.__init__(self, ("Invalid range access in %s at %d"
1307
 
                                       % (path, offset)))
 
1483
    _fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
 
1484
 
 
1485
    def __init__(self, path, offset, msg=None):
 
1486
        TransportError.__init__(self, msg)
1308
1487
        self.path = path
1309
1488
        self.offset = offset
1310
1489
 
1321
1500
class InvalidHttpRange(InvalidHttpResponse):
1322
1501
 
1323
1502
    _fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1324
 
    
 
1503
 
1325
1504
    def __init__(self, path, range, msg):
1326
1505
        self.range = range
1327
1506
        InvalidHttpResponse.__init__(self, path, msg)
1330
1509
class InvalidHttpContentType(InvalidHttpResponse):
1331
1510
 
1332
1511
    _fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1333
 
    
 
1512
 
1334
1513
    def __init__(self, path, ctype, msg):
1335
1514
        self.ctype = ctype
1336
1515
        InvalidHttpResponse.__init__(self, path, msg)
1340
1519
 
1341
1520
    _fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1342
1521
 
1343
 
    def __init__(self, source, target, is_permament=False, qual_proto=None):
 
1522
    def __init__(self, source, target, is_permanent=False, qual_proto=None):
1344
1523
        self.source = source
1345
1524
        self.target = target
1346
 
        if is_permament:
 
1525
        if is_permanent:
1347
1526
            self.permanently = ' permanently'
1348
1527
        else:
1349
1528
            self.permanently = ''
1350
 
        self.is_permament = is_permament
1351
1529
        self._qualified_proto = qual_proto
1352
1530
        TransportError.__init__(self)
1353
1531
 
1389
1567
 
1390
1568
    _fmt = "Too many redirections"
1391
1569
 
 
1570
 
1392
1571
class ConflictsInTree(BzrError):
1393
1572
 
1394
1573
    _fmt = "Working tree has conflicts."
1415
1594
 
1416
1595
class SigningFailed(BzrError):
1417
1596
 
1418
 
    _fmt = "Failed to gpg sign data with command %(command_line)r"
 
1597
    _fmt = 'Failed to gpg sign data with command "%(command_line)s"'
1419
1598
 
1420
1599
    def __init__(self, command_line):
1421
1600
        BzrError.__init__(self, command_line=command_line)
1446
1625
        self.graph = graph
1447
1626
 
1448
1627
 
1449
 
class WritingCompleted(BzrError):
 
1628
class WritingCompleted(InternalBzrError):
1450
1629
 
1451
1630
    _fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1452
1631
            "called upon it - accept bytes may not be called anymore.")
1453
1632
 
1454
 
    internal_error = True
1455
 
 
1456
1633
    def __init__(self, request):
1457
1634
        self.request = request
1458
1635
 
1459
1636
 
1460
 
class WritingNotComplete(BzrError):
 
1637
class WritingNotComplete(InternalBzrError):
1461
1638
 
1462
1639
    _fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1463
1640
            "called upon it - until the write phase is complete no "
1464
1641
            "data may be read.")
1465
1642
 
1466
 
    internal_error = True
1467
 
 
1468
1643
    def __init__(self, request):
1469
1644
        self.request = request
1470
1645
 
1478
1653
        self.filename = filename
1479
1654
 
1480
1655
 
1481
 
class MediumNotConnected(BzrError):
 
1656
class MediumNotConnected(InternalBzrError):
1482
1657
 
1483
1658
    _fmt = """The medium '%(medium)s' is not connected."""
1484
1659
 
1485
 
    internal_error = True
1486
 
 
1487
1660
    def __init__(self, medium):
1488
1661
        self.medium = medium
1489
1662
 
1495
1668
 
1496
1669
class NoBundleFound(BzrError):
1497
1670
 
1498
 
    _fmt = "No bundle was found in %(filename)s"
 
1671
    _fmt = 'No bundle was found in "%(filename)s".'
1499
1672
 
1500
1673
    def __init__(self, filename):
1501
1674
        BzrError.__init__(self)
1565
1738
        self.root_trans_id = transform.root
1566
1739
 
1567
1740
 
1568
 
class BzrBadParameter(BzrError):
 
1741
class BzrBadParameter(InternalBzrError):
1569
1742
 
1570
1743
    _fmt = "Bad parameter: %(param)r"
1571
1744
 
1636
1809
class BzrRemoveChangedFilesError(BzrError):
1637
1810
    """Used when user is trying to remove changed files."""
1638
1811
 
1639
 
    _fmt = ("Can't remove changed or unknown files:\n%(changes_as_text)s"
 
1812
    _fmt = ("Can't safely remove modified or unknown files:\n"
 
1813
        "%(changes_as_text)s"
1640
1814
        "Use --keep to not delete them, or --force to delete them regardless.")
1641
1815
 
1642
1816
    def __init__(self, tree_delta):
1707
1881
        self.format = format
1708
1882
 
1709
1883
 
 
1884
class NoDiffFound(BzrError):
 
1885
 
 
1886
    _fmt = 'Could not find an appropriate Differ for file "%(path)s"'
 
1887
 
 
1888
    def __init__(self, path):
 
1889
        BzrError.__init__(self, path)
 
1890
 
 
1891
 
 
1892
class ExecutableMissing(BzrError):
 
1893
 
 
1894
    _fmt = "%(exe_name)s could not be found on this machine"
 
1895
 
 
1896
    def __init__(self, exe_name):
 
1897
        BzrError.__init__(self, exe_name=exe_name)
 
1898
 
 
1899
 
1710
1900
class NoDiff(BzrError):
1711
1901
 
1712
1902
    _fmt = "Diff is not installed on this machine: %(msg)s"
1720
1910
    _fmt = "Diff3 is not installed on this machine."
1721
1911
 
1722
1912
 
 
1913
class ExistingContent(BzrError):
 
1914
    # Added in bzrlib 0.92, used by VersionedFile.add_lines.
 
1915
 
 
1916
    _fmt = "The content being inserted is already present."
 
1917
 
 
1918
 
1723
1919
class ExistingLimbo(BzrError):
1724
1920
 
1725
1921
    _fmt = """This tree contains left-over files from a failed operation.
1731
1927
       self.limbo_dir = limbo_dir
1732
1928
 
1733
1929
 
 
1930
class ExistingPendingDeletion(BzrError):
 
1931
 
 
1932
    _fmt = """This tree contains left-over files from a failed operation.
 
1933
    Please examine %(pending_deletion)s to see if it contains any files you
 
1934
    wish to keep, and delete it when you are done."""
 
1935
 
 
1936
    def __init__(self, pending_deletion):
 
1937
       BzrError.__init__(self, pending_deletion=pending_deletion)
 
1938
 
 
1939
 
1734
1940
class ImmortalLimbo(BzrError):
1735
1941
 
1736
 
    _fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
 
1942
    _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1737
1943
    Please examine %(limbo_dir)s to see if it contains any files you wish to
1738
1944
    keep, and delete it when you are done."""
1739
1945
 
1742
1948
       self.limbo_dir = limbo_dir
1743
1949
 
1744
1950
 
 
1951
class ImmortalPendingDeletion(BzrError):
 
1952
 
 
1953
    _fmt = ("Unable to delete transform temporary directory "
 
1954
    "%(pending_deletion)s.  Please examine %(pending_deletion)s to see if it "
 
1955
    "contains any files you wish to keep, and delete it when you are done.")
 
1956
 
 
1957
    def __init__(self, pending_deletion):
 
1958
       BzrError.__init__(self, pending_deletion=pending_deletion)
 
1959
 
 
1960
 
1745
1961
class OutOfDateTree(BzrError):
1746
1962
 
1747
1963
    _fmt = "Working tree is out of date, please run 'bzr update'."
1774
1990
    _fmt = "Format error in conflict listings"
1775
1991
 
1776
1992
 
 
1993
class CorruptDirstate(BzrError):
 
1994
 
 
1995
    _fmt = ("Inconsistency in dirstate file %(dirstate_path)s.\n"
 
1996
            "Error: %(description)s")
 
1997
 
 
1998
    def __init__(self, dirstate_path, description):
 
1999
        BzrError.__init__(self)
 
2000
        self.dirstate_path = dirstate_path
 
2001
        self.description = description
 
2002
 
 
2003
 
1777
2004
class CorruptRepository(BzrError):
1778
2005
 
1779
2006
    _fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1784
2011
        self.repo_path = repo.bzrdir.root_transport.base
1785
2012
 
1786
2013
 
 
2014
class InconsistentDelta(BzrError):
 
2015
    """Used when we get a delta that is not valid."""
 
2016
 
 
2017
    _fmt = ("An inconsistent delta was supplied involving %(path)r,"
 
2018
            " %(file_id)r\nreason: %(reason)s")
 
2019
 
 
2020
    def __init__(self, path, file_id, reason):
 
2021
        BzrError.__init__(self)
 
2022
        self.path = path
 
2023
        self.file_id = file_id
 
2024
        self.reason = reason
 
2025
 
 
2026
 
1787
2027
class UpgradeRequired(BzrError):
1788
2028
 
1789
2029
    _fmt = "To use this feature you must upgrade your branch at %(path)s."
1930
2170
    _fmt = """This operation requires rich root data storage"""
1931
2171
 
1932
2172
 
1933
 
class NoSmartMedium(BzrError):
 
2173
class NoSmartMedium(InternalBzrError):
1934
2174
 
1935
2175
    _fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1936
2176
 
1937
 
    internal_error = True
1938
 
 
1939
2177
    def __init__(self, transport):
1940
2178
        self.transport = transport
1941
2179
 
1972
2210
        self.revision_id = revision_id
1973
2211
 
1974
2212
 
1975
 
class IllegalUseOfScopeReplacer(BzrError):
 
2213
class IllegalUseOfScopeReplacer(InternalBzrError):
1976
2214
 
1977
2215
    _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
1978
2216
            " %(msg)s%(extra)s")
1979
2217
 
1980
 
    internal_error = True
1981
 
 
1982
2218
    def __init__(self, name, msg, extra=None):
1983
2219
        BzrError.__init__(self)
1984
2220
        self.name = name
1989
2225
            self.extra = ''
1990
2226
 
1991
2227
 
1992
 
class InvalidImportLine(BzrError):
 
2228
class InvalidImportLine(InternalBzrError):
1993
2229
 
1994
2230
    _fmt = "Not a valid import statement: %(msg)\n%(text)s"
1995
2231
 
1996
 
    internal_error = True
1997
 
 
1998
2232
    def __init__(self, text, msg):
1999
2233
        BzrError.__init__(self)
2000
2234
        self.text = text
2001
2235
        self.msg = msg
2002
2236
 
2003
2237
 
2004
 
class ImportNameCollision(BzrError):
 
2238
class ImportNameCollision(InternalBzrError):
2005
2239
 
2006
2240
    _fmt = ("Tried to import an object to the same name as"
2007
2241
            " an existing object. %(name)s")
2008
2242
 
2009
 
    internal_error = True
2010
 
 
2011
2243
    def __init__(self, name):
2012
2244
        BzrError.__init__(self)
2013
2245
        self.name = name
2026
2258
        " branch location."
2027
2259
 
2028
2260
 
 
2261
class IllegalMergeDirectivePayload(BzrError):
 
2262
    """A merge directive contained something other than a patch or bundle"""
 
2263
 
 
2264
    _fmt = "Bad merge directive payload %(start)r"
 
2265
 
 
2266
    def __init__(self, start):
 
2267
        BzrError(self)
 
2268
        self.start = start
 
2269
 
 
2270
 
 
2271
class PatchVerificationFailed(BzrError):
 
2272
    """A patch from a merge directive could not be verified"""
 
2273
 
 
2274
    _fmt = "Preview patch does not match requested changes."
 
2275
 
 
2276
 
2029
2277
class PatchMissing(BzrError):
2030
2278
    """Raise a patch type was specified but no patch supplied"""
2031
2279
 
2032
 
    _fmt = "patch_type was %(patch_type)s, but no patch was supplied."
 
2280
    _fmt = "Patch_type was %(patch_type)s, but no patch was supplied."
2033
2281
 
2034
2282
    def __init__(self, patch_type):
2035
2283
        BzrError.__init__(self)
2046
2294
 
2047
2295
class BadSubsumeSource(BzrError):
2048
2296
 
2049
 
    _fmt = """Can't subsume %(other_tree)s into %(tree)s.  %(reason)s"""
 
2297
    _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2050
2298
 
2051
2299
    def __init__(self, tree, other_tree, reason):
2052
2300
        self.tree = tree
2062
2310
        self.other_tree = other_tree
2063
2311
 
2064
2312
 
2065
 
class BadReferenceTarget(BzrError):
2066
 
 
2067
 
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s.  %(reason)s"
2068
 
 
2069
 
    internal_error = True
 
2313
class BadReferenceTarget(InternalBzrError):
 
2314
 
 
2315
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
 
2316
           "%(reason)s"
2070
2317
 
2071
2318
    def __init__(self, tree, other_tree, reason):
2072
2319
        self.tree = tree
2108
2355
        self.reason = reason
2109
2356
 
2110
2357
 
 
2358
class InvalidBugTrackerURL(BzrError):
 
2359
 
 
2360
    _fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
 
2361
            "contain {id}: %(url)s")
 
2362
 
 
2363
    def __init__(self, abbreviation, url):
 
2364
        self.abbreviation = abbreviation
 
2365
        self.url = url
 
2366
 
 
2367
 
2111
2368
class UnknownBugTrackerAbbreviation(BzrError):
2112
2369
 
2113
2370
    _fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2124
2381
 
2125
2382
    def __init__(self, response_tuple):
2126
2383
        self.response_tuple = response_tuple
 
2384
 
 
2385
 
 
2386
class ContainerError(BzrError):
 
2387
    """Base class of container errors."""
 
2388
 
 
2389
 
 
2390
class UnknownContainerFormatError(ContainerError):
 
2391
 
 
2392
    _fmt = "Unrecognised container format: %(container_format)r"
 
2393
    
 
2394
    def __init__(self, container_format):
 
2395
        self.container_format = container_format
 
2396
 
 
2397
 
 
2398
class UnexpectedEndOfContainerError(ContainerError):
 
2399
 
 
2400
    _fmt = "Unexpected end of container stream"
 
2401
 
 
2402
 
 
2403
class UnknownRecordTypeError(ContainerError):
 
2404
 
 
2405
    _fmt = "Unknown record type: %(record_type)r"
 
2406
 
 
2407
    def __init__(self, record_type):
 
2408
        self.record_type = record_type
 
2409
 
 
2410
 
 
2411
class InvalidRecordError(ContainerError):
 
2412
 
 
2413
    _fmt = "Invalid record: %(reason)s"
 
2414
 
 
2415
    def __init__(self, reason):
 
2416
        self.reason = reason
 
2417
 
 
2418
 
 
2419
class ContainerHasExcessDataError(ContainerError):
 
2420
 
 
2421
    _fmt = "Container has data after end marker: %(excess)r"
 
2422
 
 
2423
    def __init__(self, excess):
 
2424
        self.excess = excess
 
2425
 
 
2426
 
 
2427
class DuplicateRecordNameError(ContainerError):
 
2428
 
 
2429
    _fmt = "Container has multiple records with the same name: %(name)s"
 
2430
 
 
2431
    def __init__(self, name):
 
2432
        self.name = name
 
2433
 
 
2434
 
 
2435
class NoDestinationAddress(InternalBzrError):
 
2436
 
 
2437
    _fmt = "Message does not have a destination address."
 
2438
 
 
2439
 
 
2440
class RepositoryDataStreamError(BzrError):
 
2441
 
 
2442
    _fmt = "Corrupt or incompatible data stream: %(reason)s"
 
2443
 
 
2444
    def __init__(self, reason):
 
2445
        self.reason = reason
 
2446
 
 
2447
 
 
2448
class SMTPError(BzrError):
 
2449
 
 
2450
    _fmt = "SMTP error: %(error)s"
 
2451
 
 
2452
    def __init__(self, error):
 
2453
        self.error = error
 
2454
 
 
2455
 
 
2456
class NoMessageSupplied(BzrError):
 
2457
 
 
2458
    _fmt = "No message supplied."
 
2459
 
 
2460
 
 
2461
class NoMailAddressSpecified(BzrError):
 
2462
 
 
2463
    _fmt = "No mail-to address specified."
 
2464
 
 
2465
 
 
2466
class UnknownMailClient(BzrError):
 
2467
 
 
2468
    _fmt = "Unknown mail client: %(mail_client)s"
 
2469
 
 
2470
    def __init__(self, mail_client):
 
2471
        BzrError.__init__(self, mail_client=mail_client)
 
2472
 
 
2473
 
 
2474
class MailClientNotFound(BzrError):
 
2475
 
 
2476
    _fmt = "Unable to find mail client with the following names:"\
 
2477
        " %(mail_command_list_string)s"
 
2478
 
 
2479
    def __init__(self, mail_command_list):
 
2480
        mail_command_list_string = ', '.join(mail_command_list)
 
2481
        BzrError.__init__(self, mail_command_list=mail_command_list,
 
2482
                          mail_command_list_string=mail_command_list_string)
 
2483
 
 
2484
class SMTPConnectionRefused(SMTPError):
 
2485
 
 
2486
    _fmt = "SMTP connection to %(host)s refused"
 
2487
 
 
2488
    def __init__(self, error, host):
 
2489
        self.error = error
 
2490
        self.host = host
 
2491
 
 
2492
 
 
2493
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
 
2494
 
 
2495
    _fmt = "Please specify smtp_server.  No server at default %(host)s."
 
2496
 
 
2497
 
 
2498
class BzrDirError(BzrError):
 
2499
 
 
2500
    def __init__(self, bzrdir):
 
2501
        import bzrlib.urlutils as urlutils
 
2502
        display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
 
2503
                                                    'ascii')
 
2504
        BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
 
2505
 
 
2506
 
 
2507
class AlreadyBranch(BzrDirError):
 
2508
 
 
2509
    _fmt = "'%(display_url)s' is already a branch."
 
2510
 
 
2511
 
 
2512
class AlreadyTree(BzrDirError):
 
2513
 
 
2514
    _fmt = "'%(display_url)s' is already a tree."
 
2515
 
 
2516
 
 
2517
class AlreadyCheckout(BzrDirError):
 
2518
 
 
2519
    _fmt = "'%(display_url)s' is already a checkout."
 
2520
 
 
2521
 
 
2522
class AlreadyLightweightCheckout(BzrDirError):
 
2523
 
 
2524
    _fmt = "'%(display_url)s' is already a lightweight checkout."
 
2525
 
 
2526
 
 
2527
class ReconfigurationNotSupported(BzrDirError):
 
2528
 
 
2529
    _fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
 
2530
 
 
2531
 
 
2532
class NoBindLocation(BzrDirError):
 
2533
 
 
2534
    _fmt = "No location could be found to bind to at %(display_url)s."
 
2535
 
 
2536
 
 
2537
class UncommittedChanges(BzrError):
 
2538
 
 
2539
    _fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
 
2540
 
 
2541
    def __init__(self, tree):
 
2542
        import bzrlib.urlutils as urlutils
 
2543
        display_url = urlutils.unescape_for_display(
 
2544
            tree.bzrdir.root_transport.base, 'ascii')
 
2545
        BzrError.__init__(self, tree=tree, display_url=display_url)
 
2546
 
 
2547
 
 
2548
class MissingTemplateVariable(BzrError):
 
2549
 
 
2550
    _fmt = 'Variable {%(name)s} is not available.'
 
2551
 
 
2552
    def __init__(self, name):
 
2553
        self.name = name
 
2554
 
 
2555
 
 
2556
class NoTemplate(BzrError):
 
2557
 
 
2558
    _fmt = 'No template specified.'
 
2559
 
 
2560
 
 
2561
class UnableCreateSymlink(BzrError):
 
2562
 
 
2563
    _fmt = 'Unable to create symlink %(path_str)son this platform'
 
2564
 
 
2565
    def __init__(self, path=None):
 
2566
        path_str = ''
 
2567
        if path:
 
2568
            try:
 
2569
                path_str = repr(str(path))
 
2570
            except UnicodeEncodeError:
 
2571
                path_str = repr(path)
 
2572
            path_str += ' '
 
2573
        self.path_str = path_str
 
2574
 
 
2575
 
 
2576
class UnsupportedTimezoneFormat(BzrError):
 
2577
 
 
2578
    _fmt = ('Unsupported timezone format "%(timezone)s", '
 
2579
            'options are "utc", "original", "local".')
 
2580
 
 
2581
    def __init__(self, timezone):
 
2582
        self.timezone = timezone
 
2583
 
 
2584
 
 
2585
class UnableEncodePath(BzrError):
 
2586
 
 
2587
    _fmt = ('Unable to encode %(kind)s path %(path)r in '
 
2588
            'user encoding %(user_encoding)s')
 
2589
 
 
2590
    def __init__(self, path, kind):
 
2591
        self.path = path
 
2592
        self.kind = kind
 
2593
        self.user_encoding = osutils.get_user_encoding()