~jelmer/brz/bgt

« back to all changes in this revision

Viewing changes to breezy/errors.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
        BzrError.__init__(self, branch_url=public_location)
260
260
 
261
261
 
262
 
class NoHelpTopic(BzrError):
263
 
 
264
 
    _fmt = ("No help could be found for '%(topic)s'. "
265
 
        "Please use 'brz help topics' to obtain a list of topics.")
266
 
 
267
 
    def __init__(self, topic):
268
 
        self.topic = topic
269
 
 
270
 
 
271
262
class NoSuchId(BzrError):
272
263
 
273
264
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
351
342
        self.not_locked = not_locked
352
343
 
353
344
 
354
 
class BzrOptionError(BzrCommandError):
355
 
 
356
 
    _fmt = "Error in command line options"
357
 
 
358
 
 
359
345
class BadIndexFormatSignature(BzrError):
360
346
 
361
347
    _fmt = "%(value)s is not an index of type %(_type)s."
412
398
        self.value = value
413
399
 
414
400
 
415
 
class BadOptionValue(BzrError):
416
 
 
417
 
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
418
 
 
419
 
    def __init__(self, name, value):
420
 
        BzrError.__init__(self, name=name, value=value)
421
 
 
422
 
 
423
401
class StrictCommitFailed(BzrError):
424
402
 
425
403
    _fmt = "Commit refused because there are unknown files in the tree"
511
489
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
512
490
 
513
491
 
514
 
class InvalidURL(PathError):
515
 
 
516
 
    _fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
517
 
 
518
 
 
519
 
class InvalidURLJoin(PathError):
520
 
 
521
 
    _fmt = "Invalid URL join request: %(reason)s: %(base)r + %(join_args)r"
522
 
 
523
 
    def __init__(self, reason, base, join_args):
524
 
        self.reason = reason
525
 
        self.base = base
526
 
        self.join_args = join_args
527
 
        PathError.__init__(self, base, reason)
528
 
 
529
 
 
530
 
class InvalidRebaseURLs(PathError):
531
 
 
532
 
    _fmt = "URLs differ by more than path: %(from_)r and %(to)r"
533
 
 
534
 
    def __init__(self, from_, to):
535
 
        self.from_ = from_
536
 
        self.to = to
537
 
        PathError.__init__(self, from_, 'URLs differ by more than path.')
538
 
 
539
 
 
540
492
class UnavailableRepresentation(InternalBzrError):
541
493
 
542
494
    _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
1314
1266
        self.error = error
1315
1267
 
1316
1268
 
1317
 
class WeaveError(BzrError):
1318
 
 
1319
 
    _fmt = "Error in processing weave: %(msg)s"
1320
 
 
1321
 
    def __init__(self, msg=None):
1322
 
        BzrError.__init__(self)
1323
 
        self.msg = msg
1324
 
 
1325
 
 
1326
 
class WeaveRevisionAlreadyPresent(WeaveError):
1327
 
 
1328
 
    _fmt = "Revision {%(revision_id)s} already present in %(weave)s"
1329
 
 
1330
 
    def __init__(self, revision_id, weave):
1331
 
 
1332
 
        WeaveError.__init__(self)
1333
 
        self.revision_id = revision_id
1334
 
        self.weave = weave
1335
 
 
1336
 
 
1337
 
class WeaveRevisionNotPresent(WeaveError):
1338
 
 
1339
 
    _fmt = "Revision {%(revision_id)s} not present in %(weave)s"
1340
 
 
1341
 
    def __init__(self, revision_id, weave):
1342
 
        WeaveError.__init__(self)
1343
 
        self.revision_id = revision_id
1344
 
        self.weave = weave
1345
 
 
1346
 
 
1347
 
class WeaveFormatError(WeaveError):
1348
 
 
1349
 
    _fmt = "Weave invariant violated: %(what)s"
1350
 
 
1351
 
    def __init__(self, what):
1352
 
        WeaveError.__init__(self)
1353
 
        self.what = what
1354
 
 
1355
 
 
1356
 
class WeaveParentMismatch(WeaveError):
1357
 
 
1358
 
    _fmt = "Parents are mismatched between two revisions. %(msg)s"
