/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 breezy/errors.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2013, 2016 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
17
17
"""Exceptions for bzr, and reporting of them.
18
18
"""
19
19
 
20
 
from __future__ import absolute_import
21
20
 
22
21
# TODO: is there any value in providing the .args field used by standard
23
22
# python exceptions?   A list of values with no names seems less useful
32
31
# 'unprintable'.
33
32
 
34
33
 
35
 
# return codes from the bzr program
 
34
# return codes from the brz program
36
35
EXIT_OK = 0
37
36
EXIT_ERROR = 3
38
37
EXIT_INTERNAL_ERROR = 4
39
38
 
40
39
 
41
 
class BzrError(StandardError):
 
40
class BzrError(Exception):
42
41
    """
43
 
    Base class for errors raised by bzrlib.
 
42
    Base class for errors raised by breezy.
44
43
 
45
 
    :cvar internal_error: if True this was probably caused by a bzr bug and
 
44
    :cvar internal_error: if True this was probably caused by a brz bug and
46
45
        should be displayed with a traceback; if False (or absent) this was
47
46
        probably a user or environment error and they don't need the gory
48
47
        details.  (That can be overridden by -Derror on the command line.)
72
71
           not subject to expansion. 'msg' is used instead of 'message' because
73
72
           python evolved and, in 2.6, forbids the use of 'message'.
74
73
        """
75
 
        StandardError.__init__(self)
 
74
        Exception.__init__(self)
76
75
        if msg is not None:
77
76
            # I was going to deprecate this, but it actually turns out to be
78
77
            # quite handy - mbp 20061103.
87
86
        if s is not None:
88
87
            # contains a preformatted message
89
88
            return s
 
89
        err = None
90
90
        try:
91
91
            fmt = self._get_format_string()
92
92
            if fmt:
95
95
                # __str__() should always return a 'str' object
96
96
                # never a 'unicode' object.
97
97
                return s
98
 
        except Exception, e:
99
 
            pass # just bind to 'e' for formatting below
100
 
        else:
101
 
            e = None
 
98
        except Exception as e:
 
99
            err = e
102
100
        return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
103
101
            % (self.__class__.__name__,
104
102
               self.__dict__,
105
103
               getattr(self, '_fmt', None),
106
 
               e)
107
 
 
108
 
    def __unicode__(self):
109
 
        u = self._format()
110
 
        if isinstance(u, str):
111
 
            # Try decoding the str using the default encoding.
112
 
            u = unicode(u)
113
 
        elif not isinstance(u, unicode):
114
 
            # Try to make a unicode object from it, because __unicode__ must
115
 
            # return a unicode object.
116
 
            u = unicode(u)
117
 
        return u
118
 
 
119
 
    def __str__(self):
120
 
        s = self._format()
121
 
        if isinstance(s, unicode):
122
 
            s = s.encode('utf8')
123
 
        else:
124
 
            # __str__ must return a str.
125
 
            s = str(s)
126
 
        return s
 
104
               err)
 
105
 
 
106
    __str__ = _format
127
107
 
128
108
    def __repr__(self):
129
109
        return '%s(%s)' % (self.__class__.__name__, str(self))
132
112
        """Return format string for this exception or None"""
133
113
        fmt = getattr(self, '_fmt', None)
134
114
        if fmt is not None:
135
 
            from bzrlib.i18n import gettext
136
 
            return gettext(unicode(fmt)) # _fmt strings should be ascii
 
115
            from breezy.i18n import gettext
 
116
            return gettext(fmt)  # _fmt strings should be ascii
137
117
 
138
118
    def __eq__(self, other):
139
119
        if self.__class__ is not other.__class__:
140
120
            return NotImplemented
141
121
        return self.__dict__ == other.__dict__
142
122
 
 
123
    def __hash__(self):
 
124
        return id(self)
 
125
 
143
126
 
