Mercurial > hg
annotate mercurial/error.py @ 27039:d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
For --tool or HGMERGE, we could have either:
(a) proceeded with the particular tool, then failed the merge.
(b) chosen to prompt regardless.
We're explicitly choosing (b) here, because it's effectively what we've been
doing so far and helps maintain an easier-to-use interface.
However, in future patches we're going to change the default selection from
'pick changed version' to 'leave unresolved'. That fixes most of the brokenness
involved with choice (b).
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sun, 15 Nov 2015 21:40:15 -0800 |
parents | 039a53c87370 |
children | f8142cb77b1e |
rev | line source |
---|---|
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 | 6 # GNU General Public License version 2 or any later version. |
7633 | 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 |
7633 | 16 # Do not import anything here, please |
17 | |
25248
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
18 class HintException(Exception): |
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
19 def __init__(self, *args, **kw): |
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
20 Exception.__init__(self, *args) |
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
21 self.hint = kw.get('hint') |
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
22 |
25249
4311e78a4609
error: derive RevlogError from HintException instead of Exception
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25248
diff
changeset
|
23 class RevlogError(HintException): |
7633 | 24 pass |
25 | |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
26 class FilteredIndexError(IndexError): |
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
27 pass |
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
28 |
7633 | 29 class LookupError(RevlogError, KeyError): |
30 def __init__(self, name, index, message): | |
31 self.name = name | |
24038
10d02cd18604
error: store filename and message on LookupError for later
Martin von Zweigbergk <martinvonz@google.com>
parents:
23415
diff
changeset
|
32 self.index = index |
24137
dcfdfd63bde4
error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents:
24120
diff
changeset
|
33 # 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
|
34 # 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
|
35 self.lookupmessage = message |
7633 | 36 if isinstance(name, str) and len(name) == 20: |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
37 from .node import short |
7633 | 38 name = short(name) |
39 RevlogError.__init__(self, '%s@%s: %s' % (index, name, message)) | |
40 | |
41 def __str__(self): | |
42 return RevlogError.__str__(self) | |
7636 | 43 |
23015
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
44 class FilteredLookupError(LookupError): |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
45 pass |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
46 |
18855
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
47 class ManifestLookupError(LookupError): |
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
48 pass |
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
49 |
11287
b901bb751999
error: change ParseError to CommandError
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
50 class CommandError(Exception): |
7636 | 51 """Exception raised on errors in parsing the command line.""" |
7637 | 52 |
18931
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
53 class InterventionRequired(Exception): |
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
54 """Exception raised when a command requires human intervention.""" |
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
55 |
25248
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
56 class Abort(HintException): |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
57 """Raised if a command needs to print an error and exit.""" |
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
58 |
26692
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
59 class HookLoadError(Abort): |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
60 """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
|
61 |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
62 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
|
63 |
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
|
64 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
|
65 """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
|
66 |
cdbb85489c41
hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23016
diff
changeset
|
67 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
|
68 |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
69 class ConfigError(Abort): |
22359
e3714b927af5
error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents:
21747
diff
changeset
|
70 """Exception raised when parsing config files""" |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
7947
diff
changeset
|
71 |
26683
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
72 class UpdateAbort(Abort): |
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
73 """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
|
74 |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
75 class ResponseExpected(Abort): |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
76 """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
|
77 def __init__(self): |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
78 from .i18n import _ |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
79 Abort.__init__(self, _('response expected')) |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
80 |
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
|
81 class OutOfBandError(Exception): |
22359
e3714b927af5
error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents:
21747
diff
changeset
|
82 """Exception raised when a remote repo reports failure""" |
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
|
83 |
25242
8de7d1d937b3
error: allow a 'hint' to OutOfBandError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24217
diff
changeset
|
84 def __init__(self, *args, **kw): |
8de7d1d937b3
error: allow a 'hint' to OutOfBandError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24217
diff
changeset
|
85 Exception.__init__(self, *args) |
8de7d1d937b3
error: allow a 'hint' to OutOfBandError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24217
diff
changeset
|
86 self.hint = kw.get('hint') |
8de7d1d937b3
error: allow a 'hint' to OutOfBandError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24217
diff
changeset
|
87 |
11292 | 88 class ParseError(Exception): |
24040
7f375d2de945
error: update docstring on ParseError
Augie Fackler <augie@google.com>
parents:
24038
diff
changeset
|
89 """Raised when parsing config files and {rev,file}sets (msg[, pos])""" |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
90 |
24217
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
91 class UnknownIdentifier(ParseError): |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
92 """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
|
93 |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
94 def __init__(self, function, symbols): |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
95 from .i18n import _ |
24217
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
96 ParseError.__init__(self, _("unknown identifier: %s") % function) |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
97 self.function = function |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
98 self.symbols = symbols |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
99 |
25248
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
100 class RepoError(HintException): |
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
101 pass |
7637 | 102 |
9423
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
103 class RepoLookupError(RepoError): |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
104 pass |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
105 |
23016
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
106 class FilteredRepoLookupError(RepoLookupError): |
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
107 pass |
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
108 |
7637 | 109 class CapabilityError(RepoError): |
110 pass | |
7640 | 111 |
13447
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
112 class RequirementError(RepoError): |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
113 """Exception raised if .hg/requires has an unknown entry.""" |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
114 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
115 class UnsupportedMergeRecords(Abort): |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
116 def __init__(self, recordtypes): |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
117 from .i18n import _ |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
118 self.recordtypes = sorted(recordtypes) |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
119 s = ' '.join(self.recordtypes) |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
120 Abort.__init__( |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
121 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
|
122 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
|
123 'more information')) |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
124 |
7640 | 125 class LockError(IOError): |
126 def __init__(self, errno, strerror, filename, desc): | |
127 IOError.__init__(self, errno, strerror, filename) | |
128 self.desc = desc | |
129 | |
130 class LockHeld(LockError): | |
131 def __init__(self, errno, filename, desc, locker): | |
132 LockError.__init__(self, errno, 'Lock held', filename, desc) | |
133 self.locker = locker | |
134 | |
135 class LockUnavailable(LockError): | |
136 pass | |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
137 |
26355
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
138 # 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
|
139 class LockInheritanceContractViolation(RuntimeError): |
26355
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
140 pass |
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
141 |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
142 class ResponseError(Exception): |
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
143 """Raised to print an error with part of output and exit.""" |
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
144 |
7643
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
145 class UnknownCommand(Exception): |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
146 """Exception raised if command is not in the command table.""" |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
147 |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
148 class AmbiguousCommand(Exception): |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
149 """Exception raised if command shortcut matches more than one command.""" |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
150 |
7644
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
151 # derived from KeyboardInterrupt to simplify some breakout code |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
152 class SignalInterrupt(KeyboardInterrupt): |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
153 """Exception raised on SIGTERM and SIGHUP.""" |
7646 | 154 |
155 class SignatureError(Exception): | |
156 pass | |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
157 |
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
158 class PushRaced(RuntimeError): |
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
159 """An exception raised during unbundling that indicate a push race""" |
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
160 |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
161 # bundle2 related errors |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
162 class BundleValueError(ValueError): |
21621
b6eb56a9335d
bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21620
diff
changeset
|
163 """error raised when bundle2 cannot be processed""" |
21620
6eaa71b2a3cc
bundle2: introduce a parttype attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21618
diff
changeset
|
164 |
26393
cff70549a959
bundle2: rename error exception class for unsupported feature
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26355
diff
changeset
|
165 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
|
166 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
|
167 self.parttype = parttype |
21621
b6eb56a9335d
bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21620
diff
changeset
|
168 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
|
169 self.values = values |
21627
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
170 if self.parttype is None: |
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
171 msg = 'Stream Parameter' |
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
172 else: |
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
173 msg = parttype |
26394
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
174 entries = self.params |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
175 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
|
176 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
|
177 entries = [] |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
178 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
|
179 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
|
180 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
|
181 entries.append(val) |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
182 else: |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
183 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
|
184 if entries: |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
185 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
|
186 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
|
187 |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
188 class ReadOnlyPartError(RuntimeError): |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
189 """error raised when code tries to alter a part being generated""" |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
190 |
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
|
191 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
|
192 """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
|
193 |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
194 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
|
195 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
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 # 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
|
203 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
|
204 % (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
|
205 |
22595
244478687edd
error: add CensoredNodeError, will be thrown when content deliberately erased
Mike Edgar <adgar@google.com>
parents:
22359
diff
changeset
|
206 class CensoredNodeError(RevlogError): |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
207 """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
|
208 |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
209 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
|
210 """ |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
211 |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
212 def __init__(self, filename, node, tombstone): |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
213 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
|
214 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
|
215 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
|
216 |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
217 class CensoredBaseError(RevlogError): |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
218 """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
|
219 |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 """ |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
224 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
225 class InvalidBundleSpecification(Exception): |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
226 """error raised when a bundle specification is invalid. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
227 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
228 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
|
229 """ |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
230 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
231 class UnsupportedBundleSpecification(Exception): |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
232 """error raised when a bundle specification is not supported.""" |