mercurial/error.py
author Martin von Zweigbergk <martinvonz@google.com>
Wed, 10 Jan 2018 14:00:23 -0800
changeset 35708 03e921942163
parent 35105 795bfa2a9103
child 36541 c6a7b99f150a
permissions -rw-r--r--
transaction: register summary callbacks only at start of transaction (BC) We currently register summary callbacks every time localrepo.transaction() is called, so both when the transaction is started and when a nested transaction is created. That seems a little weirdly asymmetric, because the summary callbacks are thus not necessarily registred at the beginning of the outermost transaction, but they are only called when the outermost transaction closes (not when a nested transaction closes). I want to add another summary callback that records the repo state at the beginning of the transaction and compares to that when the transaction closes. However, because of the registration that happens when a nested transaction is created, that would need to go through extra trouble to not overwrite the callback and report the difference from the start time of the innermost transaction to the close of the outermost transaction. Also, the callbacks are registered with a name based on the order they are defined in the registersummarycallback(). For example, if both the "new changesets %s" and the "obsoleted %i changesets" hooks are registered, the first would be called 00-txnreport and the second would be called 01-txnreport. That gets really weird if registersummarycallback() gets called multiple times, because the last one wins, and a depending on which of the two callbacks get registered, we might hypothetically even overwrite on type of callback with another. For example, if when the outer transaction was started, we registered the "new changesets %s" callback first, and when the inner transaction was started, we registered only the "obsoleted %i changesets" callback, then only the latter message would get printed. What makes it hypothetical is that what gets registered depends on the transaction name, and the set of transaction names that we match on for the former latter message is a subset of the set of names we match on for the former. Still, that seems like a bug waiting to happen. That second issue could be solved independently, but the first issue seems enough for me to consider it a bug (affecting developers, not users), so this patch simply drops that extra registration. Note that this affects "hg transplant" in a user-visible way. When "hg transplant" is asked to transplant from a remote repo so it involves a pull, then the outermost transaction name is "transplant" and an inner transaction is created for "pull". That inner transaction is what led us to sometimes report "new changesets %s" from "hg transplant". After this patch, that no longer happens. That seems fine to me. We can make it instead print the message for all "hg transplant" invocations if we want (not just those involving a remote), but I'll leave that for someone else to do if they think it's important. Differential Revision: https://phab.mercurial-scm.org/D1866
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8226
8b2cd04a6e97 put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
     1
# error.py - Mercurial exceptions
8b2cd04a6e97 put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
     2
#
8b2cd04a6e97 put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
     3
# Copyright 2005-2008 Matt Mackall <mpm@selenic.com>
8b2cd04a6e97 put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
     4
#
8b2cd04a6e97 put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents: 8225
diff changeset
     5
# This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9423
diff changeset
     6
# GNU General Public License version 2 or any later version.
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     7
8227
0a9542703300 turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents: 8226
diff changeset
     8
"""Mercurial exceptions.
0a9542703300 turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents: 8226
diff changeset
     9
0a9542703300 turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents: 8226
diff changeset
    10
This allows us to catch exceptions at higher levels without forcing
0a9542703300 turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents: 8226
diff changeset
    11
imports.
0a9542703300 turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents: 8226
diff changeset
    12
"""
0a9542703300 turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents: 8226
diff changeset
    13
25945
147bd9e238a1 error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25484
diff changeset
    14
from __future__ import absolute_import
147bd9e238a1 error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25484
diff changeset
    15
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    16
# Do not import anything but pycompat here, please
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    17
from . import pycompat
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    18
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    19
def _tobytes(exc):
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    20
    """Byte-stringify exception in the same way as BaseException_str()"""
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    21
    if not exc.args:
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    22
        return b''
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    23
    if len(exc.args) == 1:
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    24
        return pycompat.bytestr(exc.args[0])
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    25
    return b'(%s)' % b', '.join(b"'%s'" % pycompat.bytestr(a) for a in exc.args)
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    26
29509
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
    27
class Hint(object):
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
    28
    """Mix-in to provide a hint of an error
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
    29
29510
19205a0e2bf1 error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents: 29509
diff changeset
    30
    This should come first in the inheritance list to consume a hint and
19205a0e2bf1 error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents: 29509
diff changeset
    31
    pass remaining arguments to the exception class.
29509
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
    32
    """