144
127
class InternalBzrError(BzrError):
145
128
    """Base class for errors that are internal in nature.
152
135
    internal_error = True
153
136
 
154
137
 
155
 
class AlreadyBuilding(BzrError):
156
 
 
157
 
    _fmt = "The tree builder is already building a tree."
158
 
 
159
 
 
160
138
class BranchError(BzrError):
161
139
    """Base class for concrete 'errors about a branch'."""
162
140
 
173
151
        self.msg = msg
174
152
 
175
153
 
176
 
class DirstateCorrupt(BzrError):
177
 
 
178
 
    _fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s"
179
 
 
180
 
    def __init__(self, state, msg):
181
 
        BzrError.__init__(self)
182
 
        self.state = state
183
 
        self.msg = msg
184
 
 
185
 
 
186
 
class DisabledMethod(InternalBzrError):
187
 
 
188
 
    _fmt = "The smart server method '%(class_name)s' is disabled."
189
 
 
190
 
    def __init__(self, class_name):
191
 
        BzrError.__init__(self)
192
 
        self.class_name = class_name
193
 
 
194
 
 
195
 
class IncompatibleAPI(BzrError):
196
 
 
197
 
    _fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
198
 
        'It supports versions "%(minimum)s" to "%(current)s".'
199
 
 
200
 
    def __init__(self, api, wanted, minimum, current):
 
154
class IncompatibleVersion(BzrError):
 
155
 
 
156
    _fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\
 
157
           'is required, but current version is %(current)r.'
 
158
 
 
159
    def __init__(self, api, wanted, current):
201
160
        self.api = api
202
161
        self.wanted = wanted
203
 
        self.minimum = minimum
204
162
        self.current = current
205
163
 
206
164
 
213
171
        self.transport = transport
214
172
 
215
173
 
216
 
class InvalidEntryName(InternalBzrError):
217
 
 
218
 
    _fmt = "Invalid entry name: %(name)s"
219
 
 
220
 
    def __init__(self, name):
221
 
        BzrError.__init__(self)
222
 
        self.name = name
223
 
 
224
 
 
225
174
class InvalidRevisionNumber(BzrError):
226
175
 
227
176
    _fmt = "Invalid revision number %(revno)s"
253
202
class RootMissing(InternalBzrError):
254
203
 
255
204
    _fmt = ("The root entry of a tree must be the first entry supplied to "
256
 
        "the commit builder.")
 
205
            "the commit builder.")
257
206
 
258
207
 
259
208
class NoPublicBranch(BzrError):
261
210
    _fmt = 'There is no public branch set for "%(branch_url)s".'
262
211
 
263
212
    def __init__(self, branch):
264
 
        import bzrlib.urlutils as urlutils
 
213
        from . import urlutils
265
214
        public_location = urlutils.unescape_for_display(branch.base, 'ascii')
266
215
        BzrError.__init__(self, branch_url=public_location)
267
216
 
268
217
 
269
 
class NoHelpTopic(BzrError):
270
 
 
271
 
    _fmt = ("No help could be found for '%(topic)s'. "
272
 
        "Please use 'bzr help topics' to obtain a list of topics.")
273
 
 
274
 
    def __init__(self, topic):
275
 
        self.topic = topic
276
 
 
277
 
 
278
218
class NoSuchId(BzrError):
279
219
 
280
220
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
285
225
        self.tree = tree
286
226
 
287
227
 
288
 
class NoSuchIdInRepository(NoSuchId):
289
 
 
290
 
    _fmt = ('The file id "%(file_id)s" is not present in the repository'
291
 
            ' %(repository)r')
292
 
 
293
 
    def __init__(self, repository, file_id):
294
 
        BzrError.__init__(self, repository=repository, file_id=file_id)
295
 
 
296
 
 
297
228
class NotStacked(BranchError):
298
229
 
299
230
    _fmt = "The branch '%(branch)s' is not stacked."
300
231
 
301
232
 
302
 
class InventoryModified(InternalBzrError):
303
 
 
304
 
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
305
 
            " so a clean inventory cannot be read without data loss.")
306
 
 
307
 
    def __init__(self, tree):
308
 
        self.tree = tree
309
 
 
310
 
 
311
233
class NoWorkingTree(BzrError):
312
234
 
313
235
    _fmt = 'No WorkingTree exists for "%(base)s".'
317
239
        self.base = base
318
240
 
319
241
 
320
 
class NotBuilding(BzrError):
321
 
 
322
 
    _fmt = "Not currently building a tree."
323
 
 
324
 
 
325
242
class NotLocalUrl(BzrError):
326
243
 
327
244
    _fmt = "%(url)s is not a local path."
338
255
        self.base = base
339
256
 
340
257
 
341
 
class BzrCommandError(BzrError):
 
258
class NoWhoami(BzrError):
 
259
 
 
260
    _fmt = ('Unable to determine your name.\n'
 
261
            "Please, set your name with the 'whoami' command.\n"
 
262
            'E.g. brz whoami "Your Name <name@example.com>"')
 
263
 
 
264
 
 
265
class CommandError(BzrError):
342
266
    """Error from user command"""
343
267
 
344
268
    # Error from malformed user command; please avoid raising this as a
346
270
    #
347
271
    # I think it's a waste of effort to differentiate between errors that
348
272
    # are not intended to be caught anyway.  UI code need not subclass
349
 
    # BzrCommandError, and non-UI code should not throw a subclass of
350
 
    # BzrCommandError.  ADHB 20051211
 
273
    # CommandError, and non-UI code should not throw a subclass of
 
274
    # CommandError.  ADHB 20051211
 
275
 
 
276
 
 
277
# Provide the old name as backup, for the moment.
 
278
BzrCommandError = CommandError
351
279
 
352
280
 
353
281
class NotWriteLocked(BzrError):
358
286
        self.not_locked = not_locked
359
287
 
360
288
 
361
 
class BzrOptionError(BzrCommandError):
362
 
 
363
 
    _fmt = "Error in command line options"
364
 
 
365
 
 
366
 
class BadIndexFormatSignature(BzrError):
367
 
 
368
 
    _fmt = "%(value)s is not an index of type %(_type)s."
369
 
 
370
 
    def __init__(self, value, _type):
371
 
        BzrError.__init__(self)
372
 
        self.value = value
373
 
        self._type = _type
374
 
 
375
 
 
376
 
class BadIndexData(BzrError):
377
 
 
378
 
    _fmt = "Error in data for index %(value)s."
379
 
 
380
 
    def __init__(self, value):
381
 
        BzrError.__init__(self)
382
 
        self.value = value
383
 
 
384
 
 
385
 
class BadIndexDuplicateKey(BzrError):
386
 
 
387
 
    _fmt = "The key '%(key)s' is already in index '%(index)s'."
388
 
 
389
 
    def __init__(self, key, index):
390
 
        BzrError.__init__(self)
391
 
        self.key = key
392
 
        self.index = index
393
 
 
394
 
 
395
 
class BadIndexKey(BzrError):
396
 
 
397
 
    _fmt = "The key '%(key)s' is not a valid key."
398
 
 
399
 
    def __init__(self, key):
400
 
        BzrError.__init__(self)
401
 
        self.key = key
402
 
 
403
 
 
404
 
class BadIndexOptions(BzrError):
405
 
 
406
 
    _fmt = "Could not parse options for index %(value)s."
407
 
 
408
 
    def __init__(self, value):
409
 
        BzrError.__init__(self)
410
 
        self.value = value
411
 
 
412
 
 
413
 
class BadIndexValue(BzrError):
414
 
 
415
 
    _fmt = "The value '%(value)s' is not a valid value."
416
 
 
417
 
    def __init__(self, value):
418
 
        BzrError.__init__(self)
419
 
        self.value = value
420
 
 
421
 
 
422
 
class BadOptionValue(BzrError):
423
 
 
424
 
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
425
 
 
426
 
    def __init__(self, name, value):
427
 
        BzrError.__init__(self, name=name, value=value)
428
 
 
429
 
 
430
289
class StrictCommitFailed(BzrError):
431
290
 
432
291
    _fmt = "Commit refused because there are unknown files in the tree"
465
324
    """Used when renaming and both source and dest exist."""
466
325
 
467
326
    _fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
468
 
            " (Use --after to tell bzr about a rename that has already"
 
327
            " (Use --after to tell brz about a rename that has already"
469
328
            " happened)%(extra)s")
470
329
 
471
330
    def __init__(self, source, dest, extra=None):
518
377
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
519
378
 
520
379
 
521
 
class InvalidURL(PathError):
522
 
 
523
 
    _fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
524
 
 
525
 
 
526
 
class InvalidURLJoin(PathError):
527
 
 
528
 
    _fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r"
529
 
 
530
 
    def __init__(self, reason, base, join_args):
531
 
        self.reason = reason
532
 
        self.base = base
533
 
        self.join_args = join_args
534
 
        PathError.__init__(self, base, reason)
535
 
 
536
 
 
537
 
class InvalidRebaseURLs(PathError):
538
 
 
539
 
    _fmt = "URLs differ by more than path: %(from_)r and %(to)r"
540
 
 
541
 
    def __init__(self, from_, to):
542
 
        self.from_ = from_
543
 
        self.to = to
544
 
        PathError.__init__(self, from_, 'URLs differ by more than path.')
545
 
 
546
 
 
547
 
class UnavailableRepresentation(InternalBzrError):
548
 
 
549
 
    _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
550
 
        "is encoded as '%(native)s'.")
551
 
 
552
 
    def __init__(self, key, wanted, native):
553
 
        InternalBzrError.__init__(self)
554
 
        self.wanted = wanted
555
 
        self.native = native
556
 
        self.key = key
557
 
 
558
 
 
559
 
class UnknownHook(BzrError):
560
 
 
561
 
    _fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
562
 
 
563
 
    def __init__(self, hook_type, hook_name):
564
 
        BzrError.__init__(self)
565
 
        self.type = hook_type
566
 
        self.hook = hook_name
567
 
 
568
 
 
569
380
class UnsupportedProtocol(PathError):
570
381
 
571
382
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
574
385
        PathError.__init__(self, url, extra=extra)
575
386
 
576
387
 
577
 
class UnstackableBranchFormat(BzrError):
578
 
 
579
 
    _fmt = ("The branch '%(url)s'(%(format)s) is not a stackable format. "
580
 
        "You will need to upgrade the branch to permit branch stacking.")
581
 
 
582
 
    def __init__(self, format, url):
583
 
        BzrError.__init__(self)
584
 
        self.format = format
585
 
        self.url = url
586
 
 
587
 
 
588
388
class UnstackableLocationError(BzrError):
589
389
 
590
390
    _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
598
398
class UnstackableRepositoryFormat(BzrError):
599
399
 
600
400
    _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
601
 
        "You will need to upgrade the repository to permit branch stacking.")
 
401
            "You will need to upgrade the repository to permit branch stacking.")
602
402
 
603
403
    def __init__(self, format, url):
604
404
        BzrError.__init__(self)
653
453
 
654
454
    _fmt = 'Not a branch: "%(path)s"%(detail)s.'
655
455
 
656
 
    def __init__(self, path, detail=None, bzrdir=None):
657
 
       import bzrlib.urlutils as urlutils
658
 
       path = urlutils.unescape_for_display(path, 'ascii')
659
 
       if detail is not None:
660
 
           detail = ': ' + detail
661
 
       self.detail = detail
662
 
       self.bzrdir = bzrdir
663
 
       PathError.__init__(self, path=path)
 
456
    def __init__(self, path, detail=None, controldir=None):
 
457
        from . import urlutils
 
458
        path = urlutils.unescape_for_display(path, 'ascii')
 
459
        if detail is not None:
 
460
            detail = ': ' + detail
 
461
        self.detail = detail
 
462
        self.controldir = controldir
 
463
        PathError.__init__(self, path=path)
664
464
 
665
465
    def __repr__(self):
666
466
        return '<%s %r>' % (self.__class__.__name__, self.__dict__)
667
467
 
668
 
    def _format(self):
669
 
        # XXX: Ideally self.detail would be a property, but Exceptions in
670
 
        # Python 2.4 have to be old-style classes so properties don't work.
671
 
        # Instead we override _format.
 
468
    def _get_format_string(self):
 
469
        # GZ 2017-06-08: Not the best place to lazy fill detail in.
672
470
        if self.detail is None:
673
 
            if self.bzrdir is not None:
674
 
                try:
675
 
                    self.bzrdir.open_repository()
676
 
                except NoRepositoryPresent:
677
 
                    self.detail = ''
678
 
                except Exception:
679
 
                    # Just ignore unexpected errors.  Raising arbitrary errors
680
 
                    # during str(err) can provoke strange bugs.  Concretely
681
 
                    # Launchpad's codehosting managed to raise NotBranchError
682
 
                    # here, and then get stuck in an infinite loop/recursion
683
 
                    # trying to str() that error.  All this error really cares
684
 
                    # about that there's no working repository there, and if
685
 
                    # open_repository() fails, there probably isn't.
686
 
                    self.detail = ''
687
 
                else:
688
 
                    self.detail = ': location is a repository'
 
471
            self.detail = self._get_detail()
 
472
        return super(NotBranchError, self)._get_format_string()
 
473
 
 
474
    def _get_detail(self):
 
475
        if self.controldir is not None:
 
476
            try:
 
477
                self.controldir.open_repository()
 
478
            except NoRepositoryPresent:
 
479
                return ''
 
480
            except Exception as e:
 
481
                # Just ignore unexpected errors.  Raising arbitrary errors
 
482
                # during str(err) can provoke strange bugs.  Concretely
 
483
                # Launchpad's codehosting managed to raise NotBranchError
 
484
                # here, and then get stuck in an infinite loop/recursion
 
485
                # trying to str() that error.  All this error really cares
 
486
                # about that there's no working repository there, and if
 
487
                # open_repository() fails, there probably isn't.
 
488
                return ': ' + e.__class__.__name__
689
489
            else:
690
 
                self.detail = ''
691
 
        return PathError._format(self)
 
490
                return ': location is a repository'
 
491
        return ''
692
492
 
693
493
 
694
494
class NoSubmitBranch(PathError):
696
496
    _fmt = 'No submit branch available for branch "%(path)s"'
697
497
 
698
498
    def __init__(self, branch):
699
 
       import bzrlib.urlutils as urlutils
700
 
       self.path = urlutils.unescape_for_display(branch.base, 'ascii')
 
499
        from . import urlutils
 
500
        self.path = urlutils.unescape_for_display(branch.base, 'ascii')
701
501
 
702
502
 
703
503
class AlreadyControlDirError(PathError):
727
527
class BranchExistsWithoutWorkingTree(PathError):
728
528
 
729
529
    _fmt = 'Directory contains a branch, but no working tree \
730
 
(use bzr checkout if you wish to build a working tree): "%(path)s"'
731
 
 
732
 
 
733
 
class AtomicFileAlreadyClosed(PathError):
734
 
 
735
 
    _fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
736
 
            ' "%(path)s"')
737
 
 
738
 
    def __init__(self, path, function):
739
 
        PathError.__init__(self, path=path, extra=None)
740
 
        self.function = function
 
530
(use brz checkout if you wish to build a working tree): "%(path)s"'
741
531
 
742
532
 
743
533
class InaccessibleParent(PathError):
753
543
class NoRepositoryPresent(BzrError):
754
544
 
755
545
    _fmt = 'No repository present: "%(path)s"'
756
 
    def __init__(self, bzrdir):
 
546
 
 
547
    def __init__(self, controldir):
757
548
        BzrError.__init__(self)
758
 
        self.path = bzrdir.transport.clone('..').base
 
549
        self.path = controldir.transport.clone('..').base
759
550
 
760
551
 
761
552
class UnsupportedFormatError(BzrError):
762
553
 
763
 
    _fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
 
554
    _fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
764
555
 
765
556
 
766
557
class UnknownFormatError(BzrError):
774
565
 
775
566
class IncompatibleFormat(BzrError):
776
567
 
777
 
    _fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
 
568
    _fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
778
569
 
779
 
    def __init__(self, format, bzrdir_format):
 
570
    def __init__(self, format, controldir_format):
780
571
        BzrError.__init__(self)
781
572
        self.format = format
782
 
        self.bzrdir = bzrdir_format
 
573
        self.controldir = controldir_format
783
574
 
784
575
 
785
576
class ParseFormatError(BzrError):
803
594
    """
