~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Vincent Ladeuil
  • Date: 2009-07-02 13:07:14 UTC
  • mto: (4524.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4525.
  • Revision ID: v.ladeuil+lp@free.fr-20090702130714-hsyqfusi8vn3a11m
Use tree.has_changes() where appropriate (the test suite caught a
bug in has_changes() (not filtering out the root) in an impressive
number of tests)

* bzrlib/send.py:
(send): Use tree.has_changes() instead of tree.changes_from().

* bzrlib/reconfigure.py:
(Reconfigure._check): Use tree.has_changes() instead of
tree.changes_from().

* bzrlib/merge.py:
(Merger.ensure_revision_trees, Merger.compare_basis): Use
tree.has_changes() instead of tree.changes_from().

* bzrlib/builtins.py:
(cmd_remove_tree.run, cmd_push.run, cmd_merge.run): Use
tree.has_changes() instead of tree.changes_from().

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Exceptions for bzr, and reporting of them.
18
18
"""
31
31
 
32
32
 
33
33
# TODO: is there any value in providing the .args field used by standard
34
 
# python exceptions?   A list of values with no names seems less useful 
 
34
# python exceptions?   A list of values with no names seems less useful
35
35
# to me.
36
36
 
37
 
# TODO: Perhaps convert the exception to a string at the moment it's 
 
37
# TODO: Perhaps convert the exception to a string at the moment it's
38
38
# constructed to make sure it will succeed.  But that says nothing about
39
39
# exceptions that are never raised.
40
40
 
61
61
    :cvar _fmt: Format string to display the error; this is expanded
62
62
    by the instance's dict.
63
63
    """
64
 
    
 
64
 
65
65
    internal_error = False
66
66
 
67
67
    def __init__(self, msg=None, **kwds):
72
72
        arguments can be given.  The first is for generic "user" errors which
73
73
        are not intended to be caught and so do not need a specific subclass.
74
74
        The second case is for use with subclasses that provide a _fmt format
75
 
        string to print the arguments.  
 
75
        string to print the arguments.
76
76
 
77
 
        Keyword arguments are taken as parameters to the error, which can 
78
 
        be inserted into the format string template.  It's recommended 
79
 
        that subclasses override the __init__ method to require specific 
 
77
        Keyword arguments are taken as parameters to the error, which can
 
78
        be inserted into the format string template.  It's recommended
 
79
        that subclasses override the __init__ method to require specific
80
80
        parameters.
81
81
 
82
82
        :param msg: If given, this is the literal complete text for the error,
154
154
               )
155
155
 
156
156
    def __eq__(self, other):
157
 
        if self.__class__ != other.__class__:
 
157
        if self.__class__ is not other.__class__:
158
158
            return NotImplemented
159
159
        return self.__dict__ == other.__dict__
160
160
 
265
265
 
266
266
 
267
267
class InvalidEntryName(InternalBzrError):
268
 
    
 
268
 
269
269
    _fmt = "Invalid entry name: %(name)s"
270
270
 
271
271
    def __init__(self, name):
274
274
 
275
275
 
276
276
class InvalidRevisionNumber(BzrError):
277
 
    
 
277
 
278
278
    _fmt = "Invalid revision number %(revno)s"
279
279
 
280
280
    def __init__(self, revno):
329
329
class NoSuchId(BzrError):
330
330
 
331
331
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
332
 
    
 
332
 
333
333
    def __init__(self, tree, file_id):
334
334
        BzrError.__init__(self)
335
335
        self.file_id = file_id
362
362
class NoWorkingTree(BzrError):
363
363
 
364
364
    _fmt = 'No WorkingTree exists for "%(base)s".'
365
 
    
 
365
 
366
366
    def __init__(self, base):
367
367
        BzrError.__init__(self)
368
368
        self.base = base
477
477
    def __init__(self, name, value):
478
478
        BzrError.__init__(self, name=name, value=value)
479
479
 
480
 
    
 
480
 
481
481
class StrictCommitFailed(BzrError):
482
482
 
483
483
    _fmt = "Commit refused because there are unknown files in the tree"
486
486
# XXX: Should be unified with TransportError; they seem to represent the
487
487
# same thing
488
488
# RBC 20060929: I think that unifiying with TransportError would be a mistake
489
 
# - this is finer than a TransportError - and more useful as such. It 
 
489
# - this is finer than a TransportError - and more useful as such. It
490
490
# differentiates between 'transport has failed' and 'operation on a transport
491
491
# has failed.'
492
492
class PathError(BzrError):
493
 
    
 