25248
821e664924dc error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 25242
diff changeset
    33
    def __init__(self, *args, **kw):
31503
0ca00905f769 error: use r-string to properly pop hints from **kw
Augie Fackler <augie@google.com>
parents: 30585
diff changeset
    34
        self.hint = kw.pop(r'hint', None)
29510
19205a0e2bf1 error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents: 29509
diff changeset
    35
        super(Hint, self).__init__(*args, **kw)
25248
821e664924dc error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 25242
diff changeset
    36
29509
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
    37
class RevlogError(Hint, Exception):
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    38
    __bytes__ = _tobytes
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
23014
f00813325c5a repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23010
diff changeset
    40
class FilteredIndexError(IndexError):
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    41
    __bytes__ = _tobytes
23014
f00813325c5a repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23010
diff changeset
    42
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    43
class LookupError(RevlogError, KeyError):
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    44
    def __init__(self, name, index, message):
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    45
        self.name = name
24038
10d02cd18604 error: store filename and message on LookupError for later
Martin von Zweigbergk <martinvonz@google.com>
parents: 23415
diff changeset
    46
        self.index = index
24137
dcfdfd63bde4 error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents: 24120
diff changeset
    47
        # this can't be called 'message' because at least some installs of
dcfdfd63bde4 error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents: 24120
diff changeset
    48
        # Python 2.6+ complain about the 'message' property being deprecated
dcfdfd63bde4 error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents: 24120
diff changeset
    49
        self.lookupmessage = message
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    50
        if isinstance(name, str) and len(name) == 20:
25945
147bd9e238a1 error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25484
diff changeset
    51
            from .node import short
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    52
            name = short(name)
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    53
        RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    54
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    55
    def __bytes__(self):
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    56
        return RevlogError.__bytes__(self)
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    57
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    58
    def __str__(self):
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    59
        return RevlogError.__str__(self)
7636
e3f8c6d6b72e error: move ParseError
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
    60
23015
21c44c1aed87 repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23014
diff changeset
    61
class FilteredLookupError(LookupError):
21c44c1aed87 repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23014
diff changeset
    62
    pass
21c44c1aed87 repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23014
diff changeset
    63
18855
50c922c1b514 hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents: 15017
diff changeset
    64
class ManifestLookupError(LookupError):
50c922c1b514 hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents: 15017
diff changeset
    65
    pass
50c922c1b514 hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents: 15017
diff changeset
    66
11287
b901bb751999 error: change ParseError to CommandError
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    67
class CommandError(Exception):
7636
e3f8c6d6b72e error: move ParseError
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
    68
    """Exception raised on errors in parsing the command line."""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    69
    __bytes__ = _tobytes
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
    70
29509
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
    71
class InterventionRequired(Hint, Exception):
18931
3c224e0949de error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents: 18855
diff changeset
    72
    """Exception raised when a command requires human intervention."""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    73
    __bytes__ = _tobytes
18931
3c224e0949de error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents: 18855
diff changeset
    74
29509
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
    75
class Abort(Hint, Exception):
11288
2123aad24d56 error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents: 11287
diff changeset
    76
    """Raised if a command needs to print an error and exit."""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
    77
    __bytes__ = _tobytes
11288
2123aad24d56 error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents: 11287
diff changeset
    78
26692
8d1cfd77b64f hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents: 26683
diff changeset
    79
class HookLoadError(Abort):
8d1cfd77b64f hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents: 26683
diff changeset
    80
    """raised when loading a hook fails, aborting an operation
8d1cfd77b64f hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents: 26683
diff changeset
    81
8d1cfd77b64f hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents: 26683
diff changeset
    82
    Exists to allow more specialized catching."""
8d1cfd77b64f hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents: 26683
diff changeset
    83
23415
cdbb85489c41 hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23016
diff changeset
    84
class HookAbort(Abort):
cdbb85489c41 hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23016
diff changeset
    85
    """raised when a validation hook fails, aborting an operation
cdbb85489c41 hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23016
diff changeset
    86
cdbb85489c41 hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23016
diff changeset
    87
    Exists to allow more specialized catching."""
cdbb85489c41 hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23016
diff changeset
    88
11288
2123aad24d56 error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents: 11287
diff changeset
    89