804
595
 
805
596
    _fmt = "%(target)s\n" \
806
 
            "is not compatible with\n" \
807
 
            "%(source)s\n" \
808
 
            "%(details)s"
 
597
        "is not compatible with\n" \
 
598
        "%(source)s\n" \
 
599
        "%(details)s"
809
600
 
810
601
    def __init__(self, source, target, details=None):
811
602
        if details is None:
870
661
    _fmt = "Path(s) are not versioned: %(paths_as_string)s"
871
662
 
872
663
    def __init__(self, paths):
873
 
        from bzrlib.osutils import quotefn
 
664
        from breezy.osutils import quotefn
874
665
        BzrError.__init__(self)
875
666
        self.paths = paths
876
667
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
885
676
 
886
677
    def __init__(self, paths, extra=None):
887
678
        # circular import
888
 
        from bzrlib.osutils import quotefn
 
679
        from breezy.osutils import quotefn
889
680
        BzrError.__init__(self)
890
681
        self.paths = paths
891
682
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
1054
845
class LockCorrupt(LockError):
1055
846
 
1056
847
    _fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
1057
 
            "Use 'bzr break-lock' to clear it")
 
848
            "Use 'brz break-lock' to clear it")
1058
849
 
1059
850
    internal_error = False
1060
851
 
1092
883
        self.lock_token = lock_token
1093
884
 
1094
885
 
1095
 
class PointlessCommit(BzrError):
1096
 
 
1097
 
    _fmt = "No changes to commit"
1098
 
 
1099
 
 
1100
 
class CannotCommitSelectedFileMerge(BzrError):
1101
 
 
1102
 
    _fmt = 'Selected-file commit of merges is not supported yet:'\
1103
 
        ' files %(files_str)s'
1104
 
 
1105
 
    def __init__(self, files):
1106
 
        files_str = ', '.join(files)
1107
 
        BzrError.__init__(self, files=files, files_str=files_str)
1108
 
 
1109
 
 
1110
 
class ExcludesUnsupported(BzrError):
1111
 
 
1112
 
    _fmt = ('Excluding paths during commit is not supported by '
1113
 
            'repository at %(repository)r.')
1114
 
 
1115
 
    def __init__(self, repository):
1116
 
        BzrError.__init__(self, repository=repository)
1117
 
 
1118
 
 
1119
 
class BadCommitMessageEncoding(BzrError):
1120
 
 
1121
 
    _fmt = 'The specified commit message contains characters unsupported by '\
1122
 
        'the current encoding.'
1123
 
 
1124
 
 
1125
886
class UpgradeReadonly(BzrError):
1126
887
 
1127
888
    _fmt = "Upgrade URL cannot work with readonly URLs."
1136
897
        self.format = format
1137
898
 
1138
899
 
1139
 
class StrictCommitFailed(Exception):
1140
 
 
1141
 
    _fmt = "Commit refused because there are unknowns in the tree."
1142
 
 
1143
 
 
1144
900
class NoSuchRevision(InternalBzrError):
1145
901
 
1146
902
    _fmt = "%(branch)s has no revision %(revision)s"
1174
930
        self.revision_id = revision_id
1175
931
 
1176
932
 
1177
 
class InvalidRevisionSpec(BzrError):
1178
 
 
1179
 
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
1180
 
            " %(branch_url)s%(extra)s")
1181
 
 
1182
 
    def __init__(self, spec, branch, extra=None):
1183
 
        BzrError.__init__(self, branch=branch, spec=spec)
1184
 
        self.branch_url = getattr(branch, 'user_url', str(branch))
1185
 
        if extra:
1186
 
            self.extra = '\n' + str(extra)
1187
 
        else:
1188
 
            self.extra = ''
1189
 
 
1190
 
 
1191
933
class AppendRevisionsOnlyViolation(BzrError):
1192
934
 
1193
935
    _fmt = ('Operation denied because it would change the main history,'
1194
 
           ' which is not permitted by the append_revisions_only setting on'
1195
 
           ' branch "%(location)s".')
 
936
            ' which is not permitted by the append_revisions_only setting on'
 
937
            ' branch "%(location)s".')
1196
938
 
1197
939
    def __init__(self, location):
1198
 
       import bzrlib.urlutils as urlutils
1199
 
       location = urlutils.unescape_for_display(location, 'ascii')
1200
 
       BzrError.__init__(self, location=location)
 
940
        import breezy.urlutils as urlutils
 
941
        location = urlutils.unescape_for_display(location, 'ascii')
 
942
        BzrError.__init__(self, location=location)
1201
943
 
1202
944
 
1203
945
class DivergedBranches(BzrError):
1243
985
class NoCommonRoot(BzrError):
1244
986
 
1245
987
    _fmt = ("Revisions are not derived from the same root: "
1246
 
           "%(revision_a)s %(revision_b)s.")
 
988
            "%(revision_a)s %(revision_b)s.")
1247
989
 
1248
990
    def __init__(self, revision_a, revision_b):
1249
991
        BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
1255
997
 
1256
998
    def __init__(self, rev_id, not_ancestor_id):
1257
999
        BzrError.__init__(self, rev_id=rev_id,
1258
 
            not_ancestor_id=not_ancestor_id)
 
1000
                          not_ancestor_id=not_ancestor_id)
1259
1001
 
1260
1002
 
1261
1003
class NoCommits(BranchError):
1269
1011
        BzrError.__init__(self, "Store %s is not listable" % store)
1270
1012
 
1271
1013
 
1272
 
 
1273
1014
class UnlistableBranch(BzrError):
1274
1015
 
1275
1016
    def __init__(self, br):
1321
1062
        self.error = error
1322
1063
 
1323
1064
 
1324
 
class WeaveError(BzrError):
1325
 
 
1326
 
    _fmt = "Error in processing weave: %(msg)s"
1327
 
 
1328
 
    def __init__(self, msg=None):
1329
 
        BzrError.__init__(self)
1330
 
        self.msg = msg
1331
 
 
1332
 
 
1333
 
class WeaveRevisionAlreadyPresent(WeaveError):
1334
 
 
1335
 
    _fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1336
 
 
1337
 
    def __init__(self, revision_id, weave):
1338
 
 
1339
 
        WeaveError.__init__(self)
1340
 
        self.revision_id = revision_id
1341
 
        self.weave = weave
1342
 
 
1343
 
 
1344
 
class WeaveRevisionNotPresent(WeaveError):
1345
 
 
1346
 
    _fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1347
 
 
1348
 
    def __init__(self, revision_id, weave):
1349
 
        WeaveError.__init__(self)
1350
 
        self.revision_id = revision_id
1351
 
        self.weave = weave
1352
 
 
1353
 
 
1354
 
class WeaveFormatError(WeaveError):
1355
 
 
1356
 
    _fmt = "Weave invariant violated: %(what)s"
1357
 
 
1358
 
    def __init__(self, what):
1359
 
        WeaveError.__init__(self)
1360
 
        self.what = what
1361
 
 
1362
 
 
1363
 
class WeaveParentMismatch(WeaveError):
1364
 
 
1365
 
    _fmt = "Parents are mismatched between two revisions. %(msg)s"
1366
 
 
1367
 
 
1368
 
class WeaveInvalidChecksum(WeaveError):
1369
 
 
1370
 
    _fmt = "Text did not match its checksum: %(msg)s"
1371
 
 
1372
 
 
1373
 