493
 
494
494
    _fmt = "Generic path error: %(path)r%(extra)s)"
495
495
 
496
496
    def __init__(self, path, extra=None):
550
550
 
551
551
 
552
552
class ReadingCompleted(InternalBzrError):
553
 
    
 
553
 
554
554
    _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
555
555
            "called upon it - the request has been completed and no more "
556
556
            "data may be read.")
636
636
        self.url = url
637
637
 
638
638
 
 
639
class UnstackableLocationError(BzrError):
 
640
 
 
641
    _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
 
642
 
 
643
    def __init__(self, branch_url, target_url):
 
644
        BzrError.__init__(self)
 
645
        self.branch_url = branch_url
 
646
        self.target_url = target_url
 
647
 
 
648
 
639
649
class UnstackableRepositoryFormat(BzrError):
640
650
 
641
651
    _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
648
658
 
649
659
 
650
660
class ReadError(PathError):
651
 
    
 
661
 
652
662
    _fmt = """Error reading from %(path)r."""
653
663
 
654
664
 
689
699
 
690
700
# TODO: This is given a URL; we try to unescape it but doing that from inside
691
701
# the exception object is a bit undesirable.
692
 
# TODO: Probably this behavior of should be a common superclass 
 
702
# TODO: Probably this behavior of should be a common superclass
693
703
class NotBranchError(PathError):
694
704
 
695
705
    _fmt = 'Not a branch: "%(path)s".'
764
774
 
765
775
 
766
776
class UnknownFormatError(BzrError):
767
 
    
 
777
 
768
778
    _fmt = "Unknown %(kind)s format: %(format)r"
769
779
 
770
780
    def __init__(self, format, kind='branch'):
773
783
 
774
784
 
775
785
class IncompatibleFormat(BzrError):
776
 
    
 
786
 
777
787
    _fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
778
788
 
779
789
    def __init__(self, format, bzrdir_format):
796
806
 
797
807
 
798
808
class IncompatibleRevision(BzrError):
799
 
    
 
809
 
800
810
    _fmt = "Revision is not compatible with %(repo_format)s"
801
811
 
802
812
    def __init__(self, repo_format):
1003
1013
 
1004
1014
class LockContention(LockError):
1005
1015
 
1006
 
    _fmt = 'Could not acquire lock "%(lock)s"'
 
1016
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
1007
1017
    # TODO: show full url for lock, combining the transport and relative
1008
1018
    # bits?
1009
1019
 
1010
1020
    internal_error = False
1011
1021
 
1012
 
    def __init__(self, lock):
 
1022
    def __init__(self, lock, msg=''):
1013
1023
        self.lock = lock
 
1024
        self.msg = msg
1014
1025
 
1015
1026
 
1016
1027
class LockBroken(LockError):
1130
1141
 
1131
1142
class NoSuchRevisionInTree(NoSuchRevision):
1132
1143
    """When using Tree.revision_tree, and the revision is not accessible."""
1133
 
    
 
1144
 
1134
1145
    _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
1135
1146
 
1136
1147
    def __init__(self, tree, revision_id):
1172
1183
class DivergedBranches(BzrError):
1173
1184
 
1174
1185
    _fmt = ("These branches have diverged."
1175
 
            " Use the merge command to reconcile them.")
 
1186
            " Use the missing command to see how.\n"
 
1187
            "Use the merge command to reconcile them.")
1176
1188
 
1177
1189
    def __init__(self, branch1, branch2):
1178
1190
        self.branch1 = branch1
1200
1212
 
1201
1213
 
1202
1214
class NoCommonAncestor(BzrError):
1203
 
    
 
1215
 
1204
1216
    _fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1205
1217
 
1206
1218
    def __init__(self, revision_a, revision_b):
1226
1238
            not_ancestor_id=not_ancestor_id)
1227
1239
 
1228
1240
 
1229
 
class InstallFailed(BzrError):
1230
 
 
1231
 
    def __init__(self, revisions):
1232
 
        revision_str = ", ".join(str(r) for r in revisions)
1233
 
        msg = "Could not install revisions:\n%s" % revision_str
1234
 
        BzrError.__init__(self, msg)
1235
 
        self.revisions = revisions
1236
 
 
1237
 
 
1238
1241
class AmbiguousBase(BzrError):
1239
1242
 
1240
1243
    def __init__(self, bases):
1274
1277
        self.branch = branch
1275
1278
        self.master = master