class ConfigError(Abort):
22359
e3714b927af5 error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents: 21747
diff changeset
    90
    """Exception raised when parsing config files"""
8144
fca54469480e ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents: 7947
diff changeset
    91
26683
634666c48b7d update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26640
diff changeset
    92
class UpdateAbort(Abort):
634666c48b7d update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26640
diff changeset
    93
    """Raised when an update is aborted for destination issue"""
634666c48b7d update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26640
diff changeset
    94
28141
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27628
diff changeset
    95
class MergeDestAbort(Abort):
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27628
diff changeset
    96
    """Raised when an update is aborted for destination issues"""
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27628
diff changeset
    97
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27628
diff changeset
    98
class NoMergeDestAbort(MergeDestAbort):
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27628
diff changeset
    99
    """Raised when an update is aborted because there is nothing to merge"""
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27628
diff changeset
   100
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27628
diff changeset
   101
class ManyMergeDestAbort(MergeDestAbort):
30332
318a24b52eeb spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents: 29536
diff changeset
   102
    """Raised when an update is aborted because destination is ambiguous"""
28141
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27628
diff changeset
   103
26896
5e46123e6c35 error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents: 26693
diff changeset
   104
class ResponseExpected(Abort):
5e46123e6c35 error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents: 26693
diff changeset
   105
    """Raised when an EOF is received for a prompt"""
5e46123e6c35 error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents: 26693
diff changeset
   106
    def __init__(self):
5e46123e6c35 error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents: 26693
diff changeset
   107
        from .i18n import _
5e46123e6c35 error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents: 26693
diff changeset
   108
        Abort.__init__(self, _('response expected'))
5e46123e6c35 error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents: 26693
diff changeset
   109
29509
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
   110
class OutOfBandError(Hint, Exception):
22359
e3714b927af5 error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents: 21747
diff changeset
   111
    """Exception raised when a remote repo reports failure"""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   112
    __bytes__ = _tobytes
15017
f4522df38c65 wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents: 14761
diff changeset
   113
29509
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
   114
class ParseError(Hint, Exception):
24040
7f375d2de945 error: update docstring on ParseError
Augie Fackler <augie@google.com>
parents: 24038
diff changeset
   115
    """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   116
    __bytes__ = _tobytes
11288
2123aad24d56 error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents: 11287
diff changeset
   117
34251
61714510220d error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32616
diff changeset
   118
class PatchError(Exception):
61714510220d error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32616
diff changeset
   119
    __bytes__ = _tobytes
61714510220d error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32616
diff changeset
   120
24217
d2b81256db1e error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents: 24190
diff changeset
   121
class UnknownIdentifier(ParseError):
d2b81256db1e error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents: 24190
diff changeset
   122
    """Exception raised when a {rev,file}set references an unknown identifier"""
d2b81256db1e error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents: 24190
diff changeset
   123
d2b81256db1e error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents: 24190
diff changeset
   124
    def __init__(self, function, symbols):
25945
147bd9e238a1 error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25484
diff changeset
   125
        from .i18n import _
24217
d2b81256db1e error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents: 24190
diff changeset
   126
        ParseError.__init__(self, _("unknown identifier: %s") % function)
d2b81256db1e error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents: 24190
diff changeset
   127
        self.function = function
d2b81256db1e error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents: 24190
diff changeset
   128
        self.symbols = symbols
d2b81256db1e error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents: 24190
diff changeset
   129
29509
945b4c14c570 error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28141
diff changeset
   130
class RepoError(Hint, Exception):
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   131
    __bytes__ = _tobytes
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
   132
9423
1444a42f6052 Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   133
class RepoLookupError(RepoError):
1444a42f6052 Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   134
    pass
1444a42f6052 Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents: 8227
diff changeset
   135
23016
2bd51e61c65e repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23015
diff changeset
   136
class FilteredRepoLookupError(RepoLookupError):
2bd51e61c65e repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23015
diff changeset
   137
    pass
2bd51e61c65e repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23015
diff changeset
   138
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
   139
class CapabilityError(RepoError):
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
   140
    pass
7640
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   141
13447
931a72e00efa introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents: 11574
diff changeset
   142
class RequirementError(RepoError):
931a72e00efa introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents: 11574
diff changeset
   143
    """Exception raised if .hg/requires has an unknown entry."""
931a72e00efa introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents: 11574
diff changeset
   144
31959
b445a3f00528 stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents: 31503
diff changeset
   145
class StdioError(IOError):
b445a3f00528 stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents: 31503
diff changeset
   146
    """Raised if I/O to stdout or stderr fails"""
b445a3f00528 stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents: 31503
diff changeset
   147
b445a3f00528 stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents: 31503
diff changeset
   148
    def __init__(self, err):
b445a3f00528 stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents: 31503
diff changeset
   149
        IOError.__init__(self, err.errno, err.strerror)
b445a3f00528 stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents: 31503
diff changeset
   150
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   151
    # no __bytes__() because error message is derived from the standard IOError
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   152
26985
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   153
class UnsupportedMergeRecords(Abort):
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   154
    def __init__(self, recordtypes):
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   155
        from .i18n import _
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   156
        self.recordtypes = sorted(recordtypes)
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   157
        s = ' '.join(self.recordtypes)
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   158
        Abort.__init__(
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   159
            self, _('unsupported merge state records: %s') % s,
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   160
            hint=_('see https://mercurial-scm.org/wiki/MergeStateRecords for '
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   161
                   'more information'))
039a53c87370 error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents: 26896
diff changeset
   162
32596
19df975eb555 obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32402
diff changeset
   163
class UnknownVersion(Abort):
19df975eb555 obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32402
diff changeset
   164
    """generic exception for aborting from an encounter with an unknown version