class WeaveTextDiffers(WeaveError):
1374
 
 
1375
 
    _fmt = ("Weaves differ on text content. Revision:"
1376
 
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1377
 
 
1378
 
    def __init__(self, revision_id, weave_a, weave_b):
1379
 
        WeaveError.__init__(self)
1380
 
        self.revision_id = revision_id
1381
 
        self.weave_a = weave_a
1382
 
        self.weave_b = weave_b
1383
 
 
1384
 
 
1385
 
class WeaveTextDiffers(WeaveError):
1386
 
 
1387
 
    _fmt = ("Weaves differ on text content. Revision:"
1388
 
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1389
 
 
1390
 
    def __init__(self, revision_id, weave_a, weave_b):
1391
 
        WeaveError.__init__(self)
1392
 
        self.revision_id = revision_id
1393
 
        self.weave_a = weave_a
1394
 
        self.weave_b = weave_b
1395
 
 
1396
 
 
1397
1065
class VersionedFileError(BzrError):
1398
1066
 
1399
1067
    _fmt = "Versioned file error"
1424
1092
    _fmt = "Text did not match its checksum: %(msg)s"
1425
1093
 
1426
1094
 
1427
 
class KnitError(InternalBzrError):
1428
 
 
1429
 
    _fmt = "Knit error"
1430
 
 
1431
 
 
1432
 
class KnitCorrupt(KnitError):
1433
 
 
1434
 
    _fmt = "Knit %(filename)s corrupt: %(how)s"
1435
 
 
1436
 
    def __init__(self, filename, how):
1437
 
        KnitError.__init__(self)
1438
 
        self.filename = filename
1439
 
        self.how = how
1440
 
 
1441
 
 
1442
 
class SHA1KnitCorrupt(KnitCorrupt):
1443
 
 
1444
 
    _fmt = ("Knit %(filename)s corrupt: sha-1 of reconstructed text does not "
1445
 
        "match expected sha-1. key %(key)s expected sha %(expected)s actual "
1446
 
        "sha %(actual)s")
1447
 
 
1448
 
    def __init__(self, filename, actual, expected, key, content):
1449
 
        KnitError.__init__(self)
1450
 
        self.filename = filename
1451
 
        self.actual = actual
1452
 
        self.expected = expected
1453
 
        self.key = key
1454
 
        self.content = content
1455
 
 
1456
 
 
1457
 
class KnitDataStreamIncompatible(KnitError):
1458
 
    # Not raised anymore, as we can convert data streams.  In future we may
1459
 
    # need it again for more exotic cases, so we're keeping it around for now.
1460
 
 
1461
 
    _fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
1462
 
 
1463
 
    def __init__(self, stream_format, target_format):
1464
 
        self.stream_format = stream_format
1465
 
        self.target_format = target_format
1466
 
 
1467
 
 
1468
 
class KnitDataStreamUnknown(KnitError):
1469
 
    # Indicates a data stream we don't know how to handle.
1470
 
 
1471
 
    _fmt = "Cannot parse knit data stream of format \"%(stream_format)s\"."
1472
 
 
1473
 
    def __init__(self, stream_format):
1474
 
        self.stream_format = stream_format
1475
 
 
1476
 
 
1477
 
class KnitHeaderError(KnitError):
1478
 
 
1479
 
    _fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
1480
 
 
1481
 
    def __init__(self, badline, filename):
1482
 
        KnitError.__init__(self)
1483
 
        self.badline = badline
1484
 
        self.filename = filename
1485
 
 
1486
 
class KnitIndexUnknownMethod(KnitError):
1487
 
    """Raised when we don't understand the storage method.
1488
 
 
1489
 
    Currently only 'fulltext' and 'line-delta' are supported.
1490
 
    """
1491
 
 
1492
 
    _fmt = ("Knit index %(filename)s does not have a known method"
1493
 
            " in options: %(options)r")
1494
 
 
1495
 
    def __init__(self, filename, options):
1496
 
        KnitError.__init__(self)
1497
 
        self.filename = filename
1498
 
        self.options = options
1499
 
 
1500
 
 
1501
1095
class RetryWithNewPacks(BzrError):
1502
1096
    """Raised when we realize that the packs on disk have changed.
1503
1097
 
1564
1158
        if orig_error is None:
1565
1159
            orig_error = ''
1566
1160
        if msg is None:
1567
 
            msg =  ''
 
1161
            msg = ''
1568
1162
        self.msg = msg
1569
1163
        self.orig_error = orig_error
1570
1164
        BzrError.__init__(self)
1615
1209
        self.exc_type, self.exc_value, self.exc_tb = exc_info
1616
1210
        self.exc_info = exc_info
1617
1211
        traceback_strings = traceback.format_exception(
1618
 
                self.exc_type, self.exc_value, self.exc_tb)
 
1212
            self.exc_type, self.exc_value, self.exc_tb)
1619
1213
        self.traceback_text = ''.join(traceback_strings)
1620
1214
 
1621
1215
 
1686
1280
        TransportError.__init__(self, msg, orig_error=orig_error)
1687
1281
 
1688
1282
 
1689
 
class CertificateError(TransportError):
1690
 
 
1691
 
    _fmt = "Certificate error: %(error)s"
1692
 
 
1693
 
    def __init__(self, error):
1694
 
        self.error = error
 
1283
class UnexpectedHttpStatus(InvalidHttpResponse):
 
1284
 
 
1285
    _fmt = "Unexpected HTTP status %(code)d for %(path)s: %(extra)s"
 
1286
 
 
1287
    def __init__(self, path, code, extra=None):
 
1288
        self.path = path
 
1289
        self.code = code
 
1290
        self.extra = extra or ''
 
1291
        full_msg = 'status code %d unexpected' % code
 
1292
        if extra is not None:
 
1293
            full_msg += ': ' + extra
 
1294
        InvalidHttpResponse.__init__(
 
1295
            self, path, full_msg)
 
1296
 
 
1297
 
 
1298
class BadHttpRequest(UnexpectedHttpStatus):
 
1299
 
 
1300
    _fmt = "Bad http request for %(path)s: %(reason)s"
 
1301
 
 
1302
    def __init__(self, path, reason):
 
1303
        self.path = path
 
1304
        self.reason = reason
 
1305
        TransportError.__init__(self, reason)
1695
1306
 
1696
1307
 
1697
1308
class InvalidHttpRange(InvalidHttpResponse):
1749
1360
    _fmt = "Working tree has conflicts."
1750
1361
 
1751
1362
 
1752
 
class ConfigContentError(BzrError):
1753
 
 
1754
 
    _fmt = "Config file %(filename)s is not UTF-8 encoded\n"
1755
 
 
1756
 
    def __init__(self, filename):
1757
 
        BzrError.__init__(self)
1758
 
        self.filename = filename
1759
 
 
1760
 
 
1761
 
class ParseConfigError(BzrError):
1762
 
 
1763
 
    _fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
1764
 
 
1765
 
    def __init__(self, errors, filename):
1766
 
        BzrError.__init__(self)
1767
 
        self.filename = filename
1768
 
        self.errors = '\n'.join(e.msg for e in errors)
1769
 
 
1770
 
 
1771
 
class ConfigOptionValueError(BzrError):
1772
 
 
1773
 
    _fmt = ('Bad value "%(value)s" for option "%(name)s".\n'
1774
 
            'See ``bzr help %(name)s``')
1775
 
 
1776
 
    def __init__(self, name, value):
1777
 
        BzrError.__init__(self, name=name, value=value)
1778
 
 
1779
 
 
1780
 
class NoEmailInUsername(BzrError):
1781
 
 
1782
 
    _fmt = "%(username)r does not seem to contain a reasonable email address"
1783
 
 
1784
 
    def __init__(self, username):
1785
 
        BzrError.__init__(self)
1786
 
        self.username = username
1787
 
 
1788
 
 
1789
 
class SigningFailed(BzrError):
1790
 
 
1791
 
    _fmt = 'Failed to GPG sign data with command "%(command_line)s"'
1792
 
 
1793
 
    def __init__(self, command_line):
1794
 
        BzrError.__init__(self, command_line=command_line)
1795
 
 
1796
 
 
1797
 
class SignatureVerificationFailed(BzrError):
1798
 
 
1799
 
    _fmt = 'Failed to verify GPG signature data with error "%(error)s"'
1800
 
 
1801
 
    def __init__(self, error):
1802
 
        BzrError.__init__(self, error=error)
1803
 
 
1804
 
 
1805
1363
class DependencyNotPresent(BzrError):
1806
1364
 
1807
1365
    _fmt = 'Unable to import library "%(library)s": %(error)s'
1810
1368
        BzrError.__init__(self, library=library, error=error)
1811
1369
 
1812
1370
 
1813
 
class GpgmeNotInstalled(DependencyNotPresent):
1814
 
 
1815
 
    _fmt = 'python-gpgme is not installed, it is needed to verify signatures'
1816
 
 
1817
 
    def __init__(self, error):
1818
 
        DependencyNotPresent.__init__(self, 'gpgme', error)
1819
 
 
1820
 
 
1821
1371
class WorkingTreeNotRevision(BzrError):
1822
1372
 
1823
1373
    _fmt = ("The working tree for %(basedir)s has changed since"
1828
1378
        BzrError.__init__(self, basedir=tree.basedir)
1829
1379
 
1830
1380
 
1831
 
class CantReprocessAndShowBase(BzrError):
1832
 
 
1833
 
    _fmt = ("Can't reprocess and show base, because reprocessing obscures "
1834
 
           "the relationship of conflicting lines to the base")
1835
 
 
1836
 
 
1837
1381
class GraphCycleError(BzrError):
1838
1382
 
1839
1383
    _fmt = "Cycle in graph %(graph)r"
1916
1460
        self.file_id = file_id
1917
1461
 
1918
1462
 
1919
 
class DuplicateFileId(BzrError):
1920
 
 
1921
 
    _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1922
 
 
1923
 
    def __init__(self, file_id, entry):
1924
 
        BzrError.__init__(self)
1925
 
        self.file_id = file_id
1926
 
        self.entry = entry
1927
 
 
1928
 
 
1929
1463
class DuplicateKey(BzrError):
1930
1464
 
1931
1465
    _fmt = "Key %(key)s is already present in map"
1939
1473
        self.prefix = prefix
1940
1474
 
1941
1475
 
1942
 
class MalformedTransform(InternalBzrError):
1943
 
 
1944
 
    _fmt = "Tree transform is malformed %(conflicts)r"
1945
 
 
1946
 
 
1947
 
class NoFinalPath(BzrError):
1948
 
 
1949
 
    _fmt = ("No final name for trans_id %(trans_id)r\n"
1950
 
            "file-id: %(file_id)r\n"
1951
 
            "root trans-id: %(root_trans_id)r\n")
1952
 
 
1953
 
    def __init__(self, trans_id, transform):
1954
 
        self.trans_id = trans_id
1955
 
        self.file_id = transform.final_file_id(trans_id)
1956
 
        self.root_trans_id = transform.root
1957
 
 
1958
 
 
1959
1476
class BzrBadParameter(InternalBzrError):
1960
1477
 
1961
1478
    _fmt = "Bad parameter: %(param)r"
1973
1490
    _fmt = "Parameter %(param)s is neither unicode nor utf8."
1974
1491
 
1975
1492
 
1976
 
class ReusingTransform(BzrError):
1977
 
 
1978
 
    _fmt = "Attempt to reuse a transform that has already been applied."
1979
 
 
1980
 
 
1981
 
class CantMoveRoot(BzrError):
1982
 
 
1983
 
    _fmt = "Moving the root directory is not supported at this time"
1984
 
 
1985
 
 
1986
 
class TransformRenameFailed(BzrError):
1987
 
 
1988
 
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
1989
 
 
1990
 
    def __init__(self, from_path, to_path, why, errno):
1991
 
        self.from_path = from_path
1992
 
        self.to_path = to_path
1993
 
        self.why = why
1994
 
        self.errno = errno
1995
 
 
1996
 
 
1997
1493
class BzrMoveFailedError(BzrError):
1998
1494
 
1999
1495
    _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
2000
 
        "%(_has_extra)s%(extra)s")
 
1496
            "%(_has_extra)s%(extra)s")
2001
1497
 
2002
1498
    def __init__(self, from_path='', to_path='', extra=None):
2003
 
        from bzrlib.osutils import splitpath
 
1499
        from breezy.osutils import splitpath
2004
1500
        BzrError.__init__(self)
2005
1501
        if extra:
2006
1502
            self.extra, self._has_extra = extra, ': '
2033
1529
class BzrRenameFailedError(BzrMoveFailedError):
2034
1530
 
2035
1531
    _fmt = ("Could not rename %(from_path)s%(operator)s %(to_path)s"
2036
 
        "%(_has_extra)s%(extra)s")
 
1532
            "%(_has_extra)s%(extra)s")
2037
1533
 
2038
1534
    def __init__(self, from_path, to_path, extra=None):
2039
1535
        BzrMoveFailedError.__init__(self, from_path, to_path, extra)
2075
1571
 
2076
1572
class UninitializableFormat(BzrError):
2077
1573
 
2078
 
    _fmt = "Format %(format)s cannot be initialised by this version of bzr."
 
1574
    _fmt = "Format %(format)s cannot be initialised by this version of brz."
2079
1575
 
2080
1576
    def __init__(self, format):
2081
1577
        BzrError.__init__(self)
2085
1581
class BadConversionTarget(BzrError):
2086
1582
 
2087
1583
    _fmt = "Cannot convert from format %(from_format)s to format %(format)s." \
2088
 
            "    %(problem)s"
 
1584
        "    %(problem)s"
2089
1585
 
2090
1586
    def __init__(self, problem, format, from_format=None):
2091
1587
        BzrError.__init__(self)
2123
1619
    _fmt = "Diff3 is not installed on this machine."
2124
1620
 
2125
1621
 
2126
 
class ExistingContent(BzrError):
2127
 
    # Added in bzrlib 0.92, used by VersionedFile.add_lines.
2128
 
 
2129
 
    _fmt = "The content being inserted is already present."
2130
 
 
2131
 
 
2132
1622
class ExistingLimbo(BzrError):
2133
1623
 
2134
1624
    _fmt = """This tree contains left-over files from a failed operation.
2136
1626
    keep, and delete it when you are done."""
2137
1627
 
2138
1628
    def __init__(self, limbo_dir):
2139
 
       BzrError.__init__(self)
2140
 
       self.limbo_dir = limbo_dir
 
1629
        BzrError.__init__(self)
 
1630
        self.limbo_dir = limbo_dir
2141
1631
 
2142
1632
 
2143
1633
class ExistingPendingDeletion(BzrError):
2147
1637
    wish to keep, and delete it when you are done."""
2148
1638
 
2149
1639
    def __init__(self, pending_deletion):
2150
 
       BzrError.__init__(self, pending_deletion=pending_deletion)
2151
 
 
2152
 
 
2153
 
class ImmortalLimbo(BzrError):
2154
 
 
2155
 
    _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
2156
 
    Please examine %(limbo_dir)s to see if it contains any files you wish to
2157
 
    keep, and delete it when you are done."""
2158
 
 
2159
 
    def __init__(self, limbo_dir):
2160
 
       BzrError.__init__(self)
2161
 
       self.limbo_dir = limbo_dir
 
1640
        BzrError.__init__(self, pending_deletion=pending_deletion)
2162
1641
 
2163
1642
 
2164
1643
class ImmortalPendingDeletion(BzrError):
2165
1644
 
2166
1645
    _fmt = ("Unable to delete transform temporary directory "
2167
 
    "%(pending_deletion)s.  Please examine %(pending_deletion)s to see if it "
2168
 
    "contains any files you wish to keep, and delete it when you are done.")
 
1646
            "%(pending_deletion)s.  Please examine %(pending_deletion)s to see if it "
 
1647
            "contains any files you wish to keep, and delete it when you are done.")
2169
1648
 
2170
1649
    def __init__(self, pending_deletion):
2171
 
       BzrError.__init__(self, pending_deletion=pending_deletion)
 
1650
        BzrError.__init__(self, pending_deletion=pending_deletion)
2172
1651
 
2173
1652
 
2174
1653
class OutOfDateTree(BzrError):
2175
1654
 
2176
 
    _fmt = "Working tree is out of date, please run 'bzr update'.%(more)s"
 
1655
    _fmt = "Working tree is out of date, please run 'brz update'.%(more)s"
2177
1656
 
2178
1657
    def __init__(self, tree, more=None):
2179
1658
        if more is None:
2191
1670
        '"%(revstring)s".'
2192
1671
 
2193
1672
    def __init__(self, public_location, revstring):
2194
 
        import bzrlib.urlutils as urlutils
 
1673
        import breezy.urlutils as urlutils
2195
1674
        public_location = urlutils.unescape_for_display(public_location,
2196
1675
                                                        'ascii')
2197
1676
        BzrError.__init__(self, public_location=public_location,
2208
1687
    _fmt = "Format error in conflict listings"
2209
1688
 
2210
1689
 
2211
 
class CorruptDirstate(BzrError):
2212
 
 
2213
 
    _fmt = ("Inconsistency in dirstate file %(dirstate_path)s.\n"
2214
 
            "Error: %(description)s")
2215
 
 
2216
 
    def __init__(self, dirstate_path, description):
2217
 
        BzrError.__init__(self)
2218
 
        self.dirstate_path = dirstate_path
2219
 
        self.description = description
2220
 
 
2221
 
 
2222
1690
class CorruptRepository(BzrError):
2223
1691
 
2224
1692
    _fmt = ("An error has been detected in the repository %(repo_path)s.\n"
2225
 
            "Please run bzr reconcile on this repository.")
 
1693
            "Please run brz reconcile on this repository.")
2226
1694
 
2227
1695
    def __init__(self, repo):
2228
1696
        BzrError.__init__(self)
2271
1739
class RichRootUpgradeRequired(UpgradeRequired):
2272
1740
 
2273
1741
    _fmt = ("To use this feature you must upgrade your branch at %(path)s to"
2274
 
           " a format which supports rich roots.")
 
1742
            " a format which supports rich roots.")
2275
1743
 
2276
1744
 
2277
1745
class LocalRequiresBoundBranch(BzrError):
2290
1758
        self.tname = type(method_self).__name__
2291
1759
 
2292
1760
 
2293
 
class CannotSetRevisionId(UnsupportedOperation):
2294
 
    """Raised when a commit is attempting to set a revision id but cant."""
 
1761
class FetchLimitUnsupported(UnsupportedOperation):
 
1762
 
 
1763
    fmt = ("InterBranch %(interbranch)r does not support fetching limits.")
 
1764
 
 
1765
    def __init__(self, interbranch):
 
1766
        BzrError.__init__(self, interbranch=interbranch)
2295
1767
 
2296
1768
 
2297
1769
class NonAsciiRevisionId(UnsupportedOperation):
2300
1772
    """
2301
1773
 
2302
1774
 
 
1775
class SharedRepositoriesUnsupported(UnsupportedOperation):
 
1776
    _fmt = "Shared repositories are not supported by %(format)r."
 
1777
 
 
1778
    def __init__(self, format):
 
1779
        BzrError.__init__(self, format=format)
 
1780
 
 
1781
 
2303
1782
class GhostTagsNotSupported(BzrError):
2304
1783
 
2305
1784
    _fmt = "Ghost tags not supported by format %(format)r."
2387
1866
        self.other = other
2388
1867
 
2389
1868
 
2390
 
class BadInventoryFormat(BzrError):
2391
 
 
2392
 
    _fmt = "Root class for inventory serialization errors"
2393
 
 
2394
 
 
2395
 
class UnexpectedInventoryFormat(BadInventoryFormat):
2396
 
 
2397
 
    _fmt = "The inventory was not in the expected format:\n %(msg)s"
2398
 
 
2399
 
    def __init__(self, msg):
2400
 
        BadInventoryFormat.__init__(self, msg=msg)
2401
 
 
2402
 
 
2403
1869
class RootNotRich(BzrError):
2404
1870
 
2405
1871
    _fmt = """This operation requires rich root data storage"""
2415
1881
 
2416
1882
class UnknownSSH(BzrError):
2417
1883
 
2418
 
    _fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
 
1884
    _fmt = "Unrecognised value for BRZ_SSH environment variable: %(vendor)s"
2419
1885
 
2420
1886
    def __init__(self, vendor):
2421
1887
        BzrError.__init__(self)
2425
1891
class SSHVendorNotFound(BzrError):
2426
1892
 
2427
1893
    _fmt = ("Don't know how to handle SSH connections."
2428
 
            " Please set BZR_SSH environment variable.")
 
1894
            " Please set BRZ_SSH environment variable.")
2429
1895
 
2430
1896
 
2431
1897
class GhostRevisionsHaveNoRevno(BzrError):
2448
1914
        self.revision_id = revision_id
2449
1915
 
2450
1916
 
2451
 
class IllegalUseOfScopeReplacer(InternalBzrError):
2452
 
 
2453
 
    _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2454
 
            " %(msg)s%(extra)s")