1276
1279
 
1277
 
        
 
1280
 
1278
1281
class CommitToDoubleBoundBranch(BzrError):
1279
1282
 
1280
1283
    _fmt = ("Cannot commit to branch %(branch)s."
1350
1353
class WeaveParentMismatch(WeaveError):
1351
1354
 
1352
1355
    _fmt = "Parents are mismatched between two revisions. %(message)s"
1353
 
    
 
1356
 
1354
1357
 
1355
1358
class WeaveInvalidChecksum(WeaveError):
1356
1359
 
1382
1385
 
1383
1386
 
1384
1387
class VersionedFileError(BzrError):
1385
 
    
 
1388
 
1386
1389
    _fmt = "Versioned file error"
1387
1390
 
1388
1391
 
1389
1392
class RevisionNotPresent(VersionedFileError):
1390
 
    
 
1393
 
1391
1394
    _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1392
1395
 
1393
1396
    def __init__(self, revision_id, file_id):
1397
1400
 
1398
1401
 
1399
1402
class RevisionAlreadyPresent(VersionedFileError):
1400
 
    
 
1403
 
1401
1404
    _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1402
1405
 
1403
1406
    def __init__(self, revision_id, file_id):
1412
1415
 
1413
1416
 
1414
1417
class KnitError(InternalBzrError):
1415
 
    
 
1418
 
1416
1419
    _fmt = "Knit error"
1417
1420
 
1418
1421
 
1450
1453
    def __init__(self, stream_format, target_format):
1451
1454
        self.stream_format = stream_format
1452
1455
        self.target_format = target_format
1453
 
        
 
1456
 
1454
1457
 
1455
1458
class KnitDataStreamUnknown(KnitError):
1456
1459
    # Indicates a data stream we don't know how to handle.
1459
1462
 
1460
1463
    def __init__(self, stream_format):
1461
1464
        self.stream_format = stream_format
1462
 
        
 
1465
 
1463
1466
 
1464
1467
class KnitHeaderError(KnitError):
1465
1468
 
1475
1478
 
1476
1479
    Currently only 'fulltext' and 'line-delta' are supported.
1477
1480
    """
1478
 
    
 
1481
 
1479
1482
    _fmt = ("Knit index %(filename)s does not have a known method"
1480
1483
            " in options: %(options)r")
1481
1484
 
1532
1535
 
1533
1536
 
1534
1537
class NoSuchExportFormat(BzrError):
1535
 
    
 
1538
 
1536
1539
    _fmt = "Export format %(format)r not supported"
1537
1540
 
1538
1541
    def __init__(self, format):
1541
1544
 
1542
1545
 
1543
1546
class TransportError(BzrError):
1544
 
    
 
1547
 
1545
1548
    _fmt = "Transport error: %(msg)s %(orig_error)s"
1546
1549
 
1547
1550
    def __init__(self, msg=None, orig_error=None):
1634
1637
            self.port = ':%s' % port
1635
1638
 
1636
1639
 
 
1640
# XXX: This is also used for unexpected end of file, which is different at the
 
1641
# TCP level from "connection reset".
1637
1642
class ConnectionReset(TransportError):
1638
1643
 
1639
1644
    _fmt = "Connection closed: %(msg)s %(orig_error)s"
1729
1734
 
1730
1735
class WorkingTreeNotRevision(BzrError):
1731
1736
 
1732
 
    _fmt = ("The working tree for %(basedir)s has changed since" 
 
1737
    _fmt = ("The working tree for %(basedir)s has changed since"
1733
1738
            " the last commit, but weave merge requires that it be"
1734
1739
            " unchanged")
1735
1740
 
2049
2054
    _fmt = """This tree contains left-over files from a failed operation.
2050
2055
    Please examine %(limbo_dir)s to see if it contains any files you wish to
2051
2056
    keep, and delete it when you are done."""
2052
 
    
 
2057
 
2053
2058
    def __init__(self, limbo_dir):
2054
2059
       BzrError.__init__(self)
2055
2060
       self.limbo_dir = limbo_dir
2088
2093
 
2089
2094
class OutOfDateTree(BzrError):
2090
2095
 
2091
 
    _fmt = "Working tree is out of date, please run 'bzr update'."
 
2096
    _fmt = "Working tree is out of date, please run 'bzr update'.%(more)s"
2092
2097
 
2093
 
    def __init__(self, tree):
 
2098
    def __init__(self, tree, more=None):
 
2099
        if more is None:
 
2100
            more = ''
 
2101
        else:
 
2102
            more = ' ' + more
2094
2103
        BzrError.__init__(self)
2095
2104
        self.tree = tree
 
2105
        self.more = more
2096
2106
 
2097
2107
 
2098
2108
class PublicBranchOutOfDate(BzrError):
2166
2176
    _fmt = "To use this feature you must upgrade your repository at %(path)s."
2167
2177
 
2168
2178
 
 
2179
class RichRootUpgradeRequired(UpgradeRequired):
 
2180
 
 
2181
    _fmt = ("To use this feature you must upgrade your branch at %(path)s to"
 
2182
           " a format which supports rich roots.")
 
2183
 
 
2184
 
2169
2185
class LocalRequiresBoundBranch(BzrError):
2170
2186
 
2171
2187
    _fmt = "Cannot perform local-only commits on unbound branches."
2172
2188
 
2173
2189
 
2174
 
class InvalidProgressBarType(BzrError):
2175
 
 
2176
 
    _fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
2177
 
            " is not a supported type Select one of: %(valid_types)s")
2178
 
 
2179
 
    def __init__(self, bar_type, valid_types):
2180
 
        BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
2181
 
 
2182
 
 
2183
2190
class UnsupportedOperation(BzrError):
2184
2191
 
2185
2192
    _fmt = ("The method %(mname)s is not supported on"
2202
2209
 
2203
2210
 
2204
2211
class BinaryFile(BzrError):
2205
 
    
 
2212
 
2206
2213
    _fmt = "File is binary but should be text."
2207
2214
 
2208
2215
 
2228
2235
 
2229
2236
 
2230
2237
class NotABundle(BzrError):
2231
 
    
 
2238
 
2232
2239
    _fmt = "Not a bzr revision-bundle: %(text)r"
2233
2240
 
2234
2241
    def __init__(self, text):
2236
2243
        self.text = text
2237
2244
 
2238
2245
 
2239
 
class BadBundle(BzrError): 
2240
 
    
 
2246
class BadBundle(BzrError):
 
2247
 
2241
2248
    _fmt = "Bad bzr revision-bundle: %(text)r"
2242
2249
 
2243
2250
    def __init__(self, text):
2245
2252
        self.text = text
2246
2253
 
2247
2254
 
2248
 
class MalformedHeader(BadBundle): 
2249
 
    
 
2255
class MalformedHeader(BadBundle):
 
2256
 
2250
2257
    _fmt = "Malformed bzr revision-bundle header: %(text)r"
2251
2258
 
2252
2259
 
2253
 
class MalformedPatches(BadBundle): 
2254
 
    
 
2260
class MalformedPatches(BadBundle):
 
2261
 
2255
2262
    _fmt = "Malformed patches in bzr revision-bundle: %(text)r"
2256
2263
 
2257
2264
 
2258
 
class MalformedFooter(BadBundle): 
2259
 
    
 
2265
class MalformedFooter(BadBundle):
 
2266
 
2260
2267
    _fmt = "Malformed footer in bzr revision-bundle: %(text)r"
2261
2268
 
2262
2269
 
2263
2270
class UnsupportedEOLMarker(BadBundle):
2264
 
    
2265
 
    _fmt = "End of line marker was not \\n in bzr revision-bundle"    
 
2271
 
 
2272
    _fmt = "End of line marker was not \\n in bzr revision-bundle"
2266
2273
 
2267
2274
    def __init__(self):
2268
 
        # XXX: BadBundle's constructor assumes there's explanatory text, 
 
2275
        # XXX: BadBundle's constructor assumes there's explanatory text,
2269
2276
        # but for this there is not
2270
2277
        BzrError.__init__(self)
2271
2278
 
2272
2279
 
2273
2280
class IncompatibleBundleFormat(BzrError):
2274
 
    
 
2281
 
2275
2282
    _fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
2276
2283
 
2277
2284
    def __init__(self, bundle_format, other):
2281
2288
 
2282
2289
 
2283
2290
class BadInventoryFormat(BzrError):
2284
 
    
 
2291
 
2285
2292
    _fmt = "Root class for inventory serialization errors"
2286
2293
 
2287
2294
 
2306
2313
        self.transport = transport
2307
2314
 
2308
2315
 
2309
 
class NoSmartServer(NotBranchError):
2310
 
 
2311
 
    _fmt = "No smart server available at %(url)s"
2312
 
 
2313
 
    @symbol_versioning.deprecated_method(symbol_versioning.one_four)
2314
 
    def __init__(self, url):
2315
 
        self.url = url
2316
 
 
2317
 
 
2318
2316
class UnknownSSH(BzrError):
2319
2317
 
2320
2318
    _fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
2340
2338
        self.revision_id = revision_id
2341
2339
        self.ghost_revision_id = ghost_revision_id
2342
2340
 
2343
 
        
 
2341
 
2344
2342
class GhostRevisionUnusableHere(BzrError):
2345
2343
 
2346
2344
    _fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2438
2436
 
2439
2437
 
2440
2438
class UnsupportedInventoryKind(BzrError):
2441
 
    
 
2439
 
2442
2440
    _fmt = """Unsupported entry kind %(kind)s"""
2443
2441
 
2444
2442
    def __init__(self, kind):
2456
2454
 
2457
2455
 
2458
2456
class SubsumeTargetNeedsUpgrade(BzrError):
2459
 
    
 
2457
 
2460
2458
    _fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2461
2459
 
2462
2460
    def __init__(self, other_tree):
2490
2488
    def __init__(self, branch):
2491
2489
        self.branch = branch
2492
2490
 
2493
 
        
 
2491
 
2494
2492
class TagAlreadyExists(BzrError):
2495
2493
 
2496
2494
    _fmt = "Tag %(tag_name)s already exists."
2501
2499
 
2502
2500
class MalformedBugIdentifier(BzrError):
2503
2501
 
2504
 
    _fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
 
2502
    _fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
 
2503
            'See "bzr help bugs" for more information on this feature.')
2505
2504
 
2506
2505
    def __init__(self, bug_id, reason):
2507
2506
        self.bug_id = bug_id
2528
2527
        self.branch = branch
2529
2528
 
2530
2529
 
 
2530
class InvalidLineInBugsProperty(BzrError):
 
2531
 
 
2532
    _fmt = ("Invalid line in bugs property: '%(line)s'")
 
2533
 
 
2534
    def __init__(self, line):
 
2535
        self.line = line
 
2536
 
 
2537
 
 
2538
class InvalidBugStatus(BzrError):
 
2539
 
 
2540
    _fmt = ("Invalid bug status: '%(status)s'")
 
2541
 
 
2542
    def __init__(self, status):
 
2543
        self.status = status
 
2544
 
 
2545
 
2531
2546
class UnexpectedSmartServerResponse(BzrError):
2532
2547
 
2533
2548
    _fmt = "Could not understand response from smart server: %(response_tuple)r"
2579
2594
        """
2580
2595
        self.error_from_smart_server = error_from_smart_server
2581
2596
        self.error_tuple = error_from_smart_server.error_tuple
2582
 
        
 
2597
 
2583
2598
 
2584
2599
class ContainerError(BzrError):
2585
2600
    """Base class of container errors."""
2588
2603
class UnknownContainerFormatError(ContainerError):
2589
2604
 
2590
2605
    _fmt = "Unrecognised container format: %(container_format)r"
2591
 
    
 
2606
 
2592
2607
    def __init__(self, container_format):
2593
2608
        self.container_format = container_format
2594
2609
 
2768
2783
 
2769
2784
class UncommittedChanges(BzrError):
2770
2785
 
2771
 
    _fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
 
2786
    _fmt = ('Working tree "%(display_url)s" has uncommitted changes'
 
2787
            ' (See bzr status).%(more)s')
2772
2788
 
2773
 
    def __init__(self, tree):
 
2789
    def __init__(self, tree, more=None):
 
2790
        if more is None:
 
2791
            more = ''
 
2792
        else:
 
2793
            more = ' ' + more
2774
2794
        import bzrlib.urlutils as urlutils
2775
2795
        display_url = urlutils.unescape_for_display(
2776
2796
            tree.bzrdir.root_transport.base, 'ascii')
2777
 
        BzrError.__init__(self, tree=tree, display_url=display_url)
 
2797
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2778
2798
 
2779
2799
 
2780
2800
class MissingTemplateVariable(BzrError):
2815
2835
 
2816
2836
 
2817
2837
class CommandAvailableInPlugin(StandardError):
2818
 
    
 
2838
 
2819
2839
    internal_error = False
2820
2840
 
2821
2841
    def __init__(self, cmd_name, plugin_metadata, provider):
2822
 
        
 
2842
 
2823
2843
        self.plugin_metadata = plugin_metadata
2824
2844
        self.cmd_name = cmd_name
2825
2845
        self.provider = provider
2826
2846
 
2827
2847
    def __str__(self):
2828
2848
 
2829
 
        _fmt = ('"%s" is not a standard bzr command. \n' 
 
2849
        _fmt = ('"%s" is not a standard bzr command. \n'
2830
2850
                'However, the following official plugin provides this command: %s\n'
2831
2851
                'You can install it by going to: %s'
2832
 
                % (self.cmd_name, self.plugin_metadata['name'], 
 
2852
                % (self.cmd_name, self.plugin_metadata['name'],
2833
2853
                    self.plugin_metadata['url']))
2834
2854
 
2835
2855
        return _fmt
2836
2856
 
2837
2857
 
2838
2858
class NoPluginAvailable(BzrError):
2839
 
    pass    
2840
 
 
2841
 
 
2842
 
class NotATerminal(BzrError):
2843
 
 
2844
 
    _fmt = 'Unable to ask for a password without real terminal.'
 
2859
    pass
2845
2860
 
2846
2861
 
2847
2862
class UnableEncodePath(BzrError):
2926
2941
    """A pre_change_branch_tip hook function may raise this to cleanly and
2927
2942
    explicitly abort a change to a branch tip.
2928
2943
    """
2929
 
    
 
2944
 
2930
2945
    _fmt = u"Tip change rejected: %(msg)s"
2931
2946
 
2932
2947
    def __init__(self, msg):
2954
2969
        BzrError.__init__(self, invalid_id=invalid_id)
2955
2970
 
2956
2971
 
 
2972
class JailBreak(BzrError):
 
2973
 
 
2974
    _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
 
2975
 
 
2976
    def __init__(self, url):
 
2977
        BzrError.__init__(self, url=url)
 
2978
 
 
2979
 
2957
2980
class UserAbort(BzrError):
2958
2981
 
2959
2982
    _fmt = 'The user aborted the operation.'
2965
2988
 
2966
2989
    def __init__(self, format, url):
2967
2990
        BzrError.__init__(self, format=format, url=url)
 
2991
 
 
2992
 
 
2993
class NoSuchView(BzrError):
 
2994
    """A view does not exist.
 
2995
    """
 
2996
 
 
2997
    _fmt = u"No such view: %(view_name)s."
 
2998
 
 
2999
    def __init__(self, view_name):
 
3000
        self.view_name = view_name
 
3001
 
 
3002
 
 
3003
class ViewsNotSupported(BzrError):
 
3004
    """Views are not supported by a tree format.
 
3005
    """
 
3006
 
 
3007
    _fmt = ("Views are not supported by %(tree)s;"
 
3008
            " use 'bzr upgrade' to change your tree to a later format.")
 
3009
 
 
3010
    def __init__(self, tree):
 
3011
        self.tree = tree
 
3012
 
 
3013
 
 
3014
class FileOutsideView(BzrError):
 
3015
 
 
3016
    _fmt = ('Specified file "%(file_name)s" is outside the current view: '
 
3017
            '%(view_str)s')
 
3018
 
 
3019
    def __init__(self, file_name, view_files):
 
3020
        self.file_name = file_name
 
3021
        self.view_str = ", ".join(view_files)
 
3022
 
 
3023
 
 
3024
class UnresumableWriteGroup(BzrError):
 
3025
 
 
3026
    _fmt = ("Repository %(repository)s cannot resume write group "
 
3027
            "%(write_groups)r: %(reason)s")
 
3028
 
 
3029
    internal_error = True
 
3030
 
 
3031
    def __init__(self, repository, write_groups, reason):
 
3032
        self.repository = repository
 
3033
        self.write_groups = write_groups
 
3034
        self.reason = reason
 
3035
 
 
3036
 
 
3037
class UnsuspendableWriteGroup(BzrError):
 
3038
 
 
3039
    _fmt = ("Repository %(repository)s cannot suspend a write group.")
 
3040
 
 
3041
    internal_error = True
 
3042
 
 
3043
    def __init__(self, repository):
 
3044
        self.repository = repository
 
3045
 
 
3046
 
 
3047
class LossyPushToSameVCS(BzrError):
 
3048
 
 
3049
    _fmt = ("Lossy push not possible between %(source_branch)r and "
 
3050
            "%(target_branch)r that are in the same VCS.")
 
3051
 
 
3052
    internal_error = True
 
3053
 
 
3054
    def __init__(self, source_branch, target_branch):
 
3055
        self.source_branch = source_branch
 
3056
        self.target_branch = target_branch