19df975eb555 obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32402
diff changeset
   165
    """
19df975eb555 obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32402
diff changeset
   166
19df975eb555 obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32402
diff changeset
   167
    def __init__(self, msg, hint=None, version=None):
19df975eb555 obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32402
diff changeset
   168
        self.version = version
19df975eb555 obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32402
diff changeset
   169
        super(UnknownVersion, self).__init__(msg, hint=hint)
19df975eb555 obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32402
diff changeset
   170
7640
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   171
class LockError(IOError):
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   172
    def __init__(self, errno, strerror, filename, desc):
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   173
        IOError.__init__(self, errno, strerror, filename)
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   174
        self.desc = desc
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   175
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   176
    # no __bytes__() because error message is derived from the standard IOError
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   177
7640
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   178
class LockHeld(LockError):
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   179
    def __init__(self, errno, filename, desc, locker):
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   180
        LockError.__init__(self, errno, 'Lock held', filename, desc)
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   181
        self.locker = locker
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   182
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   183
class LockUnavailable(LockError):
7197812e8d44 error: move lock errors
Matt Mackall <mpm@selenic.com>
parents: 7637
diff changeset
   184
    pass
7641
d2f753830f80 error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents: 7640
diff changeset
   185
26355
f51713b8c6fa error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents: 25945
diff changeset
   186
# LockError is for errors while acquiring the lock -- this is unrelated
26438
024644b1900b error: make lock inheritance contract violations a subclass of RuntimeError
Siddharth Agarwal <sid0@fb.com>
parents: 26394
diff changeset
   187
class LockInheritanceContractViolation(RuntimeError):
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   188
    __bytes__ = _tobytes
26355
f51713b8c6fa error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents: 25945
diff changeset
   189
7641
d2f753830f80 error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents: 7640
diff changeset
   190
class ResponseError(Exception):
d2f753830f80 error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents: 7640
diff changeset
   191
    """Raised to print an error with part of output and exit."""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   192
    __bytes__ = _tobytes
7641
d2f753830f80 error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents: 7640
diff changeset
   193
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7641
diff changeset
   194
class UnknownCommand(Exception):
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7641
diff changeset
   195
    """Exception raised if command is not in the command table."""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   196
    __bytes__ = _tobytes
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7641
diff changeset
   197
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7641
diff changeset
   198
class AmbiguousCommand(Exception):
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7641
diff changeset
   199
    """Exception raised if command shortcut matches more than one command."""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   200
    __bytes__ = _tobytes
7643
9a1ea6587557 error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents: 7641
diff changeset
   201
7644
182b7114d35a error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents: 7643
diff changeset
   202
# derived from KeyboardInterrupt to simplify some breakout code
182b7114d35a error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents: 7643
diff changeset
   203
class SignalInterrupt(KeyboardInterrupt):
182b7114d35a error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents: 7643
diff changeset
   204
    """Exception raised on SIGTERM and SIGHUP."""
7646
e62a456b8dc5 error: move SignatureError
Matt Mackall <mpm@selenic.com>
parents: 7644
diff changeset
   205
e62a456b8dc5 error: move SignatureError
Matt Mackall <mpm@selenic.com>
parents: 7644
diff changeset
   206
class SignatureError(Exception):
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   207
    __bytes__ = _tobytes
21184
28d76afa1568 bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 18931
diff changeset
   208
28d76afa1568 bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 18931
diff changeset
   209
class PushRaced(RuntimeError):
28d76afa1568 bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 18931
diff changeset
   210
    """An exception raised during unbundling that indicate a push race"""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   211
    __bytes__ = _tobytes
21184
28d76afa1568 bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 18931
diff changeset
   212
32340
9c023179e8d0 error: add hint to ProgrammingError
Yuya Nishihara <yuya@tcha.org>
parents: 32023
diff changeset
   213
class ProgrammingError(Hint, RuntimeError):
30585
0f865311ae3f error: make it clear that ProgrammingError is for mercurial developers
Jun Wu <quark@fb.com>
parents: 30573
diff changeset
   214
    """Raised if a mercurial (core or extension) developer made a mistake"""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   215
    __bytes__ = _tobytes
30573
b0ebab239f90 error: add ProgrammingError
Jun Wu <quark@fb.com>
parents: 30332
diff changeset
   216
32402
c8e10565a113 error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32340
diff changeset
   217
class WdirUnsupported(Exception):
c8e10565a113 error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32340
diff changeset
   218
    """An exception which is raised when 'wdir()' is not supported"""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   219
    __bytes__ = _tobytes
32402
c8e10565a113 error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32340
diff changeset
   220
21618
7568f5c1c801 bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21184
diff changeset
   221
# bundle2 related errors
7568f5c1c801 bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21184
diff changeset
   222
class BundleValueError(ValueError):
21621
b6eb56a9335d bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21620
diff changeset
   223
    """error raised when bundle2 cannot be processed"""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   224
    __bytes__ = _tobytes
21620
6eaa71b2a3cc bundle2: introduce a parttype attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21618
diff changeset
   225
26393
cff70549a959 bundle2: rename error exception class for unsupported feature
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26355
diff changeset
   226
class BundleUnknownFeatureError(BundleValueError):
26394
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   227
    def __init__(self, parttype=None, params=(), values=()):
21620
6eaa71b2a3cc bundle2: introduce a parttype attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21618
diff changeset
   228
        self.parttype = parttype
21621
b6eb56a9335d bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21620
diff changeset
   229
        self.params = params
26394
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   230
        self.values = values
21627
3e8bcc90f07c bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21621
diff changeset
   231
        if self.parttype is None:
3e8bcc90f07c bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21621
diff changeset
   232
            msg = 'Stream Parameter'
3e8bcc90f07c bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21621
diff changeset
   233
        else:
3e8bcc90f07c bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21621
diff changeset
   234
            msg = parttype
26394
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   235
        entries = self.params
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   236
        if self.params and self.values:
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   237
            assert len(self.params) == len(self.values)
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   238
            entries = []
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   239
            for idx, par in enumerate(self.params):
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   240
                val = self.values[idx]
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   241
                if val is None:
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   242
                    entries.append(val)
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   243
                else:
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   244
                    entries.append("%s=%r" % (par, val))
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   245
        if entries:
e75da738add5 bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26393
diff changeset
   246
            msg = '%s - %s' % (msg, ', '.join(entries))
21747
fecead61d222 error: restore python 2.4 compatibility for BundleValueError
Brendan Cully <brendan@kublai.com>
parents: 21627
diff changeset
   247
        ValueError.__init__(self, msg)
21618
7568f5c1c801 bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21184
diff changeset
   248
7568f5c1c801 bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21184
diff changeset
   249
class ReadOnlyPartError(RuntimeError):
7568f5c1c801 bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21184
diff changeset
   250
    """error raised when code tries to alter a part being generated"""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   251
    __bytes__ = _tobytes
21618
7568f5c1c801 bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21184
diff changeset
   252
25484
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   253
class PushkeyFailed(Abort):
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   254
    """error raised when a pushkey part failed to update a value"""
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   255
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   256
    def __init__(self, partid, namespace=None, key=None, new=None, old=None,
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   257
                 ret=None):
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   258
        self.partid = partid
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   259
        self.namespace = namespace
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   260
        self.key = key
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   261
        self.new = new
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   262
        self.old = old
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   263
        self.ret = ret
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   264
        # no i18n expected to be processed into a better message
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   265
        Abort.__init__(self, 'failed to update value for "%s/%s"'
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   266
                       % (namespace, key))
a5192774e925 bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25249
diff changeset
   267
22595
244478687edd error: add CensoredNodeError, will be thrown when content deliberately erased
Mike Edgar <adgar@google.com>
parents: 22359
diff changeset
   268
class CensoredNodeError(RevlogError):
24190
903c7e8c97ad changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents: 24137
diff changeset
   269
    """error raised when content verification fails on a censored node