2455
 
 
2456
 
    def __init__(self, name, msg, extra=None):
2457
 
        BzrError.__init__(self)
2458
 
        self.name = name
2459
 
        self.msg = msg
2460
 
        if extra:
2461
 
            self.extra = ': ' + str(extra)
2462
 
        else:
2463
 
            self.extra = ''
2464
 
 
2465
 
 
2466
 
class InvalidImportLine(InternalBzrError):
2467
 
 
2468
 
    _fmt = "Not a valid import statement: %(msg)\n%(text)s"
2469
 
 
2470
 
    def __init__(self, text, msg):
2471
 
        BzrError.__init__(self)
2472
 
        self.text = text
2473
 
        self.msg = msg
2474
 
 
2475
 
 
2476
 
class ImportNameCollision(InternalBzrError):
2477
 
 
2478
 
    _fmt = ("Tried to import an object to the same name as"
2479
 
            " an existing object. %(name)s")
2480
 
 
2481
 
    def __init__(self, name):
2482
 
        BzrError.__init__(self)
2483
 
        self.name = name
2484
 
 
2485
 
 
2486
1917
class NotAMergeDirective(BzrError):
2487
1918
    """File starting with %(firstline)r is not a merge directive"""
 
1919
 
2488
1920
    def __init__(self, firstline):