1359
 
 
1360
 
 
1361
 
class WeaveInvalidChecksum(WeaveError):
1362
 
 
1363
 
    _fmt = "Text did not match its checksum: %(msg)s"
1364
 
 
1365
 
 
1366
 
class WeaveTextDiffers(WeaveError):
1367
 
 
1368
 
    _fmt = ("Weaves differ on text content. Revision:"
1369
 
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1370
 
 
1371
 
    def __init__(self, revision_id, weave_a, weave_b):
1372
 
        WeaveError.__init__(self)
1373
 
        self.revision_id = revision_id
1374
 
        self.weave_a = weave_a
1375
 
        self.weave_b = weave_b
1376
 
 
1377
 
 
1378
 
class WeaveTextDiffers(WeaveError):
1379
 
 
1380
 
    _fmt = ("Weaves differ on text content. Revision:"
1381
 
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1382
 
 
1383
 
    def __init__(self, revision_id, weave_a, weave_b):
1384
 
        WeaveError.__init__(self)
1385
 
        self.revision_id = revision_id
1386
 
        self.weave_a = weave_a
1387
 
        self.weave_b = weave_b
1388
 
 
1389
 
 
1390
1269
class VersionedFileError(BzrError):
1391
1270
 
1392
1271
    _fmt = "Versioned file error"
1734
1613
    _fmt = "Working tree has conflicts."
1735
1614
 
1736
1615
 
1737
 
class ConfigContentError(BzrError):
1738
 
 
1739
 
    _fmt = "Config file %(filename)s is not UTF-8 encoded\n"
1740
 
 
1741
 
    def __init__(self, filename):
1742
 
        BzrError.__init__(self)
1743
 
        self.filename = filename
1744
 
 
1745
 
 
1746
 
class ParseConfigError(BzrError):
1747
 
 
1748
 
    _fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
1749
 
 
1750
 
    def __init__(self, errors, filename):
1751
 
        BzrError.__init__(self)
1752
 
        self.filename = filename
1753
 
        self.errors = '\n'.join(e.msg for e in errors)
1754
 
 
1755
 
 
1756
 
class ConfigOptionValueError(BzrError):
1757
 
 
1758
 
    _fmt = ('Bad value "%(value)s" for option "%(name)s".\n'
1759
 
            'See ``brz help %(name)s``')
1760
 
 
1761
 
    def __init__(self, name, value):
1762
 
        BzrError.__init__(self, name=name, value=value)
1763
 
 
1764
 
 
1765
 
class NoEmailInUsername(BzrError):
1766
 
 
1767
 
    _fmt = "%(username)r does not seem to contain a reasonable email address"
1768
 
 
1769
 
    def __init__(self, username):
1770
 
        BzrError.__init__(self)
1771
 
        self.username = username
1772
 
 
1773
 
 
1774
 
class SigningFailed(BzrError):
1775
 
 
1776
 
    _fmt = 'Failed to GPG sign data with command "%(command_line)s"'
1777
 
 
1778
 
    def __init__(self, command_line):
1779
 
        BzrError.__init__(self, command_line=command_line)
1780
 
 
1781
 
 
1782
 
class SignatureVerificationFailed(BzrError):
1783
 
 
1784
 
    _fmt = 'Failed to verify GPG signature data with error "%(error)s"'
1785
 
 
1786
 
    def __init__(self, error):
1787
 
        BzrError.__init__(self, error=error)
1788
 
 
1789
 
 
1790
1616
class DependencyNotPresent(BzrError):
1791
1617
 
1792
1618
    _fmt = 'Unable to import library "%(library)s": %(error)s'
1795
1621
        BzrError.__init__(self, library=library, error=error)
1796
1622
 
1797
1623
 
1798
 
class GpgmeNotInstalled(DependencyNotPresent):
1799
 
 
1800
 
    _fmt = 'python-gpgme is not installed, it is needed to verify signatures'
1801
 
 
1802
 
    def __init__(self, error):
1803
 
        DependencyNotPresent.__init__(self, 'gpgme', error)
1804
 
 
1805
 
 
1806
1624
class WorkingTreeNotRevision(BzrError):
1807
1625
 
1808
1626
    _fmt = ("The working tree for %(basedir)s has changed since"
2582
2400
        self.tag_name = tag_name
2583
2401
 
2584
2402
 
2585
 
class MalformedBugIdentifier(BzrError):
2586
 
 
2587
 
    _fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2588
 
            'See "brz help bugs" for more information on this feature.')
2589
 
 
2590
 
    def __init__(self, bug_id, reason):
2591
 
        self.bug_id = bug_id
2592
 
        self.reason = reason
2593
 
 
2594
 
 
2595
 
class InvalidBugTrackerURL(BzrError):
2596
 
 
2597
 
    _fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
2598
 
            "contain {id}: %(url)s")
2599
 
 
2600
 
    def __init__(self, abbreviation, url):
2601
 
        self.abbreviation = abbreviation
2602
 
        self.url = url
2603
 
 
2604
 
 
2605
 
class UnknownBugTrackerAbbreviation(BzrError):
2606
 
 
2607
 
    _fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
2608
 
            "on %(branch)s")