22595
244478687edd error: add CensoredNodeError, will be thrown when content deliberately erased
Mike Edgar <adgar@google.com>
parents: 22359
diff changeset
   270
24190
903c7e8c97ad changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents: 24137
diff changeset
   271
    Also contains the tombstone data substituted for the uncensored data.
903c7e8c97ad changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents: 24137
diff changeset
   272
    """
903c7e8c97ad changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents: 24137
diff changeset
   273
903c7e8c97ad changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents: 24137
diff changeset
   274
    def __init__(self, filename, node, tombstone):
25945
147bd9e238a1 error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25484
diff changeset
   275
        from .node import short
22595
244478687edd error: add CensoredNodeError, will be thrown when content deliberately erased
Mike Edgar <adgar@google.com>
parents: 22359
diff changeset
   276
        RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
24190
903c7e8c97ad changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents: 24137
diff changeset
   277
        self.tombstone = tombstone
24120
a450e0a2ba0a revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents: 24040
diff changeset
   278
a450e0a2ba0a revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents: 24040
diff changeset
   279
class CensoredBaseError(RevlogError):
a450e0a2ba0a revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents: 24040
diff changeset
   280
    """error raised when a delta is rejected because its base is censored
a450e0a2ba0a revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents: 24040
diff changeset
   281