2489
1921
        BzrError.__init__(self, firstline=firstline)
2490
1922
 
2496
1928
        " branch location."
2497
1929
 
2498
1930
 
2499
 
class IllegalMergeDirectivePayload(BzrError):
2500
 
    """A merge directive contained something other than a patch or bundle"""
2501
 
 
2502
 
    _fmt = "Bad merge directive payload %(start)r"
2503
 
 
2504
 
    def __init__(self, start):
2505
 
        BzrError(self)
2506
 
        self.start = start
2507
 
 
2508
 
 
2509
1931
class PatchVerificationFailed(BzrError):
2510
1932
    """A patch from a merge directive could not be verified"""
2511
1933
 
2535
1957
        self.location = location
2536
1958
 
2537
1959
 
2538
 
class UnsupportedInventoryKind(BzrError):
2539
 
 
2540
 
    _fmt = """Unsupported entry kind %(kind)s"""
2541
 
 
2542
 
    def __init__(self, kind):
2543
 
        self.kind = kind
2544
 
 
2545
 
 
2546
1960
class BadSubsumeSource(BzrError):
2547
1961
 
2548
1962
    _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2561
1975
        self.other_tree = other_tree
2562
1976
 
2563
1977
 
2564
 
class BadReferenceTarget(InternalBzrError):
2565
 
 
2566
 
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2567
 
           "%(reason)s"
2568
 
 
2569
 
    def __init__(self, tree, other_tree, reason):
2570
 
        self.tree = tree
2571
 
        self.other_tree = other_tree
2572
 
        self.reason = reason
2573
 
 
2574
 
 
2575
1978
class NoSuchTag(BzrError):
2576
1979
 
2577
1980
    _fmt = "No such tag: %(tag_name)s"
2583
1986
class TagsNotSupported(BzrError):
2584
1987
 
2585
1988
    _fmt = ("Tags not supported by %(branch)s;"
2586
 
            " you may be able to use bzr upgrade.")
 
1989
            " you may be able to use 'brz upgrade %(branch_url)s'.")
2587
1990
 
2588
1991
    def __init__(self, branch):
2589
1992
        self.branch = branch
 
1993
        self.branch_url = branch.user_url
2590
1994
 
2591
1995
 
2592
1996
class TagAlreadyExists(BzrError):
2597
2001
        self.tag_name = tag_name
2598
2002
 
2599
2003
 
2600
 
class MalformedBugIdentifier(BzrError):
2601
 
 
2602
 
    _fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2603
 
            'See "bzr help bugs" for more information on this feature.')
2604
 
 
2605
 
    def __init__(self, bug_id, reason):
2606
 
        self.bug_id = bug_id
2607
 
        self.reason = reason
2608
 
 
2609
 
 
2610
 
class InvalidBugTrackerURL(BzrError):
2611
 
 
2612
 
    _fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2613
 
            "contain {id}: %(url)s")
2614
 
 
2615
 
    def __init__(self, abbreviation, url):
2616
 
        self.abbreviation = abbreviation
2617
 
        self.url = url
2618
 
 
2619
 
 
2620
 
class UnknownBugTrackerAbbreviation(BzrError):
2621
 
 
2622
 
    _fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2623
 
            "on %(branch)s")
2624
 
 
2625
 
    def __init__(self, abbreviation, branch):
2626
 
        self.abbreviation = abbreviation
2627
 
        self.branch = branch
2628
 
 
2629
 
 
2630
 
class InvalidLineInBugsProperty(BzrError):
2631
 
 
2632
 
    _fmt = ("Invalid line in bugs property: '%(line)s'")
2633
 
 
2634
 
    def __init__(self, line):
2635
 
        self.line = line
2636
 
 
2637
 
 
2638
 
class InvalidBugStatus(BzrError):
2639
 
 
2640
 
    _fmt = ("Invalid bug status: '%(status)s'")
2641
 
 
2642
 
    def __init__(self, status):
2643
 
        self.status = status
2644
 
 
2645
 
 
2646
2004
class UnexpectedSmartServerResponse(BzrError):
2647
2005
 
2648
2006
    _fmt = "Could not understand response from smart server: %(response_tuple)r"
2671
2029
 
2672
2030
 
2673
2031
class UnknownErrorFromSmartServer(BzrError):
2674
 
    """An ErrorFromSmartServer could not be translated into a typical bzrlib
 
2032
    """An ErrorFromSmartServer could not be translated into a typical breezy
2675
2033
    error.
2676
2034
 
2677
2035
    This is distinct from ErrorFromSmartServer so that it is possible to
2746
2104
        self.name = name.decode("utf-8")
2747
2105
 
2748
2106
 
2749
 
class NoDestinationAddress(InternalBzrError):
2750
 
 
2751
 
    _fmt = "Message does not have a destination address."
2752
 
 
2753
 
 
2754
2107
class RepositoryDataStreamError(BzrError):
2755
2108
 
2756
2109
    _fmt = "Corrupt or incompatible data stream: %(reason)s"
2759
2112
        self.reason = reason
2760
2113
 
2761
2114
 
2762
 
class SMTPError(BzrError):
2763
 
 
2764
 
    _fmt = "SMTP error: %(error)s"
2765
 
 
2766
 
    def __init__(self, error):
2767
 
        self.error = error
2768
 
 
2769
 
 
2770
 
class NoMessageSupplied(BzrError):
2771
 
 
2772
 
    _fmt = "No message supplied."
2773
 
 
2774
 
 
2775
 
class NoMailAddressSpecified(BzrError):
2776
 
 
2777
 
    _fmt = "No mail-to address (--mail-to) or output (-o) specified."
2778
 
 
2779
 
 
2780
 
class MailClientNotFound(BzrError):
2781
 
 
2782
 
    _fmt = "Unable to find mail client with the following names:"\
2783
 
        " %(mail_command_list_string)s"
2784
 
 
2785
 
    def __init__(self, mail_command_list):
2786
 
        mail_command_list_string = ', '.join(mail_command_list)
2787
 
        BzrError.__init__(self, mail_command_list=mail_command_list,
2788
 
                          mail_command_list_string=mail_command_list_string)
2789
 
 
2790
 
class SMTPConnectionRefused(SMTPError):
2791
 
 
2792
 
    _fmt = "SMTP connection to %(host)s refused"
2793
 
 
2794
 
    def __init__(self, error, host):
2795
 
        self.error = error
2796
 
        self.host = host
2797
 
 
2798
 
 
2799
 
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2800
 
 
2801
 
    _fmt = "Please specify smtp_server.  No server at default %(host)s."
2802
 
 
2803
 
 
2804
 
class BzrDirError(BzrError):
2805
 
 
2806
 
    def __init__(self, bzrdir):
2807
 
        import bzrlib.urlutils as urlutils
2808
 
        display_url = urlutils.unescape_for_display(bzrdir.user_url,
2809
 
                                                    'ascii')
2810
 
        BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2811
 
 
2812
 
 
2813
 
class UnsyncedBranches(BzrDirError):
2814
 
 
2815
 
    _fmt = ("'%(display_url)s' is not in sync with %(target_url)s.  See"
2816
 
            " bzr help sync-for-reconfigure.")
