34
# return codes from the brz program
49
# return codes from the bzr program
37
52
EXIT_INTERNAL_ERROR = 4
40
class BzrError(Exception):
55
class BzrError(StandardError):
42
Base class for errors raised by breezy.
57
Base class for errors raised by bzrlib.
44
:cvar internal_error: if True this was probably caused by a brz bug and
59
:cvar internal_error: if True this was probably caused by a bzr bug and
45
60
should be displayed with a traceback; if False (or absent) this was
46
61
probably a user or environment error and they don't need the gory
47
62
details. (That can be overridden by -Derror on the command line.)
95
109
# __str__() should always return a 'str' object
96
110
# never a 'unicode' object.
98
except Exception as e:
100
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
112
except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
113
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
114
% (self.__class__.__name__,
116
getattr(self, '_fmt', None),
119
def __unicode__(self):
121
if isinstance(u, str):
122
# Try decoding the str using the default encoding.
124
elif not isinstance(u, unicode):
125
# Try to make a unicode object from it, because __unicode__ must
126
# return a unicode object.
132
if isinstance(s, unicode):
135
# __str__ must return a str.
140
return '%s(%s)' % (self.__class__.__name__, str(self))
142
def _get_format_string(self):
143
"""Return format string for this exception or None"""
144
fmt = getattr(self, '_fmt', None)
147
unicode_fmt = unicode(fmt) #_fmt strings should be ascii
148
if type(fmt) == unicode:
149
trace.mutter("Unicode strings in error.fmt are deprecated")
150
return gettext(unicode_fmt)
151
fmt = getattr(self, '__doc__', None)
153
symbol_versioning.warn("%s uses its docstring as a format, "
154
"it should use _fmt instead" % self.__class__.__name__,
157
return 'Unprintable exception %s: dict=%r, fmt=%r' \
101
158
% (self.__class__.__name__,
103
160
getattr(self, '_fmt', None),
109
return '%s(%s)' % (self.__class__.__name__, str(self))
111
def _get_format_string(self):
112
"""Return format string for this exception or None"""
113
fmt = getattr(self, '_fmt', None)
115
from breezy.i18n import gettext
116
return gettext(fmt) # _fmt strings should be ascii
118
163
def __eq__(self, other):
119
164
if self.__class__ is not other.__class__:
120
165
return NotImplemented
121
166
return self.__dict__ == other.__dict__
127
169
class InternalBzrError(BzrError):
128
170
"""Base class for errors that are internal in nature.
135
177
internal_error = True
180
class BzrNewError(BzrError):
181
"""Deprecated error base class."""
182
# base classes should override the docstring with their human-
183
# readable explanation
185
def __init__(self, *args, **kwds):
186
# XXX: Use the underlying BzrError to always generate the args
187
# attribute if it doesn't exist. We can't use super here, because
188
# exceptions are old-style classes in python2.4 (but new in 2.5).
190
symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
191
'please convert %s to use BzrError instead'
192
% self.__class__.__name__,
195
BzrError.__init__(self, *args)
196
for key, value in kwds.items():
197
setattr(self, key, value)
201
# __str__() should always return a 'str' object
202
# never a 'unicode' object.
203
s = self.__doc__ % self.__dict__
204
if isinstance(s, unicode):
205
return s.encode('utf8')
207
except (TypeError, NameError, ValueError, KeyError), e:
208
return 'Unprintable exception %s(%r): %r' \
209
% (self.__class__.__name__,
213
class AlreadyBuilding(BzrError):
215
_fmt = "The tree builder is already building a tree."
138
218
class BranchError(BzrError):
139
219
"""Base class for concrete 'errors about a branch'."""
154
class IncompatibleVersion(BzrError):
156
_fmt = 'API %(api)s is not compatible; one of versions %(wanted)r '\
157
'is required, but current version is %(current)r.'
159
def __init__(self, api, wanted, current):
234
class DirstateCorrupt(BzrError):
236
_fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s"
238
def __init__(self, state, msg):
239
BzrError.__init__(self)
244
class DisabledMethod(InternalBzrError):
246
_fmt = "The smart server method '%(class_name)s' is disabled."
248
def __init__(self, class_name):
249
BzrError.__init__(self)
250
self.class_name = class_name
253
class IncompatibleAPI(BzrError):
255
_fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
256
'It supports versions "%(minimum)s" to "%(current)s".'
258
def __init__(self, api, wanted, minimum, current):
161
260
self.wanted = wanted
261
self.minimum = minimum
162
262
self.current = current
210
319
_fmt = 'There is no public branch set for "%(branch_url)s".'
212
321
def __init__(self, branch):
213
from . import urlutils
322
import bzrlib.urlutils as urlutils
214
323
public_location = urlutils.unescape_for_display(branch.base, 'ascii')
215
324
BzrError.__init__(self, branch_url=public_location)
327
class NoHelpTopic(BzrError):
329
_fmt = ("No help could be found for '%(topic)s'. "
330
"Please use 'bzr help topics' to obtain a list of topics.")
332
def __init__(self, topic):
218
336
class NoSuchId(BzrError):
220
338
_fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
346
class NoSuchIdInRepository(NoSuchId):
348
_fmt = ('The file id "%(file_id)s" is not present in the repository'
351
def __init__(self, repository, file_id):
352
BzrError.__init__(self, repository=repository, file_id=file_id)
228
355
class NotStacked(BranchError):
230
357
_fmt = "The branch '%(branch)s' is not stacked."
360
class InventoryModified(InternalBzrError):
362
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
363
" so a clean inventory cannot be read without data loss.")
365
def __init__(self, tree):
233
369
class NoWorkingTree(BzrError):
235
371
_fmt = 'No WorkingTree exists for "%(base)s".'
286
416
self.not_locked = not_locked
419
class BzrOptionError(BzrCommandError):
421
_fmt = "Error in command line options"
424
class BadIndexFormatSignature(BzrError):
426
_fmt = "%(value)s is not an index of type %(_type)s."
428
def __init__(self, value, _type):
429
BzrError.__init__(self)
434
class BadIndexData(BzrError):
436
_fmt = "Error in data for index %(value)s."
438
def __init__(self, value):
439
BzrError.__init__(self)
443
class BadIndexDuplicateKey(BzrError):
445
_fmt = "The key '%(key)s' is already in index '%(index)s'."
447
def __init__(self, key, index):
448
BzrError.__init__(self)
453
class BadIndexKey(BzrError):
455
_fmt = "The key '%(key)s' is not a valid key."
457
def __init__(self, key):
458
BzrError.__init__(self)
462
class BadIndexOptions(BzrError):
464
_fmt = "Could not parse options for index %(value)s."
466
def __init__(self, value):
467
BzrError.__init__(self)
471
class BadIndexValue(BzrError):
473
_fmt = "The value '%(value)s' is not a valid value."
475
def __init__(self, value):
476
BzrError.__init__(self)
480
class BadOptionValue(BzrError):
482
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
484
def __init__(self, name, value):
485
BzrError.__init__(self, name=name, value=value)
289
488
class StrictCommitFailed(BzrError):
291
490
_fmt = "Commit refused because there are unknown files in the tree"
377
576
_fmt = 'Permission denied: "%(path)s"%(extra)s'
579
class InvalidURL(PathError):
581
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
584
class InvalidURLJoin(PathError):
586
_fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r"
588
def __init__(self, reason, base, join_args):
591
self.join_args = join_args
592
PathError.__init__(self, base, reason)
595
class InvalidRebaseURLs(PathError):
597
_fmt = "URLs differ by more than path: %(from_)r and %(to)r"
599
def __init__(self, from_, to):
602
PathError.__init__(self, from_, 'URLs differ by more than path.')
605
class UnavailableRepresentation(InternalBzrError):
607
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
608
"is encoded as '%(native)s'.")
610
def __init__(self, key, wanted, native):
611
InternalBzrError.__init__(self)
617
class UnknownHook(BzrError):
619
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
621
def __init__(self, hook_type, hook_name):
622
BzrError.__init__(self)
623
self.type = hook_type
624
self.hook = hook_name
380
627
class UnsupportedProtocol(PathError):
382
629
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
454
712
_fmt = 'Not a branch: "%(path)s"%(detail)s.'
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
462
self.controldir = controldir
463
PathError.__init__(self, path=path)
714
def __init__(self, path, detail=None, bzrdir=None):
715
import bzrlib.urlutils as urlutils
716
path = urlutils.unescape_for_display(path, 'ascii')
717
if detail is not None:
718
detail = ': ' + detail
721
PathError.__init__(self, path=path)
465
723
def __repr__(self):
466
724
return '<%s %r>' % (self.__class__.__name__, self.__dict__)
468
def _get_format_string(self):
469
# GZ 2017-06-08: Not the best place to lazy fill detail in.
727
# XXX: Ideally self.detail would be a property, but Exceptions in
728
# Python 2.4 have to be old-style classes so properties don't work.
729
# Instead we override _format.
470
730
if self.detail is None:
471
self.detail = self._get_detail()
472
return super(NotBranchError, self)._get_format_string()
474
def _get_detail(self):
475
if self.controldir is not None:
477
self.controldir.open_repository()
478
except NoRepositoryPresent:
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__
731
if self.bzrdir is not None:
733
self.bzrdir.open_repository()
734
except NoRepositoryPresent:
737
# Just ignore unexpected errors. Raising arbitrary errors
738
# during str(err) can provoke strange bugs. Concretely
739
# Launchpad's codehosting managed to raise NotBranchError
740
# here, and then get stuck in an infinite loop/recursion
741
# trying to str() that error. All this error really cares
742
# about that there's no working repository there, and if
743
# open_repository() fails, there probably isn't.
746
self.detail = ': location is a repository'
490
return ': location is a repository'
749
return PathError._format(self)
494
752
class NoSubmitBranch(PathError):
510
763
_fmt = 'Already a branch: "%(path)s".'
513
class InvalidBranchName(PathError):
515
_fmt = "Invalid branch name: %(name)s"
517
def __init__(self, name):
518
BzrError.__init__(self)
522
class ParentBranchExists(AlreadyBranchError):
524
_fmt = 'Parent branch already exists: "%(path)s".'
527
766
class BranchExistsWithoutWorkingTree(PathError):
529
768
_fmt = 'Directory contains a branch, but no working tree \
530
(use brz checkout if you wish to build a working tree): "%(path)s"'
769
(use bzr checkout if you wish to build a working tree): "%(path)s"'
772
class AtomicFileAlreadyClosed(PathError):
774
_fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
777
def __init__(self, path, function):
778
PathError.__init__(self, path=path, extra=None)
779
self.function = function
533
782
class InaccessibleParent(PathError):
543
792
class NoRepositoryPresent(BzrError):
545
794
_fmt = 'No repository present: "%(path)s"'
547
def __init__(self, controldir):
548
BzrError.__init__(self)
549
self.path = controldir.transport.clone('..').base
795
def __init__(self, bzrdir):
796
BzrError.__init__(self)
797
self.path = bzrdir.transport.clone('..').base
800
class FileInWrongBranch(BzrError):
802
_fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
804
# use PathNotChild instead
805
@symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 3, 0)))
806
def __init__(self, branch, path):
807
BzrError.__init__(self)
809
self.branch_base = branch.base
552
813
class UnsupportedFormatError(BzrError):
554
_fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
815
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
557
818
class UnknownFormatError(BzrError):
566
827
class IncompatibleFormat(BzrError):
568
_fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
570
def __init__(self, format, controldir_format):
571
BzrError.__init__(self)
573
self.controldir = controldir_format
576
class ParseFormatError(BzrError):
578
_fmt = "Parse error on line %(lineno)d of %(format)s format: %(line)s"
580
def __init__(self, format, lineno, line, text):
581
BzrError.__init__(self)
829
_fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
831
def __init__(self, format, bzrdir_format):
832
BzrError.__init__(self)
834
self.bzrdir = bzrdir_format
588
837
class IncompatibleRepositories(BzrError):
883
1132
self.lock_token = lock_token
1135
class PointlessCommit(BzrError):
1137
_fmt = "No changes to commit"
1140
class CannotCommitSelectedFileMerge(BzrError):
1142
_fmt = 'Selected-file commit of merges is not supported yet:'\
1143
' files %(files_str)s'
1145
def __init__(self, files):
1146
files_str = ', '.join(files)
1147
BzrError.__init__(self, files=files, files_str=files_str)
1150
class ExcludesUnsupported(BzrError):
1152
_fmt = ('Excluding paths during commit is not supported by '
1153
'repository at %(repository)r.')
1155
def __init__(self, repository):
1156
BzrError.__init__(self, repository=repository)
1159
class BadCommitMessageEncoding(BzrError):
1161
_fmt = 'The specified commit message contains characters unsupported by '\
1162
'the current encoding.'
886
1165
class UpgradeReadonly(BzrError):
888
1167
_fmt = "Upgrade URL cannot work with readonly URLs."
930
1214
self.revision_id = revision_id
1217
class InvalidRevisionSpec(BzrError):
1219
_fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
1220
" %(branch_url)s%(extra)s")
1222
def __init__(self, spec, branch, extra=None):
1223
BzrError.__init__(self, branch=branch, spec=spec)
1224
self.branch_url = getattr(branch, 'user_url', str(branch))
1226
self.extra = '\n' + str(extra)
1231
class HistoryMissing(BzrError):
1233
_fmt = "%(branch)s is missing %(object_type)s {%(object_id)s}"
933
1236
class AppendRevisionsOnlyViolation(BzrError):
935
1238
_fmt = ('Operation denied because it would change the main history,'
936
' which is not permitted by the append_revisions_only setting on'
937
' branch "%(location)s".')
1239
' which is not permitted by the append_revisions_only setting on'
1240
' branch "%(location)s".')
939
1242
def __init__(self, location):
940
import breezy.urlutils as urlutils
941
location = urlutils.unescape_for_display(location, 'ascii')
942
BzrError.__init__(self, location=location)
1243
import bzrlib.urlutils as urlutils
1244
location = urlutils.unescape_for_display(location, 'ascii')
1245
BzrError.__init__(self, location=location)
945
1248
class DivergedBranches(BzrError):
998
1301
def __init__(self, rev_id, not_ancestor_id):
999
1302
BzrError.__init__(self, rev_id=rev_id,
1000
not_ancestor_id=not_ancestor_id)
1303
not_ancestor_id=not_ancestor_id)
1306
class AmbiguousBase(BzrError):
1308
def __init__(self, bases):
1309
symbol_versioning.warn("BzrError AmbiguousBase has been deprecated "
1310
"as of bzrlib 0.8.", DeprecationWarning, stacklevel=2)
1311
msg = ("The correct base is unclear, because %s are all equally close"
1313
BzrError.__init__(self, msg)
1003
1317
class NoCommits(BranchError):
1062
1377
self.error = error
1380
class WeaveError(BzrError):
1382
_fmt = "Error in processing weave: %(msg)s"
1384
def __init__(self, msg=None):
1385
BzrError.__init__(self)
1389
class WeaveRevisionAlreadyPresent(WeaveError):
1391
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1393
def __init__(self, revision_id, weave):
1395
WeaveError.__init__(self)
1396
self.revision_id = revision_id
1400
class WeaveRevisionNotPresent(WeaveError):
1402
_fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1404
def __init__(self, revision_id, weave):
1405
WeaveError.__init__(self)
1406
self.revision_id = revision_id
1410
class WeaveFormatError(WeaveError):
1412
_fmt = "Weave invariant violated: %(what)s"
1414
def __init__(self, what):
1415
WeaveError.__init__(self)
1419
class WeaveParentMismatch(WeaveError):
1421
_fmt = "Parents are mismatched between two revisions. %(msg)s"
1424
class WeaveInvalidChecksum(WeaveError):
1426
_fmt = "Text did not match its checksum: %(msg)s"
1429
class WeaveTextDiffers(WeaveError):
1431
_fmt = ("Weaves differ on text content. Revision:"
1432
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1434
def __init__(self, revision_id, weave_a, weave_b):
1435
WeaveError.__init__(self)
1436
self.revision_id = revision_id
1437
self.weave_a = weave_a
1438
self.weave_b = weave_b
1441
class WeaveTextDiffers(WeaveError):
1443
_fmt = ("Weaves differ on text content. Revision:"
1444
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1446
def __init__(self, revision_id, weave_a, weave_b):
1447
WeaveError.__init__(self)
1448
self.revision_id = revision_id
1449
self.weave_a = weave_a
1450
self.weave_b = weave_b
1065
1453
class VersionedFileError(BzrError):
1067
1455
_fmt = "Versioned file error"
1092
1480
_fmt = "Text did not match its checksum: %(msg)s"
1483
class KnitError(InternalBzrError):
1488
class KnitCorrupt(KnitError):
1490
_fmt = "Knit %(filename)s corrupt: %(how)s"
1492
def __init__(self, filename, how):
1493
KnitError.__init__(self)
1494
self.filename = filename
1498
class SHA1KnitCorrupt(KnitCorrupt):
1500
_fmt = ("Knit %(filename)s corrupt: sha-1 of reconstructed text does not "
1501
"match expected sha-1. key %(key)s expected sha %(expected)s actual "
1504
def __init__(self, filename, actual, expected, key, content):
1505
KnitError.__init__(self)
1506
self.filename = filename
1507
self.actual = actual
1508
self.expected = expected
1510
self.content = content
1513
class KnitDataStreamIncompatible(KnitError):
1514
# Not raised anymore, as we can convert data streams. In future we may
1515
# need it again for more exotic cases, so we're keeping it around for now.
1517
_fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
1519
def __init__(self, stream_format, target_format):
1520
self.stream_format = stream_format
1521
self.target_format = target_format
1524
class KnitDataStreamUnknown(KnitError):
1525
# Indicates a data stream we don't know how to handle.
1527
_fmt = "Cannot parse knit data stream of format \"%(stream_format)s\"."
1529
def __init__(self, stream_format):
1530
self.stream_format = stream_format
1533
class KnitHeaderError(KnitError):
1535
_fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
1537
def __init__(self, badline, filename):
1538
KnitError.__init__(self)
1539
self.badline = badline
1540
self.filename = filename
1542
class KnitIndexUnknownMethod(KnitError):
1543
"""Raised when we don't understand the storage method.
1545
Currently only 'fulltext' and 'line-delta' are supported.
1548
_fmt = ("Knit index %(filename)s does not have a known method"
1549
" in options: %(options)r")
1551
def __init__(self, filename, options):
1552
KnitError.__init__(self)
1553
self.filename = filename
1554
self.options = options
1095
1557
class RetryWithNewPacks(BzrError):
1096
1558
"""Raised when we realize that the packs on disk have changed.
1280
1742
TransportError.__init__(self, msg, orig_error=orig_error)
1283
class UnexpectedHttpStatus(InvalidHttpResponse):
1285
_fmt = "Unexpected HTTP status %(code)d for %(path)s"
1287
def __init__(self, path, code, msg=None):
1291
full_msg = 'status code %d unexpected' % code
1293
full_msg += ': ' + msg
1294
InvalidHttpResponse.__init__(
1295
self, path, full_msg)
1298
class BadHttpRequest(UnexpectedHttpStatus):
1300
_fmt = "Bad http request for %(path)s: %(reason)s"
1302
def __init__(self, path, reason):
1304
self.reason = reason
1305
TransportError.__init__(self, reason)
1308
1745
class InvalidHttpRange(InvalidHttpResponse):
1310
1747
_fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1360
1797
_fmt = "Working tree has conflicts."
1800
class ConfigContentError(BzrError):
1802
_fmt = "Config file %(filename)s is not UTF-8 encoded\n"
1804
def __init__(self, filename):
1805
BzrError.__init__(self)
1806
self.filename = filename
1809
class ParseConfigError(BzrError):
1811
_fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
1813
def __init__(self, errors, filename):
1814
BzrError.__init__(self)
1815
self.filename = filename
1816
self.errors = '\n'.join(e.msg for e in errors)
1819
class ConfigOptionValueError(BzrError):
1821
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
1823
def __init__(self, name, value):
1824
BzrError.__init__(self, name=name, value=value)
1827
class NoEmailInUsername(BzrError):
1829
_fmt = "%(username)r does not seem to contain a reasonable email address"
1831
def __init__(self, username):
1832
BzrError.__init__(self)
1833
self.username = username
1836
class SigningFailed(BzrError):
1838
_fmt = 'Failed to GPG sign data with command "%(command_line)s"'
1840
def __init__(self, command_line):
1841
BzrError.__init__(self, command_line=command_line)
1844
class SignatureVerificationFailed(BzrError):
1846
_fmt = 'Failed to verify GPG signature data with error "%(error)s"'
1848
def __init__(self, error):
1849
BzrError.__init__(self, error=error)
1363
1852
class DependencyNotPresent(BzrError):
1365
1854
_fmt = 'Unable to import library "%(library)s": %(error)s'
1490
2020
_fmt = "Parameter %(param)s is neither unicode nor utf8."
2023
class ReusingTransform(BzrError):
2025
_fmt = "Attempt to reuse a transform that has already been applied."
2028
class CantMoveRoot(BzrError):
2030
_fmt = "Moving the root directory is not supported at this time"
2033
class TransformRenameFailed(BzrError):
2035
_fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
2037
def __init__(self, from_path, to_path, why, errno):
2038
self.from_path = from_path
2039
self.to_path = to_path
1493
2044
class BzrMoveFailedError(BzrError):
1495
2046
_fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1496
"%(_has_extra)s%(extra)s")
2047
"%(_has_extra)s%(extra)s")
1498
2049
def __init__(self, from_path='', to_path='', extra=None):
1499
from breezy.osutils import splitpath
2050
from bzrlib.osutils import splitpath
1500
2051
BzrError.__init__(self)
1502
2053
self.extra, self._has_extra = extra, ': '
1529
2080
class BzrRenameFailedError(BzrMoveFailedError):
1531
2082
_fmt = ("Could not rename %(from_path)s%(operator)s %(to_path)s"
1532
"%(_has_extra)s%(extra)s")
2083
"%(_has_extra)s%(extra)s")
1534
2085
def __init__(self, from_path, to_path, extra=None):
1535
2086
BzrMoveFailedError.__init__(self, from_path, to_path, extra)
2089
class BzrRemoveChangedFilesError(BzrError):
2090
"""Used when user is trying to remove changed files."""
2092
_fmt = ("Can't safely remove modified or unknown files:\n"
2093
"%(changes_as_text)s"
2094
"Use --keep to not delete them, or --force to delete them regardless.")
2096
def __init__(self, tree_delta):
2097
symbol_versioning.warn(symbol_versioning.deprecated_in((2, 3, 0)) %
2098
"BzrRemoveChangedFilesError", DeprecationWarning, stacklevel=2)
2099
BzrError.__init__(self)
2100
self.changes_as_text = tree_delta.get_changes_as_text()
2101
#self.paths_as_string = '\n'.join(changed_files)
2102
#self.paths_as_string = '\n'.join([quotefn(p) for p in changed_files])
1538
2105
class BzrBadParameterNotString(BzrBadParameter):
1540
2107
_fmt = "Parameter %(param)s is not a string or unicode string."
1637
2210
wish to keep, and delete it when you are done."""
1639
2212
def __init__(self, pending_deletion):
1640
BzrError.__init__(self, pending_deletion=pending_deletion)
2213
BzrError.__init__(self, pending_deletion=pending_deletion)
2216
class ImmortalLimbo(BzrError):
2218
_fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
2219
Please examine %(limbo_dir)s to see if it contains any files you wish to
2220
keep, and delete it when you are done."""
2222
def __init__(self, limbo_dir):
2223
BzrError.__init__(self)
2224
self.limbo_dir = limbo_dir
1643
2227
class ImmortalPendingDeletion(BzrError):
1645
2229
_fmt = ("Unable to delete transform temporary directory "
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.")
2230
"%(pending_deletion)s. Please examine %(pending_deletion)s to see if it "
2231
"contains any files you wish to keep, and delete it when you are done.")
1649
2233
def __init__(self, pending_deletion):
1650
BzrError.__init__(self, pending_deletion=pending_deletion)
2234
BzrError.__init__(self, pending_deletion=pending_deletion)
1653
2237
class OutOfDateTree(BzrError):
1655
_fmt = "Working tree is out of date, please run 'brz update'.%(more)s"
2239
_fmt = "Working tree is out of date, please run 'bzr update'.%(more)s"
1657
2241
def __init__(self, tree, more=None):
1658
2242
if more is None:
1687
2271
_fmt = "Format error in conflict listings"
2274
class CorruptDirstate(BzrError):
2276
_fmt = ("Inconsistency in dirstate file %(dirstate_path)s.\n"
2277
"Error: %(description)s")
2279
def __init__(self, dirstate_path, description):
2280
BzrError.__init__(self)
2281
self.dirstate_path = dirstate_path
2282
self.description = description
1690
2285
class CorruptRepository(BzrError):
1692
2287
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1693
"Please run brz reconcile on this repository.")
2288
"Please run bzr reconcile on this repository.")
1695
2290
def __init__(self, repo):
1696
2291
BzrError.__init__(self)
1914
2511
self.revision_id = revision_id
2514
class IllegalUseOfScopeReplacer(InternalBzrError):
2516
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2517
" %(msg)s%(extra)s")
2519
def __init__(self, name, msg, extra=None):
2520
BzrError.__init__(self)
2524
self.extra = ': ' + str(extra)
2529
class InvalidImportLine(InternalBzrError):
2531
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
2533
def __init__(self, text, msg):
2534
BzrError.__init__(self)
2539
class ImportNameCollision(InternalBzrError):
2541
_fmt = ("Tried to import an object to the same name as"
2542
" an existing object. %(name)s")
2544
def __init__(self, name):
2545
BzrError.__init__(self)
1917
2549
class NotAMergeDirective(BzrError):
1918
2550
"""File starting with %(firstline)r is not a merge directive"""
1920
2551
def __init__(self, firstline):
1921
2552
BzrError.__init__(self, firstline=firstline)
2001
2660
self.tag_name = tag_name
2663
class MalformedBugIdentifier(BzrError):
2665
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2666
'See "bzr help bugs" for more information on this feature.')
2668
def __init__(self, bug_id, reason):
2669
self.bug_id = bug_id
2670
self.reason = reason
2673
class InvalidBugTrackerURL(BzrError):
2675
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2676
"contain {id}: %(url)s")
2678
def __init__(self, abbreviation, url):
2679
self.abbreviation = abbreviation
2683
class UnknownBugTrackerAbbreviation(BzrError):
2685
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2688
def __init__(self, abbreviation, branch):
2689
self.abbreviation = abbreviation
2690
self.branch = branch
2693
class InvalidLineInBugsProperty(BzrError):
2695
_fmt = ("Invalid line in bugs property: '%(line)s'")
2697
def __init__(self, line):
2701
class InvalidBugStatus(BzrError):
2703
_fmt = ("Invalid bug status: '%(status)s'")
2705
def __init__(self, status):
2706
self.status = status
2004
2709
class UnexpectedSmartServerResponse(BzrError):
2006
2711
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2112
2822
self.reason = reason
2825
class SMTPError(BzrError):
2827
_fmt = "SMTP error: %(error)s"
2829
def __init__(self, error):
2833
class NoMessageSupplied(BzrError):
2835
_fmt = "No message supplied."
2838
class NoMailAddressSpecified(BzrError):
2840
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2843
class UnknownMailClient(BzrError):
2845
_fmt = "Unknown mail client: %(mail_client)s"
2847
def __init__(self, mail_client):
2848
BzrError.__init__(self, mail_client=mail_client)
2851
class MailClientNotFound(BzrError):
2853
_fmt = "Unable to find mail client with the following names:"\
2854
" %(mail_command_list_string)s"
2856
def __init__(self, mail_command_list):
2857
mail_command_list_string = ', '.join(mail_command_list)
2858
BzrError.__init__(self, mail_command_list=mail_command_list,
2859
mail_command_list_string=mail_command_list_string)
2861
class SMTPConnectionRefused(SMTPError):
2863
_fmt = "SMTP connection to %(host)s refused"
2865
def __init__(self, error, host):
2870
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2872
_fmt = "Please specify smtp_server. No server at default %(host)s."
2875
class BzrDirError(BzrError):
2877
def __init__(self, bzrdir):
2878
import bzrlib.urlutils as urlutils
2879
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2881
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2884
class UnsyncedBranches(BzrDirError):
2886
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2887
" bzr help sync-for-reconfigure.")
2889
def __init__(self, bzrdir, target_branch):
2890
BzrDirError.__init__(self, bzrdir)
2891
import bzrlib.urlutils as urlutils
2892
self.target_url = urlutils.unescape_for_display(target_branch.base,
2896
class AlreadyBranch(BzrDirError):
2898
_fmt = "'%(display_url)s' is already a branch."
2901
class AlreadyTree(BzrDirError):
2903
_fmt = "'%(display_url)s' is already a tree."
2906
class AlreadyCheckout(BzrDirError):
2908
_fmt = "'%(display_url)s' is already a checkout."
2911
class AlreadyLightweightCheckout(BzrDirError):
2913
_fmt = "'%(display_url)s' is already a lightweight checkout."
2916
class AlreadyUsingShared(BzrDirError):
2918
_fmt = "'%(display_url)s' is already using a shared repository."
2921
class AlreadyStandalone(BzrDirError):
2923
_fmt = "'%(display_url)s' is already standalone."
2926
class AlreadyWithTrees(BzrDirError):
2928
_fmt = ("Shared repository '%(display_url)s' already creates "
2932
class AlreadyWithNoTrees(BzrDirError):
2934
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2938
class ReconfigurationNotSupported(BzrDirError):
2940
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2943
class NoBindLocation(BzrDirError):
2945
_fmt = "No location could be found to bind to at %(display_url)s."
2115
2948
class UncommittedChanges(BzrError):
2117
2950
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2118
' (See brz status).%(more)s')
2951
' (See bzr status).%(more)s')
2120
2953
def __init__(self, tree, more=None):
2121
2954
if more is None:
2124
2957
more = ' ' + more
2125
import breezy.urlutils as urlutils
2958
import bzrlib.urlutils as urlutils
2126
2959
user_url = getattr(tree, "user_url", None)
2127
2960
if user_url is None:
2128
2961
display_url = str(tree)
2131
2964
BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2134
class StoringUncommittedNotSupported(BzrError):
2136
_fmt = ('Branch "%(display_url)s" does not support storing uncommitted'
2139
def __init__(self, branch):
2140
import breezy.urlutils as urlutils
2141
user_url = getattr(branch, "user_url", None)
2142
if user_url is None:
2143
display_url = str(branch)
2145
display_url = urlutils.unescape_for_display(user_url, 'ascii')
2146
BzrError.__init__(self, branch=branch, display_url=display_url)
2149
2967
class ShelvedChanges(UncommittedChanges):
2151
2969
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2152
' (See brz shelve --list).%(more)s')
2970
' (See bzr shelve --list).%(more)s')
2973
class MissingTemplateVariable(BzrError):
2975
_fmt = 'Variable {%(name)s} is not available.'
2977
def __init__(self, name):
2981
class NoTemplate(BzrError):
2983
_fmt = 'No template specified.'
2986
class UnableCreateSymlink(BzrError):
2988
_fmt = 'Unable to create symlink %(path_str)son this platform'
2990
def __init__(self, path=None):
2994
path_str = repr(str(path))
2995
except UnicodeEncodeError:
2996
path_str = repr(path)
2998
self.path_str = path_str
3001
class UnsupportedTimezoneFormat(BzrError):
3003
_fmt = ('Unsupported timezone format "%(timezone)s", '
3004
'options are "utc", "original", "local".')
3006
def __init__(self, timezone):
3007
self.timezone = timezone
3010
class CommandAvailableInPlugin(StandardError):
3012
internal_error = False
3014
def __init__(self, cmd_name, plugin_metadata, provider):
3016
self.plugin_metadata = plugin_metadata
3017
self.cmd_name = cmd_name
3018
self.provider = provider
3022
_fmt = ('"%s" is not a standard bzr command. \n'
3023
'However, the following official plugin provides this command: %s\n'
3024
'You can install it by going to: %s'
3025
% (self.cmd_name, self.plugin_metadata['name'],
3026
self.plugin_metadata['url']))
3031
class NoPluginAvailable(BzrError):
2155
3035
class UnableEncodePath(BzrError):
2158
3038
'user encoding %(user_encoding)s')
2160
3040
def __init__(self, path, kind):
2161
from breezy.osutils import get_user_encoding
3041
from bzrlib.osutils import get_user_encoding
2162
3042
self.path = path
2163
3043
self.kind = kind
2164
self.user_encoding = get_user_encoding()
3044
self.user_encoding = osutils.get_user_encoding()
3047
class NoSuchConfig(BzrError):
3049
_fmt = ('The "%(config_id)s" configuration does not exist.')
3051
def __init__(self, config_id):
3052
BzrError.__init__(self, config_id=config_id)
3055
class NoSuchConfigOption(BzrError):
3057
_fmt = ('The "%(option_name)s" configuration option does not exist.')
3059
def __init__(self, option_name):
3060
BzrError.__init__(self, option_name=option_name)
2167
3063
class NoSuchAlias(BzrError):
2172
3068
BzrError.__init__(self, alias_name=alias_name)
3071
class DirectoryLookupFailure(BzrError):
3072
"""Base type for lookup errors."""
3077
class InvalidLocationAlias(DirectoryLookupFailure):
3079
_fmt = '"%(alias_name)s" is not a valid location alias.'
3081
def __init__(self, alias_name):
3082
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
3085
class UnsetLocationAlias(DirectoryLookupFailure):
3087
_fmt = 'No %(alias_name)s location assigned.'
3089
def __init__(self, alias_name):
3090
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2175
3093
class CannotBindAddress(BzrError):
2177
3095
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2179
3097
def __init__(self, host, port, orig_error):
2180
3098
# nb: in python2.4 socket.error doesn't have a useful repr
2181
3099
BzrError.__init__(self, host=host, port=port,
2182
orig_error=repr(orig_error.args))
3100
orig_error=repr(orig_error.args))
3103
class UnknownRules(BzrError):
3105
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
3107
def __init__(self, unknowns):
3108
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
3111
class HookFailed(BzrError):
3112
"""Raised when a pre_change_branch_tip hook function fails anything other
3113
than TipChangeRejected.
3115
Note that this exception is no longer raised, and the import is only left
3116
to be nice to code which might catch it in a plugin.
3119
_fmt = ("Hook '%(hook_name)s' during %(hook_stage)s failed:\n"
3120
"%(traceback_text)s%(exc_value)s")
3122
def __init__(self, hook_stage, hook_name, exc_info, warn=True):
3124
symbol_versioning.warn("BzrError HookFailed has been deprecated "
3125
"as of bzrlib 2.1.", DeprecationWarning, stacklevel=2)
3127
self.hook_stage = hook_stage
3128
self.hook_name = hook_name
3129
self.exc_info = exc_info
3130
self.exc_type = exc_info[0]
3131
self.exc_value = exc_info[1]
3132
self.exc_tb = exc_info[2]
3133
self.traceback_text = ''.join(traceback.format_tb(self.exc_tb))
2185
3136
class TipChangeRejected(BzrError):
3147
class ShelfCorrupt(BzrError):
3149
_fmt = "Shelf corrupt."
3152
class DecompressCorruption(BzrError):
3154
_fmt = "Corruption while decompressing repository file%(orig_error)s"
3156
def __init__(self, orig_error=None):
3157
if orig_error is not None:
3158
self.orig_error = ", %s" % (orig_error,)
3160
self.orig_error = ""
3161
BzrError.__init__(self)
3164
class NoSuchShelfId(BzrError):
3166
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3168
def __init__(self, shelf_id):
3169
BzrError.__init__(self, shelf_id=shelf_id)
3172
class InvalidShelfId(BzrError):
3174
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3176
def __init__(self, invalid_id):
3177
BzrError.__init__(self, invalid_id=invalid_id)
2196
3180
class JailBreak(BzrError):
2198
3182
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2206
3190
_fmt = 'The user aborted the operation.'
3193
class MustHaveWorkingTree(BzrError):
3195
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3197
def __init__(self, format, url):
3198
BzrError.__init__(self, format=format, url=url)
3201
class NoSuchView(BzrError):
3202
"""A view does not exist.
3205
_fmt = u"No such view: %(view_name)s."
3207
def __init__(self, view_name):
3208
self.view_name = view_name
3211
class ViewsNotSupported(BzrError):
3212
"""Views are not supported by a tree format.
3215
_fmt = ("Views are not supported by %(tree)s;"
3216
" use 'bzr upgrade' to change your tree to a later format.")
3218
def __init__(self, tree):
3222
class FileOutsideView(BzrError):
3224
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3227
def __init__(self, file_name, view_files):
3228
self.file_name = file_name
3229
self.view_str = ", ".join(view_files)
2209
3232
class UnresumableWriteGroup(BzrError):
2211
3234
_fmt = ("Repository %(repository)s cannot resume write group "
2253
3276
self.target_branch = target_branch
3279
class FileTimestampUnavailable(BzrError):
3281
_fmt = "The filestamp for %(path)s is not available."
3283
internal_error = True
3285
def __init__(self, path):
2256
3289
class NoColocatedBranchSupport(BzrError):
2258
_fmt = ("%(controldir)r does not support co-located branches.")
2260
def __init__(self, controldir):
2261
self.controldir = controldir
3291
_fmt = ("%(bzrdir)r does not support co-located branches.")
3293
def __init__(self, bzrdir):
3294
self.bzrdir = bzrdir
3297
class NoWhoami(BzrError):
3299
_fmt = ('Unable to determine your name.\n'
3300
"Please, set your name with the 'whoami' command.\n"
3301
'E.g. bzr whoami "Your Name <name@example.com>"')
3304
class InvalidPattern(BzrError):
3306
_fmt = ('Invalid pattern(s) found. %(msg)s')
3308
def __init__(self, msg):
2264
3312
class RecursiveBind(BzrError):
2266
3314
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2267
'Please use `brz unbind` to fix.')
3315
'Please use `bzr unbind` to fix.')
2269
3317
def __init__(self, branch_url):
2270
3318
self.branch_url = branch_url
3321
# FIXME: I would prefer to define the config related exception classes in
3322
# config.py but the lazy import mechanism proscribes this -- vila 20101222
3323
class OptionExpansionLoop(BzrError):
3325
_fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
3327
def __init__(self, string, refs):
3328
self.string = string
3329
self.refs = '->'.join(refs)
3332
class ExpandingUnknownOption(BzrError):
3334
_fmt = 'Option %(name)s is not defined while expanding "%(string)s".'
3336
def __init__(self, name, string):
3338
self.string = string
3341
class NoCompatibleInter(BzrError):
3343
_fmt = ('No compatible object available for operations from %(source)r '
3346
def __init__(self, source, target):
3347
self.source = source
3348
self.target = target
3351
class HpssVfsRequestNotAllowed(BzrError):
3353
_fmt = ("VFS requests over the smart server are not allowed. Encountered: "
3354
"%(method)s, %(arguments)s.")
3356
def __init__(self, method, arguments):
3357
self.method = method
3358
self.arguments = arguments
2273
3361
class UnsupportedKindChange(BzrError):
2275
3363
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2280
3368
self.from_kind = from_kind
2281
3369
self.to_kind = to_kind
2282
3370
self.format = format
2285
class ChangesAlreadyStored(CommandError):
2287
_fmt = ('Cannot store uncommitted changes because this branch already'
2288
' stores uncommitted changes.')
2291
class RevnoOutOfBounds(InternalBzrError):
2293
_fmt = ("The requested revision number %(revno)d is outside of the "
2294
"expected boundaries (%(minimum)d <= %(maximum)d).")
2296
def __init__(self, revno, bounds):
2297
InternalBzrError.__init__(
2298
self, revno=revno, minimum=bounds[0], maximum=bounds[1])