a450e0a2ba0a revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents: 24040
diff changeset
   282
    A delta based on a censored revision must be formed as single patch
a450e0a2ba0a revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents: 24040
diff changeset
   283
    operation which replaces the entire base with new content. This ensures
a450e0a2ba0a revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents: 24040
diff changeset
   284
    the delta may be applied by clones which have not censored the base.
a450e0a2ba0a revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents: 24040
diff changeset
   285
    """
26640
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   286
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   287
class InvalidBundleSpecification(Exception):
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   288
    """error raised when a bundle specification is invalid.
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   289
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   290
    This is used for syntax errors as opposed to support errors.
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   291
    """
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   292
    __bytes__ = _tobytes
26640
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   293
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   294
class UnsupportedBundleSpecification(Exception):
b13fdcc4e700 exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26438
diff changeset
   295
    """error raised when a bundle specification is not supported."""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   296
    __bytes__ = _tobytes
29536
b17a6e3cd2ac shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents: 29510
diff changeset
   297
b17a6e3cd2ac shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents: 29510
diff changeset
   298
class CorruptedState(Exception):
b17a6e3cd2ac shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents: 29510
diff changeset
   299
    """error raised when a command is not able to read its state from file"""
32616
6df193b5c437 py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents: 32596
diff changeset
   300
    __bytes__ = _tobytes
32002
bf855efe5664 httppeer: wrap HTTPResponse.read() globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 31959
diff changeset
   301
32023
a29580905771 error: rename RichIOError to PeerTransportError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32002
diff changeset
   302
class PeerTransportError(Abort):
a29580905771 error: rename RichIOError to PeerTransportError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32002
diff changeset
   303
    """Transport-level I/O error when communicating with a peer repo."""
35105
795bfa2a9103 error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents: 34251
diff changeset
   304
795bfa2a9103 error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents: 34251
diff changeset
   305
class InMemoryMergeConflictsError(Exception):
795bfa2a9103 error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents: 34251
diff changeset
   306
    """Exception raised when merge conflicts arose during an in-memory merge."""
795bfa2a9103 error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents: 34251
diff changeset
   307
    __bytes__ = _tobytes