2817
 
 
2818
 
    def __init__(self, bzrdir, target_branch):
2819
 
        BzrDirError.__init__(self, bzrdir)
2820
 
        import bzrlib.urlutils as urlutils
2821
 
        self.target_url = urlutils.unescape_for_display(target_branch.base,
2822
 
                                                        'ascii')
2823
 
 
2824
 
 
2825
 
class AlreadyBranch(BzrDirError):
2826
 
 
2827
 
    _fmt = "'%(display_url)s' is already a branch."
2828
 
 
2829
 
 
2830
 
class AlreadyTree(BzrDirError):
2831
 
 
2832
 
    _fmt = "'%(display_url)s' is already a tree."
2833
 
 
2834
 
 
2835
 
class AlreadyCheckout(BzrDirError):
2836
 
 
2837
 
    _fmt = "'%(display_url)s' is already a checkout."
2838
 
 
2839
 
 
2840
 
class AlreadyLightweightCheckout(BzrDirError):
2841
 
 
2842
 
    _fmt = "'%(display_url)s' is already a lightweight checkout."
2843
 
 
2844
 
 
2845
 
class AlreadyUsingShared(BzrDirError):
2846
 
 
2847
 
    _fmt = "'%(display_url)s' is already using a shared repository."
2848
 
 
2849
 
 
2850
 
class AlreadyStandalone(BzrDirError):
2851
 
 
2852
 
    _fmt = "'%(display_url)s' is already standalone."
2853
 
 
2854
 
 
2855
 
class AlreadyWithTrees(BzrDirError):
2856
 
 
2857
 
    _fmt = ("Shared repository '%(display_url)s' already creates "
2858
 
            "working trees.")
2859
 
 
2860
 
 
2861
 
class AlreadyWithNoTrees(BzrDirError):
2862
 
 
2863
 
    _fmt = ("Shared repository '%(display_url)s' already doesn't create "
2864
 
            "working trees.")
2865
 
 
2866
 
 
2867
 
class ReconfigurationNotSupported(BzrDirError):
2868
 
 
2869
 
    _fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2870
 
 
2871
 
 
2872
 
class NoBindLocation(BzrDirError):
2873
 
 
2874
 
    _fmt = "No location could be found to bind to at %(display_url)s."
2875
 
 
2876
 
 
2877
2115
class UncommittedChanges(BzrError):
2878
2116
 
2879
2117
    _fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2880
 
            ' (See bzr status).%(more)s')
 
2118
            ' (See brz status).%(more)s')
2881
2119
 
2882
2120
    def __init__(self, tree, more=None):
2883
2121
        if more is None:
2884
2122
            more = ''
2885
2123
        else:
2886
2124
            more = ' ' + more
2887
 
        import bzrlib.urlutils as urlutils
 
2125
        import breezy.urlutils as urlutils
2888
2126
        user_url = getattr(tree, "user_url", None)
2889
2127
        if user_url is None:
2890
2128
            display_url = str(tree)
2899
2137
            ' changes.')
2900
2138
 
2901
2139
    def __init__(self, branch):
2902
 
        import bzrlib.urlutils as urlutils
 
2140
        import breezy.urlutils as urlutils
2903
2141
        user_url = getattr(branch, "user_url", None)
2904
2142
        if user_url is None:
2905
2143
            display_url = str(branch)
2911
2149
class ShelvedChanges(UncommittedChanges):
2912
2150
 
2913
2151
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
2914
 
            ' (See bzr shelve --list).%(more)s')
2915
 
 
2916
 
 
2917
 
class MissingTemplateVariable(BzrError):
2918
 
 
2919
 
    _fmt = 'Variable {%(name)s} is not available.'
2920
 
 
2921
 
    def __init__(self, name):
2922
 
        self.name = name
2923
 
 
2924
 
 
2925
 
class NoTemplate(BzrError):
2926
 
 
2927
 
    _fmt = 'No template specified.'
2928
 
 
2929
 
 
2930
 
class UnableCreateSymlink(BzrError):
2931
 
 
2932
 
    _fmt = 'Unable to create symlink %(path_str)son this platform'
2933
 
 
2934
 
    def __init__(self, path=None):
2935
 
        path_str = ''
2936
 
        if path:
2937
 
            try:
2938
 
                path_str = repr(str(path))
2939
 
            except UnicodeEncodeError:
2940
 
                path_str = repr(path)
2941
 
            path_str += ' '
2942
 
        self.path_str = path_str
2943
 
 
2944
 
 
2945
 
class UnsupportedTimezoneFormat(BzrError):
2946
 
 
2947
 
    _fmt = ('Unsupported timezone format "%(timezone)s", '
2948
 
            'options are "utc", "original", "local".')
2949
 
 
2950
 
    def __init__(self, timezone):
2951
 
        self.timezone = timezone
2952
 
 
2953
 
 
2954
 
class CommandAvailableInPlugin(StandardError):
2955
 
 
2956
 
    internal_error = False
2957
 
 
2958
 
    def __init__(self, cmd_name, plugin_metadata, provider):
2959
 
 
2960
 
        self.plugin_metadata = plugin_metadata
2961
 
        self.cmd_name = cmd_name
2962
 
        self.provider = provider
2963
 
 
2964
 
    def __str__(self):
2965
 
 
2966
 
        _fmt = ('"%s" is not a standard bzr command. \n'
2967
 
                'However, the following official plugin provides this command: %s\n'
2968
 
                'You can install it by going to: %s'
2969
 
                % (self.cmd_name, self.plugin_metadata['name'],
2970
 
                    self.plugin_metadata['url']))
2971
 
 
2972
 
        return _fmt
2973
 
 
2974
 
 
2975
 
class NoPluginAvailable(BzrError):
2976
 
    pass
 
2152
            ' (See brz shelve --list).%(more)s')
2977
2153
 
2978
2154
 
2979
2155
class UnableEncodePath(BzrError):
2982
2158
            'user encoding %(user_encoding)s')
2983
2159
 
2984
2160
    def __init__(self, path, kind):
2985
 
        from bzrlib.osutils import get_user_encoding
 
2161
        from breezy.osutils import get_user_encoding
2986
2162
        self.path = path
2987
2163
        self.kind = kind
2988
2164
        self.user_encoding = get_user_encoding()
2989
2165
 
2990
2166
 
2991
 
class NoSuchConfig(BzrError):
2992
 
 
2993
 
    _fmt = ('The "%(config_id)s" configuration does not exist.')
2994
 
 
2995
 
    def __init__(self, config_id):
2996
 
        BzrError.__init__(self, config_id=config_id)
2997
 
 
2998
 
 
2999
 
class NoSuchConfigOption(BzrError):
3000
 
 
3001
 
    _fmt = ('The "%(option_name)s" configuration option does not exist.')
3002
 
 
3003
 
    def __init__(self, option_name):
3004
 
        BzrError.__init__(self, option_name=option_name)
3005
 
 
3006
 
 
3007
2167
class NoSuchAlias(BzrError):
3008
2168
 
3009
2169
    _fmt = ('The alias "%(alias_name)s" does not exist.')
3012
2172
        BzrError.__init__(self, alias_name=alias_name)
3013
2173
 
3014
2174
 
3015
 
class DirectoryLookupFailure(BzrError):
3016
 
    """Base type for lookup errors."""
3017
 
 
3018
 
    pass
3019
 
 
3020
 
 
3021
 
class InvalidLocationAlias(DirectoryLookupFailure):
3022
 
 
3023
 
    _fmt = '"%(alias_name)s" is not a valid location alias.'
3024
 
 
3025
 
    def __init__(self, alias_name):
3026
 
        DirectoryLookupFailure.__init__(self, alias_name=alias_name)
3027
 
 
3028
 
 
3029
 
class UnsetLocationAlias(DirectoryLookupFailure):
3030
 
 
3031
 
    _fmt = 'No %(alias_name)s location assigned.'
3032
 
 
3033
 
    def __init__(self, alias_name):
3034
 
        DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
3035
 
 
3036
 
 
3037
2175
class CannotBindAddress(BzrError):
3038
2176
 
3039
2177
    _fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
3041
2179
    def __init__(self, host, port, orig_error):
3042
2180
        # nb: in python2.4 socket.error doesn't have a useful repr
3043
2181
        BzrError.__init__(self, host=host, port=port,
3044
 
            orig_error=repr(orig_error.args))
3045
 
 
3046
 
 
3047
 
class UnknownRules(BzrError):
3048
 
 
3049
 
    _fmt = ('Unknown rules detected: %(unknowns_str)s.')
3050
 
 
3051
 
    def __init__(self, unknowns):
3052
 
        BzrError.__init__(self, unknowns_str=", ".join(unknowns))
 
2182
                          orig_error=repr(orig_error.args))
3053
2183
 
3054
2184
 
3055
2185
class TipChangeRejected(BzrError):
3063
2193
        self.msg = msg
3064
2194
 
3065
2195
 
3066
 
class ShelfCorrupt(BzrError):
3067
 
 
3068
 
    _fmt = "Shelf corrupt."
3069
 
 
3070
 
 
3071
 
class DecompressCorruption(BzrError):
3072
 
 
3073
 
    _fmt = "Corruption while decompressing repository file%(orig_error)s"
3074
 
 
3075
 
    def __init__(self, orig_error=None):
3076
 
        if orig_error is not None:
3077
 
            self.orig_error = ", %s" % (orig_error,)
3078
 
        else:
3079
 
            self.orig_error = ""
3080
 
        BzrError.__init__(self)