2609
 
 
2610
 
    def __init__(self, abbreviation, branch):
2611
 
        self.abbreviation = abbreviation
2612
 
        self.branch = branch
2613
 
 
2614
 
 
2615
 
class InvalidLineInBugsProperty(BzrError):
2616
 
 
2617
 
    _fmt = ("Invalid line in bugs property: '%(line)s'")
2618
 
 
2619
 
    def __init__(self, line):
2620
 
        self.line = line
2621
 
 
2622
 
 
2623
 
class InvalidBugStatus(BzrError):
2624
 
 
2625
 
    _fmt = ("Invalid bug status: '%(status)s'")
2626
 
 
2627
 
    def __init__(self, status):
2628
 
        self.status = status
2629
 
 
2630
 
 
2631
2403
class UnexpectedSmartServerResponse(BzrError):
2632
2404
 
2633
2405
    _fmt = "Could not understand response from smart server: %(response_tuple)r"
2973
2745
        self.user_encoding = get_user_encoding()
2974
2746
 
2975
2747
 
2976
 
class NoSuchConfig(BzrError):
2977
 
 
2978
 
    _fmt = ('The "%(config_id)s" configuration does not exist.')
2979
 
 
2980
 
    def __init__(self, config_id):
2981
 
        BzrError.__init__(self, config_id=config_id)
2982
 
 
2983
 
 
2984
 
class NoSuchConfigOption(BzrError):
2985
 
 
2986
 
    _fmt = ('The "%(option_name)s" configuration option does not exist.')
2987
 
 
2988
 
    def __init__(self, option_name):
2989
 
        BzrError.__init__(self, option_name=option_name)
2990
 
 
2991
 
 
2992
2748
class NoSuchAlias(BzrError):
2993
2749
 
2994
2750
    _fmt = ('The alias "%(alias_name)s" does not exist.')
3180
2936
        self.target_branch = target_branch
3181
2937
 
3182
2938
 
3183
 
class FileTimestampUnavailable(BzrError):
3184
 
 
3185
 
    _fmt = "The filestamp for %(path)s is not available."
3186
 
 
3187
 
    internal_error = True
3188
 
 
3189
 
    def __init__(self, path):
3190
 
        self.path = path
3191
 
 
3192
 
 
3193
2939
class NoColocatedBranchSupport(BzrError):
3194
2940
 
3195
2941
    _fmt = ("%(controldir)r does not support co-located branches.")
3198
2944
        self.controldir = controldir
3199
2945
 
3200
2946
 
3201
 
class NoWhoami(BzrError):
3202
 
 
3203
 
    _fmt = ('Unable to determine your name.\n'
3204
 
        "Please, set your name with the 'whoami' command.\n"
3205
 
        'E.g. brz whoami "Your Name <name@example.com>"')
3206
 
 
3207
 
 
3208
 
class InvalidPattern(BzrError):
3209
 
 
3210
 
    _fmt = ('Invalid pattern(s) found. %(msg)s')
3211
 
 
3212
 
    def __init__(self, msg):
3213
 
        self.msg = msg
3214
 
 
3215
 
 
3216
2947
class RecursiveBind(BzrError):
3217
2948
 
3218
2949
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3222
2953
        self.branch_url = branch_url
