34
# return codes from the brz program
35
# return codes from the bzr program
37
38
EXIT_INTERNAL_ERROR = 4
40
class BzrError(Exception):
41
class BzrError(StandardError):
42
Base class for errors raised by breezy.
43
Base class for errors raised by bzrlib.
44
:cvar internal_error: if True this was probably caused by a brz bug and
45
:cvar internal_error: if True this was probably caused by a bzr bug and
45
46
should be displayed with a traceback; if False (or absent) this was
46
47
probably a user or environment error and they don't need the gory
47
48
details. (That can be overridden by -Derror on the command line.)
95
95
# __str__() should always return a 'str' object
96
96
# never a 'unicode' object.
98
except Exception as e:
99
pass # just bind to 'e' for formatting below
100
102
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
101
103
% (self.__class__.__name__,
103
105
getattr(self, '_fmt', None),
108
def __unicode__(self):
110
if isinstance(u, str):
111
# Try decoding the str using the default encoding.
113
elif not isinstance(u, unicode):
114
# Try to make a unicode object from it, because __unicode__ must
115
# return a unicode object.
121
if isinstance(s, unicode):
124
# __str__ must return a str.
108
128
def __repr__(self):
109
129
return '%s(%s)' % (self.__class__.__name__, str(self))
112
132
"""Return format string for this exception or None"""
113
133
fmt = getattr(self, '_fmt', None)
114
134
if fmt is not None:
115
from breezy.i18n import gettext
116
return gettext(fmt) # _fmt strings should be ascii
135
from bzrlib.i18n import gettext
136
return gettext(unicode(fmt)) # _fmt strings should be ascii
118
138
def __eq__(self, other):
119
139
if self.__class__ is not other.__class__:
120
140
return NotImplemented
121
141
return self.__dict__ == other.__dict__
127
144
class InternalBzrError(BzrError):
128
145
"""Base class for errors that are internal in nature.
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):
176
class DirstateCorrupt(BzrError):
178
_fmt = "The dirstate file (%(state)s) appears to be corrupt: %(msg)s"
180
def __init__(self, state, msg):
181
BzrError.__init__(self)
186
class DisabledMethod(InternalBzrError):
188
_fmt = "The smart server method '%(class_name)s' is disabled."
190
def __init__(self, class_name):
191
BzrError.__init__(self)
192
self.class_name = class_name
195
class IncompatibleAPI(BzrError):
197
_fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
198
'It supports versions "%(minimum)s" to "%(current)s".'
200
def __init__(self, api, wanted, minimum, current):
161
202
self.wanted = wanted
203
self.minimum = minimum
162
204
self.current = current
210
261
_fmt = 'There is no public branch set for "%(branch_url)s".'
212
263
def __init__(self, branch):
213
from . import urlutils
264
import bzrlib.urlutils as urlutils
214
265
public_location = urlutils.unescape_for_display(branch.base, 'ascii')
215
266
BzrError.__init__(self, branch_url=public_location)
269
class NoHelpTopic(BzrError):
271
_fmt = ("No help could be found for '%(topic)s'. "
272
"Please use 'bzr help topics' to obtain a list of topics.")
274
def __init__(self, topic):
218
278
class NoSuchId(BzrError):
220
280
_fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
288
class NoSuchIdInRepository(NoSuchId):
290
_fmt = ('The file id "%(file_id)s" is not present in the repository'
293
def __init__(self, repository, file_id):
294
BzrError.__init__(self, repository=repository, file_id=file_id)
228
297
class NotStacked(BranchError):
230
299
_fmt = "The branch '%(branch)s' is not stacked."
302
class InventoryModified(InternalBzrError):
304
_fmt = ("The current inventory for the tree %(tree)r has been modified,"
305
" so a clean inventory cannot be read without data loss.")
307
def __init__(self, tree):
233
311
class NoWorkingTree(BzrError):
235
313
_fmt = 'No WorkingTree exists for "%(base)s".'
271
347
# I think it's a waste of effort to differentiate between errors that
272
348
# are not intended to be caught anyway. UI code need not subclass
273
# CommandError, and non-UI code should not throw a subclass of
274
# CommandError. ADHB 20051211
277
# Provide the old name as backup, for the moment.
278
BzrCommandError = CommandError
349
# BzrCommandError, and non-UI code should not throw a subclass of
350
# BzrCommandError. ADHB 20051211
281
353
class NotWriteLocked(BzrError):
286
358
self.not_locked = not_locked
361
class BzrOptionError(BzrCommandError):
363
_fmt = "Error in command line options"
366
class BadIndexFormatSignature(BzrError):
368
_fmt = "%(value)s is not an index of type %(_type)s."
370
def __init__(self, value, _type):
371
BzrError.__init__(self)
376
class BadIndexData(BzrError):
378
_fmt = "Error in data for index %(value)s."
380
def __init__(self, value):
381
BzrError.__init__(self)
385
class BadIndexDuplicateKey(BzrError):
387
_fmt = "The key '%(key)s' is already in index '%(index)s'."
389
def __init__(self, key, index):
390
BzrError.__init__(self)
395
class BadIndexKey(BzrError):
397
_fmt = "The key '%(key)s' is not a valid key."
399
def __init__(self, key):
400
BzrError.__init__(self)
404
class BadIndexOptions(BzrError):
406
_fmt = "Could not parse options for index %(value)s."
408
def __init__(self, value):
409
BzrError.__init__(self)
413
class BadIndexValue(BzrError):
415
_fmt = "The value '%(value)s' is not a valid value."
417
def __init__(self, value):
418
BzrError.__init__(self)
422
class BadOptionValue(BzrError):
424
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
426
def __init__(self, name, value):
427
BzrError.__init__(self, name=name, value=value)
289
430
class StrictCommitFailed(BzrError):
291
432
_fmt = "Commit refused because there are unknown files in the tree"
377
518
_fmt = 'Permission denied: "%(path)s"%(extra)s'
521
class InvalidURL(PathError):
523
_fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
526
class InvalidURLJoin(PathError):
528
_fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r"
530
def __init__(self, reason, base, join_args):
533
self.join_args = join_args
534
PathError.__init__(self, base, reason)
537
class InvalidRebaseURLs(PathError):
539
_fmt = "URLs differ by more than path: %(from_)r and %(to)r"
541
def __init__(self, from_, to):
544
PathError.__init__(self, from_, 'URLs differ by more than path.')
547
class UnavailableRepresentation(InternalBzrError):
549
_fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
550
"is encoded as '%(native)s'.")
552
def __init__(self, key, wanted, native):
553
InternalBzrError.__init__(self)
559
class UnknownHook(BzrError):
561
_fmt = "The %(type)s hook '%(hook)s' is unknown in this version of bzrlib."
563
def __init__(self, hook_type, hook_name):
564
BzrError.__init__(self)
565
self.type = hook_type
566
self.hook = hook_name
380
569
class UnsupportedProtocol(PathError):
382
571
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
454
654
_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)
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
663
PathError.__init__(self, path=path)
465
665
def __repr__(self):
466
666
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.
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.
470
672
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__
673
if self.bzrdir is not None:
675
self.bzrdir.open_repository()
676
except NoRepositoryPresent:
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.
688
self.detail = ': location is a repository'
490
return ': location is a repository'
691
return PathError._format(self)
494
694
class NoSubmitBranch(PathError):
527
727
class BranchExistsWithoutWorkingTree(PathError):
529
729
_fmt = 'Directory contains a branch, but no working tree \
530
(use brz checkout if you wish to build a working tree): "%(path)s"'
730
(use bzr checkout if you wish to build a working tree): "%(path)s"'
733
class AtomicFileAlreadyClosed(PathError):
735
_fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
738
def __init__(self, path, function):
739
PathError.__init__(self, path=path, extra=None)
740
self.function = function
533
743
class InaccessibleParent(PathError):
543
753
class NoRepositoryPresent(BzrError):
545
755
_fmt = 'No repository present: "%(path)s"'
547
def __init__(self, controldir):
756
def __init__(self, bzrdir):
548
757
BzrError.__init__(self)
549
self.path = controldir.transport.clone('..').base
758
self.path = bzrdir.transport.clone('..').base
552
761
class UnsupportedFormatError(BzrError):
554
_fmt = "Unsupported branch format: %(format)s\nPlease run 'brz upgrade'"
763
_fmt = "Unsupported branch format: %(format)s\nPlease run 'bzr upgrade'"
557
766
class UnknownFormatError(BzrError):
883
1092
self.lock_token = lock_token
1095
class PointlessCommit(BzrError):
1097
_fmt = "No changes to commit"
1100
class CannotCommitSelectedFileMerge(BzrError):
1102
_fmt = 'Selected-file commit of merges is not supported yet:'\
1103
' files %(files_str)s'
1105
def __init__(self, files):
1106
files_str = ', '.join(files)
1107
BzrError.__init__(self, files=files, files_str=files_str)
1110
class ExcludesUnsupported(BzrError):
1112
_fmt = ('Excluding paths during commit is not supported by '
1113
'repository at %(repository)r.')
1115
def __init__(self, repository):
1116
BzrError.__init__(self, repository=repository)
1119
class BadCommitMessageEncoding(BzrError):
1121
_fmt = 'The specified commit message contains characters unsupported by '\
1122
'the current encoding.'
886
1125
class UpgradeReadonly(BzrError):
888
1127
_fmt = "Upgrade URL cannot work with readonly URLs."
930
1174
self.revision_id = revision_id
1177
class InvalidRevisionSpec(BzrError):
1179
_fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
1180
" %(branch_url)s%(extra)s")
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))
1186
self.extra = '\n' + str(extra)
933
1191
class AppendRevisionsOnlyViolation(BzrError):
935
1193
_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".')
1194
' which is not permitted by the append_revisions_only setting on'
1195
' branch "%(location)s".')
939
1197
def __init__(self, location):
940
import breezy.urlutils as urlutils
941
location = urlutils.unescape_for_display(location, 'ascii')
942
BzrError.__init__(self, location=location)
1198
import bzrlib.urlutils as urlutils
1199
location = urlutils.unescape_for_display(location, 'ascii')
1200
BzrError.__init__(self, location=location)
945
1203
class DivergedBranches(BzrError):
1062
1321
self.error = error
1324
class WeaveError(BzrError):
1326
_fmt = "Error in processing weave: %(msg)s"
1328
def __init__(self, msg=None):
1329
BzrError.__init__(self)
1333
class WeaveRevisionAlreadyPresent(WeaveError):
1335
_fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1337
def __init__(self, revision_id, weave):
1339
WeaveError.__init__(self)
1340
self.revision_id = revision_id
1344
class WeaveRevisionNotPresent(WeaveError):
1346
_fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1348
def __init__(self, revision_id, weave):
1349
WeaveError.__init__(self)
1350
self.revision_id = revision_id
1354
class WeaveFormatError(WeaveError):
1356
_fmt = "Weave invariant violated: %(what)s"
1358
def __init__(self, what):
1359
WeaveError.__init__(self)
1363
class WeaveParentMismatch(WeaveError):
1365
_fmt = "Parents are mismatched between two revisions. %(msg)s"
1368
class WeaveInvalidChecksum(WeaveError):
1370
_fmt = "Text did not match its checksum: %(msg)s"
1373
class WeaveTextDiffers(WeaveError):
1375
_fmt = ("Weaves differ on text content. Revision:"
1376
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
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
1385
class WeaveTextDiffers(WeaveError):
1387
_fmt = ("Weaves differ on text content. Revision:"
1388
" {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
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
1065
1397
class VersionedFileError(BzrError):
1067
1399
_fmt = "Versioned file error"
1092
1424
_fmt = "Text did not match its checksum: %(msg)s"
1427
class KnitError(InternalBzrError):
1432
class KnitCorrupt(KnitError):
1434
_fmt = "Knit %(filename)s corrupt: %(how)s"
1436
def __init__(self, filename, how):
1437
KnitError.__init__(self)
1438
self.filename = filename
1442
class SHA1KnitCorrupt(KnitCorrupt):
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 "
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
1454
self.content = content
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.
1461
_fmt = "Cannot insert knit data stream of format \"%(stream_format)s\" into knit of format \"%(target_format)s\"."
1463
def __init__(self, stream_format, target_format):
1464
self.stream_format = stream_format
1465
self.target_format = target_format
1468
class KnitDataStreamUnknown(KnitError):
1469
# Indicates a data stream we don't know how to handle.
1471
_fmt = "Cannot parse knit data stream of format \"%(stream_format)s\"."
1473
def __init__(self, stream_format):
1474
self.stream_format = stream_format
1477
class KnitHeaderError(KnitError):
1479
_fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
1481
def __init__(self, badline, filename):
1482
KnitError.__init__(self)
1483
self.badline = badline
1484
self.filename = filename
1486
class KnitIndexUnknownMethod(KnitError):
1487
"""Raised when we don't understand the storage method.
1489
Currently only 'fulltext' and 'line-delta' are supported.
1492
_fmt = ("Knit index %(filename)s does not have a known method"
1493
" in options: %(options)r")
1495
def __init__(self, filename, options):
1496
KnitError.__init__(self)
1497
self.filename = filename
1498
self.options = options
1095
1501
class RetryWithNewPacks(BzrError):
1096
1502
"""Raised when we realize that the packs on disk have changed.
1280
1686
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)
1689
class CertificateError(TransportError):
1691
_fmt = "Certificate error: %(error)s"
1693
def __init__(self, error):
1308
1697
class InvalidHttpRange(InvalidHttpResponse):
1360
1749
_fmt = "Working tree has conflicts."
1752
class ConfigContentError(BzrError):
1754
_fmt = "Config file %(filename)s is not UTF-8 encoded\n"
1756
def __init__(self, filename):
1757
BzrError.__init__(self)
1758
self.filename = filename
1761
class ParseConfigError(BzrError):
1763
_fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
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)
1771
class ConfigOptionValueError(BzrError):
1773
_fmt = ('Bad value "%(value)s" for option "%(name)s".\n'
1774
'See ``bzr help %(name)s``')
1776
def __init__(self, name, value):
1777
BzrError.__init__(self, name=name, value=value)
1780
class NoEmailInUsername(BzrError):
1782
_fmt = "%(username)r does not seem to contain a reasonable email address"
1784
def __init__(self, username):
1785
BzrError.__init__(self)
1786
self.username = username
1789
class SigningFailed(BzrError):
1791
_fmt = 'Failed to GPG sign data with command "%(command_line)s"'
1793
def __init__(self, command_line):
1794
BzrError.__init__(self, command_line=command_line)
1797
class SignatureVerificationFailed(BzrError):
1799
_fmt = 'Failed to verify GPG signature data with error "%(error)s"'
1801
def __init__(self, error):
1802
BzrError.__init__(self, error=error)
1363
1805
class DependencyNotPresent(BzrError):
1365
1807
_fmt = 'Unable to import library "%(library)s": %(error)s'
1473
1939
self.prefix = prefix
1942
class MalformedTransform(InternalBzrError):
1944
_fmt = "Tree transform is malformed %(conflicts)r"
1947
class NoFinalPath(BzrError):
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")
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
1476
1959
class BzrBadParameter(InternalBzrError):
1478
1961
_fmt = "Bad parameter: %(param)r"
1490
1973
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1976
class ReusingTransform(BzrError):
1978
_fmt = "Attempt to reuse a transform that has already been applied."
1981
class CantMoveRoot(BzrError):
1983
_fmt = "Moving the root directory is not supported at this time"
1986
class TransformRenameFailed(BzrError):
1988
_fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
1990
def __init__(self, from_path, to_path, why, errno):
1991
self.from_path = from_path
1992
self.to_path = to_path
1493
1997
class BzrMoveFailedError(BzrError):
1495
1999
_fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1496
"%(_has_extra)s%(extra)s")
2000
"%(_has_extra)s%(extra)s")
1498
2002
def __init__(self, from_path='', to_path='', extra=None):
1499
from breezy.osutils import splitpath
2003
from bzrlib.osutils import splitpath
1500
2004
BzrError.__init__(self)
1502
2006
self.extra, self._has_extra = extra, ': '
1637
2147
wish to keep, and delete it when you are done."""
1639
2149
def __init__(self, pending_deletion):
1640
BzrError.__init__(self, pending_deletion=pending_deletion)
2150
BzrError.__init__(self, pending_deletion=pending_deletion)
2153
class ImmortalLimbo(BzrError):
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."""
2159
def __init__(self, limbo_dir):
2160
BzrError.__init__(self)
2161
self.limbo_dir = limbo_dir
1643
2164
class ImmortalPendingDeletion(BzrError):
1645
2166
_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.")
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.")
1649
2170
def __init__(self, pending_deletion):
1650
BzrError.__init__(self, pending_deletion=pending_deletion)
2171
BzrError.__init__(self, pending_deletion=pending_deletion)
1653
2174
class OutOfDateTree(BzrError):
1655
_fmt = "Working tree is out of date, please run 'brz update'.%(more)s"
2176
_fmt = "Working tree is out of date, please run 'bzr update'.%(more)s"
1657
2178
def __init__(self, tree, more=None):
1658
2179
if more is None:
1687
2208
_fmt = "Format error in conflict listings"
2211
class CorruptDirstate(BzrError):
2213
_fmt = ("Inconsistency in dirstate file %(dirstate_path)s.\n"
2214
"Error: %(description)s")
2216
def __init__(self, dirstate_path, description):
2217
BzrError.__init__(self)
2218
self.dirstate_path = dirstate_path
2219
self.description = description
1690
2222
class CorruptRepository(BzrError):
1692
2224
_fmt = ("An error has been detected in the repository %(repo_path)s.\n"
1693
"Please run brz reconcile on this repository.")
2225
"Please run bzr reconcile on this repository.")
1695
2227
def __init__(self, repo):
1696
2228
BzrError.__init__(self)
1914
2448
self.revision_id = revision_id
2451
class IllegalUseOfScopeReplacer(InternalBzrError):
2453
_fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2454
" %(msg)s%(extra)s")
2456
def __init__(self, name, msg, extra=None):
2457
BzrError.__init__(self)
2461
self.extra = ': ' + str(extra)
2466
class InvalidImportLine(InternalBzrError):
2468
_fmt = "Not a valid import statement: %(msg)\n%(text)s"
2470
def __init__(self, text, msg):
2471
BzrError.__init__(self)
2476
class ImportNameCollision(InternalBzrError):
2478
_fmt = ("Tried to import an object to the same name as"
2479
" an existing object. %(name)s")
2481
def __init__(self, name):
2482
BzrError.__init__(self)
1917
2486
class NotAMergeDirective(BzrError):
1918
2487
"""File starting with %(firstline)r is not a merge directive"""
1920
2488
def __init__(self, firstline):
1921
2489
BzrError.__init__(self, firstline=firstline)
2001
2597
self.tag_name = tag_name
2600
class MalformedBugIdentifier(BzrError):
2602
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2603
'See "bzr help bugs" for more information on this feature.')
2605
def __init__(self, bug_id, reason):
2606
self.bug_id = bug_id
2607
self.reason = reason
2610
class InvalidBugTrackerURL(BzrError):
2612
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2613
"contain {id}: %(url)s")
2615
def __init__(self, abbreviation, url):
2616
self.abbreviation = abbreviation
2620
class UnknownBugTrackerAbbreviation(BzrError):
2622
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2625
def __init__(self, abbreviation, branch):
2626
self.abbreviation = abbreviation
2627
self.branch = branch
2630
class InvalidLineInBugsProperty(BzrError):
2632
_fmt = ("Invalid line in bugs property: '%(line)s'")
2634
def __init__(self, line):
2638
class InvalidBugStatus(BzrError):
2640
_fmt = ("Invalid bug status: '%(status)s'")
2642
def __init__(self, status):
2643
self.status = status
2004
2646
class UnexpectedSmartServerResponse(BzrError):
2006
2648
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2112
2759
self.reason = reason
2762
class SMTPError(BzrError):
2764
_fmt = "SMTP error: %(error)s"
2766
def __init__(self, error):
2770
class NoMessageSupplied(BzrError):
2772
_fmt = "No message supplied."
2775
class NoMailAddressSpecified(BzrError):
2777
_fmt = "No mail-to address (--mail-to) or output (-o) specified."
2780
class MailClientNotFound(BzrError):
2782
_fmt = "Unable to find mail client with the following names:"\
2783
" %(mail_command_list_string)s"
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)
2790
class SMTPConnectionRefused(SMTPError):
2792
_fmt = "SMTP connection to %(host)s refused"
2794
def __init__(self, error, host):
2799
class DefaultSMTPConnectionRefused(SMTPConnectionRefused):
2801
_fmt = "Please specify smtp_server. No server at default %(host)s."
2804
class BzrDirError(BzrError):
2806
def __init__(self, bzrdir):
2807
import bzrlib.urlutils as urlutils
2808
display_url = urlutils.unescape_for_display(bzrdir.user_url,
2810
BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2813
class UnsyncedBranches(BzrDirError):
2815
_fmt = ("'%(display_url)s' is not in sync with %(target_url)s. See"
2816
" bzr help sync-for-reconfigure.")
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,
2825
class AlreadyBranch(BzrDirError):
2827
_fmt = "'%(display_url)s' is already a branch."
2830
class AlreadyTree(BzrDirError):
2832
_fmt = "'%(display_url)s' is already a tree."
2835
class AlreadyCheckout(BzrDirError):
2837
_fmt = "'%(display_url)s' is already a checkout."
2840
class AlreadyLightweightCheckout(BzrDirError):
2842
_fmt = "'%(display_url)s' is already a lightweight checkout."
2845
class AlreadyUsingShared(BzrDirError):
2847
_fmt = "'%(display_url)s' is already using a shared repository."
2850
class AlreadyStandalone(BzrDirError):
2852
_fmt = "'%(display_url)s' is already standalone."
2855
class AlreadyWithTrees(BzrDirError):
2857
_fmt = ("Shared repository '%(display_url)s' already creates "
2861
class AlreadyWithNoTrees(BzrDirError):
2863
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2867
class ReconfigurationNotSupported(BzrDirError):
2869
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2872
class NoBindLocation(BzrDirError):
2874
_fmt = "No location could be found to bind to at %(display_url)s."
2115
2877
class UncommittedChanges(BzrError):
2117
2879
_fmt = ('Working tree "%(display_url)s" has uncommitted changes'
2118
' (See brz status).%(more)s')
2880
' (See bzr status).%(more)s')
2120
2882
def __init__(self, tree, more=None):
2121
2883
if more is None:
2124
2886
more = ' ' + more
2125
import breezy.urlutils as urlutils
2887
import bzrlib.urlutils as urlutils
2126
2888
user_url = getattr(tree, "user_url", None)
2127
2889
if user_url is None:
2128
2890
display_url = str(tree)
2149
2911
class ShelvedChanges(UncommittedChanges):
2151
2913
_fmt = ('Working tree "%(display_url)s" has shelved changes'
2152
' (See brz shelve --list).%(more)s')
2914
' (See bzr shelve --list).%(more)s')
2917
class MissingTemplateVariable(BzrError):
2919
_fmt = 'Variable {%(name)s} is not available.'
2921
def __init__(self, name):
2925
class NoTemplate(BzrError):
2927
_fmt = 'No template specified.'
2930
class UnableCreateSymlink(BzrError):
2932
_fmt = 'Unable to create symlink %(path_str)son this platform'
2934
def __init__(self, path=None):
2938
path_str = repr(str(path))
2939
except UnicodeEncodeError:
2940
path_str = repr(path)
2942
self.path_str = path_str
2945
class UnsupportedTimezoneFormat(BzrError):
2947
_fmt = ('Unsupported timezone format "%(timezone)s", '
2948
'options are "utc", "original", "local".')
2950
def __init__(self, timezone):
2951
self.timezone = timezone
2954
class CommandAvailableInPlugin(StandardError):
2956
internal_error = False
2958
def __init__(self, cmd_name, plugin_metadata, provider):
2960
self.plugin_metadata = plugin_metadata
2961
self.cmd_name = cmd_name
2962
self.provider = provider
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']))
2975
class NoPluginAvailable(BzrError):
2155
2979
class UnableEncodePath(BzrError):
2158
2982
'user encoding %(user_encoding)s')
2160
2984
def __init__(self, path, kind):
2161
from breezy.osutils import get_user_encoding
2985
from bzrlib.osutils import get_user_encoding
2162
2986
self.path = path
2163
2987
self.kind = kind
2164
2988
self.user_encoding = get_user_encoding()
2991
class NoSuchConfig(BzrError):
2993
_fmt = ('The "%(config_id)s" configuration does not exist.')
2995
def __init__(self, config_id):
2996
BzrError.__init__(self, config_id=config_id)
2999
class NoSuchConfigOption(BzrError):
3001
_fmt = ('The "%(option_name)s" configuration option does not exist.')
3003
def __init__(self, option_name):
3004
BzrError.__init__(self, option_name=option_name)
2167
3007
class NoSuchAlias(BzrError):
2169
3009
_fmt = ('The alias "%(alias_name)s" does not exist.')
2172
3012
BzrError.__init__(self, alias_name=alias_name)
3015
class DirectoryLookupFailure(BzrError):
3016
"""Base type for lookup errors."""
3021
class InvalidLocationAlias(DirectoryLookupFailure):
3023
_fmt = '"%(alias_name)s" is not a valid location alias.'
3025
def __init__(self, alias_name):
3026
DirectoryLookupFailure.__init__(self, alias_name=alias_name)
3029
class UnsetLocationAlias(DirectoryLookupFailure):
3031
_fmt = 'No %(alias_name)s location assigned.'
3033
def __init__(self, alias_name):
3034
DirectoryLookupFailure.__init__(self, alias_name=alias_name[1:])
2175
3037
class CannotBindAddress(BzrError):
2177
3039
_fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2179
3041
def __init__(self, host, port, orig_error):
2180
3042
# nb: in python2.4 socket.error doesn't have a useful repr
2181
3043
BzrError.__init__(self, host=host, port=port,
2182
orig_error=repr(orig_error.args))
3044
orig_error=repr(orig_error.args))
3047
class UnknownRules(BzrError):
3049
_fmt = ('Unknown rules detected: %(unknowns_str)s.')
3051
def __init__(self, unknowns):
3052
BzrError.__init__(self, unknowns_str=", ".join(unknowns))
2185
3055
class TipChangeRejected(BzrError):
3066
class ShelfCorrupt(BzrError):
3068
_fmt = "Shelf corrupt."
3071
class DecompressCorruption(BzrError):
3073
_fmt = "Corruption while decompressing repository file%(orig_error)s"
3075
def __init__(self, orig_error=None):
3076
if orig_error is not None:
3077
self.orig_error = ", %s" % (orig_error,)
3079
self.orig_error = ""
3080
BzrError.__init__(self)
3083
class NoSuchShelfId(BzrError):
3085
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3087
def __init__(self, shelf_id):
3088
BzrError.__init__(self, shelf_id=shelf_id)
3091
class InvalidShelfId(BzrError):
3093
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
3095
def __init__(self, invalid_id):
3096
BzrError.__init__(self, invalid_id=invalid_id)
2196
3099
class JailBreak(BzrError):
2198
3101
_fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
2206
3109
_fmt = 'The user aborted the operation.'
3112
class MustHaveWorkingTree(BzrError):
3114
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
3116
def __init__(self, format, url):
3117
BzrError.__init__(self, format=format, url=url)
3120
class NoSuchView(BzrError):
3121
"""A view does not exist.
3124
_fmt = u"No such view: %(view_name)s."
3126
def __init__(self, view_name):
3127
self.view_name = view_name
3130
class ViewsNotSupported(BzrError):
3131
"""Views are not supported by a tree format.
3134
_fmt = ("Views are not supported by %(tree)s;"
3135
" use 'bzr upgrade' to change your tree to a later format.")
3137
def __init__(self, tree):
3141
class FileOutsideView(BzrError):
3143
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3146
def __init__(self, file_name, view_files):
3147
self.file_name = file_name
3148
self.view_str = ", ".join(view_files)
2209
3151
class UnresumableWriteGroup(BzrError):
2211
3153
_fmt = ("Repository %(repository)s cannot resume write group "
2253
3195
self.target_branch = target_branch
3198
class FileTimestampUnavailable(BzrError):
3200
_fmt = "The filestamp for %(path)s is not available."
3202
internal_error = True
3204
def __init__(self, path):
2256
3208
class NoColocatedBranchSupport(BzrError):
2258
_fmt = ("%(controldir)r does not support co-located branches.")
2260
def __init__(self, controldir):
2261
self.controldir = controldir
3210
_fmt = ("%(bzrdir)r does not support co-located branches.")
3212
def __init__(self, bzrdir):
3213
self.bzrdir = bzrdir
3216
class NoWhoami(BzrError):
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>"')
3223
class InvalidPattern(BzrError):
3225
_fmt = ('Invalid pattern(s) found. %(msg)s')
3227
def __init__(self, msg):
2264
3231
class RecursiveBind(BzrError):
2266
3233
_fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2267
'Please use `brz unbind` to fix.')
3234
'Please use `bzr unbind` to fix.')
2269
3236
def __init__(self, branch_url):
2270
3237
self.branch_url = branch_url
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):
3244
_fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
3246
def __init__(self, string, refs):
3247
self.string = string
3248
self.refs = '->'.join(refs)
3251
class ExpandingUnknownOption(BzrError):
3253
_fmt = 'Option "%(name)s" is not defined while expanding "%(string)s".'
3255
def __init__(self, name, string):
3257
self.string = string
3260
class IllegalOptionName(BzrError):
3262
_fmt = 'Option "%(name)s" is not allowed.'
3264
def __init__(self, name):
3268
class NoCompatibleInter(BzrError):
3270
_fmt = ('No compatible object available for operations from %(source)r '
3273
def __init__(self, source, target):
3274
self.source = source
3275
self.target = target
3278
class HpssVfsRequestNotAllowed(BzrError):
3280
_fmt = ("VFS requests over the smart server are not allowed. Encountered: "
3281
"%(method)s, %(arguments)s.")
3283
def __init__(self, method, arguments):
3284
self.method = method
3285
self.arguments = arguments
2273
3288
class UnsupportedKindChange(BzrError):
2275
3290
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
2282
3297
self.format = format
2285
class ChangesAlreadyStored(CommandError):
3300
class MissingFeature(BzrError):
3302
_fmt = ("Missing feature %(feature)s not provided by this "
3303
"version of Bazaar or any plugin.")
3305
def __init__(self, feature):
3306
self.feature = feature
3309
class PatchSyntax(BzrError):
3310
"""Base class for patch syntax errors."""
3313
class BinaryFiles(BzrError):
3315
_fmt = 'Binary files section encountered.'
3317
def __init__(self, orig_name, mod_name):
3318
self.orig_name = orig_name
3319
self.mod_name = mod_name
3322
class MalformedPatchHeader(PatchSyntax):
3324
_fmt = "Malformed patch header. %(desc)s\n%(line)r"
3326
def __init__(self, desc, line):
3331
class MalformedHunkHeader(PatchSyntax):
3333
_fmt = "Malformed hunk header. %(desc)s\n%(line)r"
3335
def __init__(self, desc, line):
3340
class MalformedLine(PatchSyntax):
3342
_fmt = "Malformed line. %(desc)s\n%(line)r"
3344
def __init__(self, desc, line):
3349
class PatchConflict(BzrError):
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"')
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')
3360
class FeatureAlreadyRegistered(BzrError):
3362
_fmt = 'The feature %(feature)s has already been registered.'
3364
def __init__(self, feature):
3365
self.feature = feature
3368
class ChangesAlreadyStored(BzrCommandError):
2287
3370
_fmt = ('Cannot store uncommitted changes because this branch already'
2288
3371
' 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])