3081
 
 
3082
 
 
3083
 
class NoSuchShelfId(BzrError):
3084
 
 
3085
 
    _fmt = 'No changes are shelved with id "%(shelf_id)d".'
3086
 
 
3087
 
    def __init__(self, shelf_id):
3088
 
        BzrError.__init__(self, shelf_id=shelf_id)
3089
 
 
3090
 
 
3091
 
class InvalidShelfId(BzrError):
3092
 
 
3093
 
    _fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3094
 
 
3095
 
    def __init__(self, invalid_id):
3096
 
        BzrError.__init__(self, invalid_id=invalid_id)
3097
 
 
3098
 
 
3099
2196
class JailBreak(BzrError):
3100
2197
 
3101
2198
    _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
3109
2206
    _fmt = 'The user aborted the operation.'
3110
2207
 
3111
2208
 
3112
 
class MustHaveWorkingTree(BzrError):
3113
 
 
3114
 
    _fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3115
 
 
3116
 
    def __init__(self, format, url):
3117
 
        BzrError.__init__(self, format=format, url=url)
3118
 
 
3119
 
 
3120
 
class NoSuchView(BzrError):
3121
 
    """A view does not exist.
3122
 
    """
3123
 
 
3124
 
    _fmt = u"No such view: %(view_name)s."
3125
 
 
3126
 
    def __init__(self, view_name):
3127
 
        self.view_name = view_name
3128
 
 
3129
 
 
3130
 
class ViewsNotSupported(BzrError):
3131
 
    """Views are not supported by a tree format.
3132
 
    """
3133
 
 
3134
 
    _fmt = ("Views are not supported by %(tree)s;"
3135
 
            " use 'bzr upgrade' to change your tree to a later format.")
3136
 
 
3137
 
    def __init__(self, tree):
3138
 
        self.tree = tree
3139
 
 
3140
 
 
3141
 
class FileOutsideView(BzrError):
3142
 
 
3143
 
    _fmt = ('Specified file "%(file_name)s" is outside the current view: '
3144
 
            '%(view_str)s')
3145
 
 
3146
 
    def __init__(self, file_name, view_files):
3147
 
        self.file_name = file_name
3148
 
        self.view_str = ", ".join(view_files)
3149
 
 
3150
 
 
3151
2209
class UnresumableWriteGroup(BzrError):
3152
2210
 
3153
2211
    _fmt = ("Repository %(repository)s cannot resume write group "
3195
2253
        self.target_branch = target_branch
3196
2254
 
3197
2255
 
3198
 
class FileTimestampUnavailable(BzrError):
3199
 
 
3200
 
    _fmt = "The filestamp for %(path)s is not available."
3201
 
 
3202
 
    internal_error = True
3203
 
 
3204
 
    def __init__(self, path):
3205
 
        self.path = path
3206
 
 
3207
 
 
3208
2256
class NoColocatedBranchSupport(BzrError):
3209
2257
 
3210
 
    _fmt = ("%(bzrdir)r does not support co-located branches.")
3211
 
 
3212
 
    def __init__(self, bzrdir):
3213
 
        self.bzrdir = bzrdir
3214
 
 
3215
 
 
3216
 
class NoWhoami(BzrError):
3217
 
 
3218
 
    _fmt = ('Unable to determine your name.\n'
3219
 
        "Please, set your name with the 'whoami' command.\n"
3220
 
        'E.g. bzr whoami "Your Name <name@example.com>"')
3221
 
 
3222
 
 
3223
 
class InvalidPattern(BzrError):
3224
 
 
3225
 
    _fmt = ('Invalid pattern(s) found. %(msg)s')
3226
 
 
3227
 
    def __init__(self, msg):
3228
 
        self.msg = msg
 
2258
    _fmt = ("%(controldir)r does not support co-located branches.")
 
2259
 
 
2260
    def __init__(self, controldir):
 
2261
        self.controldir = controldir
3229
2262
 
3230
2263
 
3231
2264
class RecursiveBind(BzrError):
3232
2265
 
3233
2266
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3234
 
        'Please use `bzr unbind` to fix.')
 
2267
            'Please use `brz unbind` to fix.')
3235
2268
 
3236
2269
    def __init__(self, branch_url):
3237
2270
        self.branch_url = branch_url
3238
2271
 
3239
2272
 
3240
 
# FIXME: I would prefer to define the config related exception classes in
3241
 
# config.py but the lazy import mechanism proscribes this -- vila 20101222
3242
 
class OptionExpansionLoop(BzrError):
3243
 
 
3244
 
    _fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
3245
 
 
3246
 
    def __init__(self, string, refs):
3247
 
        self.string = string
3248
 
        self.refs = '->'.join(refs)
3249
 
 
3250
 
 
3251
 
class ExpandingUnknownOption(BzrError):
3252
 
 
3253
 
    _fmt = 'Option "%(name)s" is not defined while expanding "%(string)s".'
3254
 
 
3255
 
    def __init__(self, name, string):
3256
 
        self.name = name
3257
 
        self.string = string
3258
 
 
3259
 
 
3260
 
class IllegalOptionName(BzrError):
3261
 
 
3262
 
    _fmt = 'Option "%(name)s" is not allowed.'
3263
 
 
3264
 
    def __init__(self, name):
3265
 
        self.name = name
3266
 
 
3267
 
 
3268
 
class NoCompatibleInter(BzrError):
3269
 
 
3270
 
    _fmt = ('No compatible object available for operations from %(source)r '
3271
 
            'to %(target)r.')
3272
 
 
3273
 
    def __init__(self, source, target):
3274
 
        self.source = source
3275
 
        self.target = target
3276
 
 
3277
 
 
3278
 
class HpssVfsRequestNotAllowed(BzrError):
3279
 
 
3280
 
    _fmt = ("VFS requests over the smart server are not allowed. Encountered: "
3281
 
            "%(method)s, %(arguments)s.")
3282
 
 
3283
 
    def __init__(self, method, arguments):
3284
 
        self.method = method
3285
 
        self.arguments = arguments
3286
 
 
3287
 
 
3288
2273
class UnsupportedKindChange(BzrError):
3289
2274
 
3290
2275
    _fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
3297
2282
        self.format = format
3298
2283
 
3299
2284
 
3300
 
class MissingFeature(BzrError):
3301
 
 
3302
 
    _fmt = ("Missing feature %(feature)s not provided by this "
3303
 
            "version of Bazaar or any plugin.")
3304
 
 
3305
 
    def __init__(self, feature):
3306
 
        self.feature = feature
3307
 
 
3308
 
 
3309
 
class PatchSyntax(BzrError):
3310
 
    """Base class for patch syntax errors."""
3311
 
 
3312
 
 
3313
 
class BinaryFiles(BzrError):
3314
 
 
3315
 
    _fmt = 'Binary files section encountered.'
3316
 
 
3317
 
    def __init__(self, orig_name, mod_name):
3318
 
        self.orig_name = orig_name
3319
 
        self.mod_name = mod_name
3320
 
 
3321
 
 
3322
 
class MalformedPatchHeader(PatchSyntax):
3323
 
 
3324
 
    _fmt = "Malformed patch header.  %(desc)s\n%(line)r"
3325
 
 
3326
 
    def __init__(self, desc, line):
3327
 
        self.desc = desc
3328
 
        self.line = line
3329
 
 
3330
 
 
3331
 
class MalformedHunkHeader(PatchSyntax):
3332
 
 
3333
 
    _fmt = "Malformed hunk header.  %(desc)s\n%(line)r"
3334
 
 
3335
 
    def __init__(self, desc, line):
3336
 
        self.desc = desc
3337
 
        self.line = line
3338
 
 
3339
 
 
3340
 
class MalformedLine(PatchSyntax):
3341
 
 
3342
 
    _fmt = "Malformed line.  %(desc)s\n%(line)r"
3343
 
 
3344
 
    def __init__(self, desc, line):
3345
 
        self.desc = desc
3346
 
        self.line = line
3347
 
 
3348
 
 
3349
 
class PatchConflict(BzrError):
3350
 
 
3351
 
    _fmt = ('Text contents mismatch at line %(line_no)d.  Original has '
3352
 
            '"%(orig_line)s", but patch says it should be "%(patch_line)s"')
3353
 
 
3354
 
    def __init__(self, line_no, orig_line, patch_line):
3355
 
        self.line_no = line_no
3356
 
        self.orig_line = orig_line.rstrip('\n')
3357
 
        self.patch_line = patch_line.rstrip('\n')
3358
 
 
3359
 
 
3360
 
class FeatureAlreadyRegistered(BzrError):
3361
 
 
3362
 
    _fmt = 'The feature %(feature)s has already been registered.'
3363
 
 
3364
 
    def __init__(self, feature):
3365
 
        self.feature = feature
3366
 
 
3367
 
 
3368
 
class ChangesAlreadyStored(BzrCommandError):
 
2285
class ChangesAlreadyStored(CommandError):
3369
2286
 
3370
2287
    _fmt = ('Cannot store uncommitted changes because this branch already'
3371
2288
            ' stores uncommitted changes.')
 
2289
 
 
2290
 
 
2291
class RevnoOutOfBounds(InternalBzrError):
 
2292
 
 
2293
    _fmt = ("The requested revision number %(revno)d is outside of the "
 
2294
            "expected boundaries (%(minimum)d <= %(maximum)d).")
 
2295
 
 
2296
    def __init__(self, revno, bounds):
 
2297
        InternalBzrError.__init__(
 
2298
            self, revno=revno, minimum=bounds[0], maximum=bounds[1])