3223
2954
 
3224
2955
 
3225
 
# FIXME: I would prefer to define the config related exception classes in
3226
 
# config.py but the lazy import mechanism proscribes this -- vila 20101222
3227
 
class OptionExpansionLoop(BzrError):
3228
 
 
3229
 
    _fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
3230
 
 
3231
 
    def __init__(self, string, refs):
3232
 
        self.string = string
3233
 
        self.refs = '->'.join(refs)
3234
 
 
3235
 
 
3236
 
class ExpandingUnknownOption(BzrError):
3237
 
 
3238
 
    _fmt = 'Option "%(name)s" is not defined while expanding "%(string)s".'
3239
 
 
3240
 
    def __init__(self, name, string):
3241
 
        self.name = name
3242
 
        self.string = string
3243
 
 
3244
 
 
3245
 
class IllegalOptionName(BzrError):
3246
 
 
3247
 
    _fmt = 'Option "%(name)s" is not allowed.'
3248
 
 
3249
 
    def __init__(self, name):
3250
 
        self.name = name
3251
 
 
3252
 
 
3253
 
class NoCompatibleInter(BzrError):
3254
 
 
3255
 
    _fmt = ('No compatible object available for operations from %(source)r '
3256
 
            'to %(target)r.')
3257
 
 
3258
 
    def __init__(self, source, target):
3259
 
        self.source = source
3260
 
        self.target = target
3261
 
 
3262
 
 
3263
2956
class HpssVfsRequestNotAllowed(BzrError):
3264
2957
 
3265
2958
    _fmt = ("VFS requests over the smart server are not allowed. Encountered: "
3282
2975
        self.format = format
3283
2976
 
3284
2977
 
3285
 
class MissingFeature(BzrError):
3286
 
 
3287
 
    _fmt = ("Missing feature %(feature)s not provided by this "
3288
 
            "version of Bazaar or any plugin.")
3289
 
 
3290
 
    def __init__(self, feature):
3291
 
        self.feature = feature
3292
 
 
3293
 
 
3294
 
class PatchSyntax(BzrError):
3295
 
    """Base class for patch syntax errors."""
3296
 
 
3297
 
 
3298
 
class BinaryFiles(BzrError):
3299
 
 
3300
 
    _fmt = 'Binary files section encountered.'
3301
 
 
3302
 
    def __init__(self, orig_name, mod_name):
3303
 
        self.orig_name = orig_name
3304
 
        self.mod_name = mod_name
3305
 
 
3306
 
 
3307
 
class MalformedPatchHeader(PatchSyntax):
3308
 
 
3309
 
    _fmt = "Malformed patch header.  %(desc)s\n%(line)r"
3310
 
 
3311
 
    def __init__(self, desc, line):
3312
 
        self.desc = desc
3313
 
        self.line = line
3314
 
 
3315
 
 
3316
 
class MalformedHunkHeader(PatchSyntax):
3317
 
 
3318
 
    _fmt = "Malformed hunk header.  %(desc)s\n%(line)r"
3319
 
 
3320
 
    def __init__(self, desc, line):
3321
 
        self.desc = desc
3322
 
        self.line = line
3323
 
 
3324
 
 
3325
 
class MalformedLine(PatchSyntax):
3326
 
 
3327
 
    _fmt = "Malformed line.  %(desc)s\n%(line)r"
3328
 
 
3329
 
    def __init__(self, desc, line):
3330
 
        self.desc = desc
3331
 
        self.line = line
3332
 
 
3333
 
 
3334
 
class PatchConflict(BzrError):
3335
 
 
3336
 
    _fmt = ('Text contents mismatch at line %(line_no)d.  Original has '
3337
 
            '"%(orig_line)s", but patch says it should be "%(patch_line)s"')
3338
 
 
3339
 
    def __init__(self, line_no, orig_line, patch_line):
3340
 
        self.line_no = line_no
3341
 
        self.orig_line = orig_line.rstrip('\n')
3342
 
        self.patch_line = patch_line.rstrip('\n')
3343
 
 
3344
 
 
3345
2978
class FeatureAlreadyRegistered(BzrError):
3346
2979
 
3347
2980
    _fmt = 'The feature %(feature)s has already been registered.'