Mercurial > public > mercurial-scm > hg
annotate mercurial/error.py @ 45892:06b64fabf91c
copies: cache the ancestor checking call when tracing copy
A good share of the time spent in this function is spent doing ancestors
checking. To avoid spending time in duplicated call, we cache the result of
calls.
In the slower case, this provide a quite significant performance boost. Below
are the result for a set of selected pairs (many of them pathological):
(And further down is another table that summarize the current state of filelog
based vs changeset base copy tracing)
The benchmark have been configured to be killed after 6 minutes of runtime,
which mean that any detect slower than 2 minutes will be marked as "killed".
This drop some useful information about how much slower these case are? but also
prevent 99% of the benchmark time to be spent on case that can be labelled "very
slow" anyway.
Repo Case Source-Rev Dest-Rev Old-Time New-Time Difference Factor
------------------------------------------------------------------------------------------------------------------------------------
mercurial x_revs_x_added_0_copies ad6b123de1c7 39cfcef4f463 : 0.000044 s, 0.000044 s, +0.000000 s, ? 1.0000
mercurial x_revs_x_added_x_copies 2b1c78674230 0c1d10351869 : 0.000138 s, 0.000138 s, +0.000000 s, ? 1.0000
mercurial x000_revs_x000_added_x_copies 81f8ff2a9bf2 dd3267698d84 : 0.005067 s, 0.005052 s, -0.000015 s, ? 0.9970
pypy x_revs_x_added_0_copies aed021ee8ae8 099ed31b181b : 0.000218 s, 0.000219 s, +0.000001 s, ? 1.0046
pypy x_revs_x000_added_0_copies 4aa4e1f8e19a 359343b9ac0e : 0.000053 s, 0.000055 s, +0.000002 s, ? 1.0377
pypy x_revs_x_added_x_copies ac52eb7bbbb0 72e022663155 : 0.000125 s, 0.000128 s, +0.000003 s, ? 1.0240
pypy x_revs_x00_added_x_copies c3b14617fbd7 ace7255d9a26 : 0.001098 s, 0.001089 s, -0.000009 s, ? 0.9918
pypy x_revs_x000_added_x000_copies df6f7a526b60 a83dc6a2d56f : 0.017546 s, 0.017407 s, -0.000139 s, ? 0.9921
pypy x000_revs_xx00_added_0_copies 89a76aede314 2f22446ff07e : 0.096723 s, 0.094175 s, -0.002548 s, ? 0.9737
pypy x000_revs_x000_added_x_copies 8a3b5bfd266e 2c68e87c3efe : 0.271796 s, 0.238009 s, -0.033787 s, ? 0.8757
pypy x000_revs_x000_added_x000_copies 89a76aede314 7b3dda341c84 : 0.128602 s, 0.125876 s, -0.002726 s, ? 0.9788
pypy x0000_revs_x_added_0_copies d1defd0dc478 c9cb1334cc78 : 7.086742 s, 3.581556 s, -3.505186 s, ? 0.5054
pypy x0000_revs_xx000_added_0_copies bf2c629d0071 4ffed77c095c : 0.016634 s, 0.016721 s, +0.000087 s, ? 1.0052
pypy x0000_revs_xx000_added_x000_copies 08ea3258278e d9fa043f30c0 : 0.254225 s, 0.242367 s, -0.011858 s, ? 0.9534
netbeans x_revs_x_added_0_copies fb0955ffcbcd a01e9239f9e7 : 0.000166 s, 0.000165 s, -0.000001 s, ? 0.9940
netbeans x_revs_x000_added_0_copies 6f360122949f 20eb231cc7d0 : 0.000118 s, 0.000114 s, -0.000004 s, ? 0.9661
netbeans x_revs_x_added_x_copies 1ada3faf6fb6 5a39d12eecf4 : 0.000296 s, 0.000296 s, +0.000000 s, ? 1.0000
netbeans x_revs_x00_added_x_copies 35be93ba1e2c 9eec5e90c05f : 0.001137 s, 0.001124 s, -0.000013 s, ? 0.9886
netbeans x000_revs_xx00_added_0_copies eac3045b4fdd 51d4ae7f1290 : 0.014133 s, 0.013060 s, -0.001073 s, ? 0.9241
netbeans x000_revs_x000_added_x_copies e2063d266acd 6081d72689dc : 0.016988 s, 0.017112 s, +0.000124 s, ? 1.0073
netbeans x000_revs_x000_added_x000_copies ff453e9fee32 411350406ec2 : 0.676361 s, 0.660350 s, -0.016011 s, ? 0.9763
netbeans x0000_revs_xx000_added_x000_copies 588c2d1ced70 1aad62e59ddd : 12.515149 s, 10.032499 s, -2.482650 s, ? 0.8016
mozilla-central x_revs_x_added_0_copies 3697f962bb7b 7015fcdd43a2 : 0.000186 s, 0.000189 s, +0.000003 s, ? 1.0161
mozilla-central x_revs_x000_added_0_copies dd390860c6c9 40d0c5bed75d : 0.000459 s, 0.000462 s, +0.000003 s, ? 1.0065
mozilla-central x_revs_x_added_x_copies 8d198483ae3b 14207ffc2b2f : 0.000273 s, 0.000270 s, -0.000003 s, ? 0.9890
mozilla-central x_revs_x00_added_x_copies 98cbc58cc6bc 446a150332c3 : 0.001503 s, 0.001474 s, -0.000029 s, ? 0.9807
mozilla-central x_revs_x000_added_x000_copies 3c684b4b8f68 0a5e72d1b479 : 0.004862 s, 0.004806 s, -0.000056 s, ? 0.9885
mozilla-central x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 0.088291 s, 0.085150 s, -0.003141 s, ? 0.9644
mozilla-central x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 0.007113 s, 0.007064 s, -0.000049 s, ? 0.9931
mozilla-central x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 0.004687 s, 0.004741 s, +0.000054 s, ? 1.0115
mozilla-central x000_revs_x000_added_x000_copies 7c97034feb78 4407bd0c6330 : 0.198710 s, 0.190133 s, -0.008577 s, ? 0.9568
mozilla-central x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 0.036068 s, 0.035651 s, -0.000417 s, ? 0.9884
mozilla-central x0000_revs_xx000_added_x000_copies f78c615a656c 96a38b690156 : 0.465362 s, 0.440694 s, -0.024668 s, ? 0.9470
mozilla-central x00000_revs_x0000_added_x0000_copies 6832ae71433c 4c222a1d9a00 : 24.519684 s, 18.454163 s, -6.065521 s, ? 0.7526
mozilla-central x00000_revs_x00000_added_x000_copies 76caed42cf7c 1daa622bbe42 : 42.711897 s, 31.562719 s, -11.149178 s, ? 0.7390
mozilla-try x_revs_x_added_0_copies aaf6dde0deb8 9790f499805a : 0.001201 s, 0.001189 s, -0.000012 s, ? 0.9900
mozilla-try x_revs_x000_added_0_copies d8d0222927b4 5bb8ce8c7450 : 0.001216 s, 0.001204 s, -0.000012 s, ? 0.9901
mozilla-try x_revs_x_added_x_copies 092fcca11bdb 936255a0384a : 0.000595 s, 0.000586 s, -0.000009 s, ? 0.9849
mozilla-try x_revs_x00_added_x_copies b53d2fadbdb5 017afae788ec : 0.001856 s, 0.001845 s, -0.000011 s, ? 0.9941
mozilla-try x_revs_x000_added_x000_copies 20408ad61ce5 6f0ee96e21ad : 0.064936 s, 0.063822 s, -0.001114 s, ? 0.9828
mozilla-try x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 0.090601 s, 0.088038 s, -0.002563 s, ? 0.9717
mozilla-try x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 0.007510 s, 0.007389 s, -0.000121 s, ? 0.9839
mozilla-try x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 0.004911 s, 0.004868 s, -0.000043 s, ? 0.9912
mozilla-try x000_revs_x000_added_x000_copies 1346fd0130e4 4c65cbdabc1f : 0.233231 s, 0.222450 s, -0.010781 s, ? 0.9538
mozilla-try x0000_revs_x_added_0_copies 63519bfd42ee a36a2a865d92 : 0.419989 s, 0.370675 s, -0.049314 s, ? 0.8826
mozilla-try x0000_revs_x_added_x_copies 9fe69ff0762d bcabf2a78927 : 0.401521 s, 0.358020 s, -0.043501 s, ? 0.8917
mozilla-try x0000_revs_xx000_added_x_copies 156f6e2674f2 4d0f2c178e66 : 0.179555 s, 0.145235 s, -0.034320 s, ? 0.8089
mozilla-try x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 0.038004 s, 0.037606 s, -0.000398 s, ? 0.9895
mozilla-try x0000_revs_xx000_added_x000_copies 89294cd501d9 7ccb2fc7ccb5 : 52.838482 s, 7.382439 s, -45.456043 s, ? 0.1397
mozilla-try x0000_revs_x0000_added_x0000_copies e928c65095ed e951f4ad123a : 8.705874 s, 7.273506 s, -1.432368 s, ? 0.8355
mozilla-try x00000_revs_x00000_added_0_copies dc8a3ca7010e d16fde900c9c : 1.126708 s, 1.074593 s, -0.052115 s, ? 0.9537
mozilla-try x00000_revs_x0000_added_x0000_copies 8d3fafa80d4b eb884023b810 : 83.854020 s, 27.746195 s, -56.107825 s, ? 0.3309
Below is a table comparing the runtime of the current "filelog centric"
algorithm, with the "changeset centric" one, we just modified.
The changeset centric algorithm is a significant win in many scenario, but they
are still various cases where it is quite slower. When many revision has to be
considered the cost of retrieving the copy information, creating new
dictionaries, merging dictionaries and checking if revision are ancestors of
each other can slow things down.
The rest of this series, will introduce a rust version of the copy tracing code
to deal with most of theses issues.
Repo Case Source-Rev Dest-Rev filelog sidedata Difference Factor
---------------------------------------------------------------------------------------------------------------------------------------
mercurial x_revs_x_added_0_copies ad6b123de1c7 39cfcef4f463 : 0.000914 s, 0.000044 s, - 0.000870 s, ? 0.048140
mercurial x_revs_x_added_x_copies 2b1c78674230 0c1d10351869 : 0.001812 s, 0.000138 s, - 0.001674 s, ? 0.076159
mercurial x000_revs_x000_added_x_copies 81f8ff2a9bf2 dd3267698d84 : 0.017954 s, 0.005052 s, - 0.012902 s, ? 0.281386
pypy x_revs_x_added_0_copies aed021ee8ae8 099ed31b181b : 0.001509 s, 0.000219 s, - 0.001290 s, ? 0.145129
pypy x_revs_x000_added_0_copies 4aa4e1f8e19a 359343b9ac0e : 0.206881 s, 0.000055 s, - 0.206826 s, ? 0.000266
pypy x_revs_x_added_x_copies ac52eb7bbbb0 72e022663155 : 0.016951 s, 0.000128 s, - 0.016823 s, ? 0.007551
pypy x_revs_x00_added_x_copies c3b14617fbd7 ace7255d9a26 : 0.019096 s, 0.001089 s, - 0.018007 s, ? 0.057028
pypy x_revs_x000_added_x000_copies df6f7a526b60 a83dc6a2d56f : 0.762506 s, 0.017407 s, - 0.745099 s, ? 0.022829
pypy x000_revs_xx00_added_0_copies 89a76aede314 2f22446ff07e : 1.179211 s, 0.094175 s, - 1.085036 s, ? 0.079863
pypy x000_revs_x000_added_x_copies 8a3b5bfd266e 2c68e87c3efe : 1.249058 s, 0.238009 s, - 1.011049 s, ? 0.190551
pypy x000_revs_x000_added_x000_copies 89a76aede314 7b3dda341c84 : 1.614107 s, 0.125876 s, - 1.488231 s, ? 0.077985
pypy x0000_revs_x_added_0_copies d1defd0dc478 c9cb1334cc78 : 0.001064 s, 3.581556 s, + 3.580492 s, ? 3366.124060
pypy x0000_revs_xx000_added_0_copies bf2c629d0071 4ffed77c095c : 1.061275 s, 0.016721 s, - 1.044554 s, ? 0.015756
pypy x0000_revs_xx000_added_x000_copies 08ea3258278e d9fa043f30c0 : 1.341119 s, 0.242367 s, - 1.098752 s, ? 0.180720
netbeans x_revs_x_added_0_copies fb0955ffcbcd a01e9239f9e7 : 0.027803 s, 0.000165 s, - 0.027638 s, ? 0.005935
netbeans x_revs_x000_added_0_copies 6f360122949f 20eb231cc7d0 : 0.130014 s, 0.000114 s, - 0.129900 s, ? 0.000877
netbeans x_revs_x_added_x_copies 1ada3faf6fb6 5a39d12eecf4 : 0.024990 s, 0.000296 s, - 0.024694 s, ? 0.011845
netbeans x_revs_x00_added_x_copies 35be93ba1e2c 9eec5e90c05f : 0.052201 s, 0.001124 s, - 0.051077 s, ? 0.021532
netbeans x000_revs_xx00_added_0_copies eac3045b4fdd 51d4ae7f1290 : 0.037642 s, 0.013060 s, - 0.024582 s, ? 0.346953
netbeans x000_revs_x000_added_x_copies e2063d266acd 6081d72689dc : 0.197086 s, 0.017112 s, - 0.179974 s, ? 0.086825
netbeans x000_revs_x000_added_x000_copies ff453e9fee32 411350406ec2 : 0.935148 s, 0.660350 s, - 0.274798 s, ? 0.706145
netbeans x0000_revs_xx000_added_x000_copies 588c2d1ced70 1aad62e59ddd : 3.920674 s, 10.032499 s, + 6.111825 s, ? 2.558871
mozilla-central x_revs_x_added_0_copies 3697f962bb7b 7015fcdd43a2 : 0.024232 s, 0.000189 s, - 0.024043 s, ? 0.007800
mozilla-central x_revs_x000_added_0_copies dd390860c6c9 40d0c5bed75d : 0.141483 s, 0.000462 s, - 0.141021 s, ? 0.003265
mozilla-central x_revs_x_added_x_copies 8d198483ae3b 14207ffc2b2f : 0.025775 s, 0.000270 s, - 0.025505 s, ? 0.010475
mozilla-central x_revs_x00_added_x_copies 98cbc58cc6bc 446a150332c3 : 0.084922 s, 0.001474 s, - 0.083448 s, ? 0.017357
mozilla-central x_revs_x000_added_x000_copies 3c684b4b8f68 0a5e72d1b479 : 0.194784 s, 0.004806 s, - 0.189978 s, ? 0.024673
mozilla-central x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 2.161103 s, 0.085150 s, - 2.075953 s, ? 0.039401
mozilla-central x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 0.089347 s, 0.007064 s, - 0.082283 s, ? 0.079063
mozilla-central x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 0.732171 s, 0.004741 s, - 0.727430 s, ? 0.006475
mozilla-central x000_revs_x000_added_x000_copies 7c97034feb78 4407bd0c6330 : 1.157287 s, 0.190133 s, - 0.967154 s, ? 0.164292
mozilla-central x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 6.726568 s, 0.035651 s, - 6.690917 s, ? 0.005300
mozilla-central x0000_revs_xx000_added_x000_copies f78c615a656c 96a38b690156 : 3.266229 s, 0.440694 s, - 2.825535 s, ? 0.134924
mozilla-central x00000_revs_x0000_added_x0000_copies 6832ae71433c 4c222a1d9a00 : 15.860534 s, 18.454163 s, + 2.593629 s, ? 1.163527
mozilla-central x00000_revs_x00000_added_x000_copies 76caed42cf7c 1daa622bbe42 : 20.450475 s, 31.562719 s, +11.112244 s, ? 1.543373
mozilla-try x_revs_x_added_0_copies aaf6dde0deb8 9790f499805a : 0.080442 s, 0.001189 s, - 0.079253 s, ? 0.014781
mozilla-try x_revs_x000_added_0_copies d8d0222927b4 5bb8ce8c7450 : 0.497672 s, 0.001204 s, - 0.496468 s, ? 0.002419
mozilla-try x_revs_x_added_x_copies 092fcca11bdb 936255a0384a : 0.021183 s, 0.000586 s, - 0.020597 s, ? 0.027664
mozilla-try x_revs_x00_added_x_copies b53d2fadbdb5 017afae788ec : 0.230991 s, 0.001845 s, - 0.229146 s, ? 0.007987
mozilla-try x_revs_x000_added_x000_copies 20408ad61ce5 6f0ee96e21ad : 1.118461 s, 0.063822 s, - 1.054639 s, ? 0.057062
mozilla-try x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 2.206083 s, 0.088038 s, - 2.118045 s, ? 0.039907
mozilla-try x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 0.089404 s, 0.007389 s, - 0.082015 s, ? 0.082647
mozilla-try x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 0.733043 s, 0.004868 s, - 0.728175 s, ? 0.006641
mozilla-try x000_revs_x000_added_x000_copies 1346fd0130e4 4c65cbdabc1f : 1.163367 s, 0.222450 s, - 0.940917 s, ? 0.191212
mozilla-try x0000_revs_x_added_0_copies 63519bfd42ee a36a2a865d92 : 0.085456 s, 0.370675 s, + 0.285219 s, ? 4.337612
mozilla-try x0000_revs_x_added_x_copies 9fe69ff0762d bcabf2a78927 : 0.083601 s, 0.358020 s, + 0.274419 s, ? 4.282485
mozilla-try x0000_revs_xx000_added_x_copies 156f6e2674f2 4d0f2c178e66 : 7.366614 s, 0.145235 s, - 7.221379 s, ? 0.019715
mozilla-try x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 6.664464 s, 0.037606 s, - 6.626858 s, ? 0.005643
mozilla-try x0000_revs_xx000_added_x000_copies 89294cd501d9 7ccb2fc7ccb5 : 7.467836 s, 7.382439 s, - 0.085397 s, ? 0.988565
mozilla-try x0000_revs_x0000_added_x0000_copies e928c65095ed e951f4ad123a : 9.801294 s, 7.273506 s, - 2.527788 s, ? 0.742097
mozilla-try x00000_revs_x_added_0_copies 6a320851d377 1ebb79acd503 : 0.091886 s, killed
mozilla-try x00000_revs_x00000_added_0_copies dc8a3ca7010e d16fde900c9c : 26.491140 s, 1.074593 s, -25.416547 s, ? 0.040564
mozilla-try x00000_revs_x_added_x_copies 5173c4b6f97c 95d83ee7242d : 0.092863 s, killed
mozilla-try x00000_revs_x000_added_x_copies 9126823d0e9c ca82787bb23c : 0.226823 s, killed
mozilla-try x00000_revs_x0000_added_x0000_copies 8d3fafa80d4b eb884023b810 : 18.914630 s, 27.746195 s, + 8.831565 s, ? 1.466917
mozilla-try x00000_revs_x00000_added_x0000_copies 1b661134e2ca 1ae03d022d6d : 21.198903 s, killed
mozilla-try x00000_revs_x00000_added_x000_copies 9b2a99adc05e 8e29777b48e6 : 24.952268 s, killed
Differential Revision: https://phab.mercurial-scm.org/D9296
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 02 Nov 2020 11:03:56 +0100 |
parents | da178b816812 |
children | 9dc1351d0b5f |
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 |
45882
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
16 import difflib |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
17 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
18 # 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
|
19 from . import pycompat |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
20 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
21 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
22 def _tobytes(exc): |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
23 """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
|
24 if not exc.args: |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
25 return b'' |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
26 if len(exc.args) == 1: |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
27 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
|
28 return b'(%s)' % b', '.join(b"'%s'" % pycompat.bytestr(a) for a in exc.args) |
7633 | 29 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
30 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
31 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
|
32 """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
|
33 |
29510
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29509
diff
changeset
|
34 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
|
35 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
|
36 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
37 |
25248
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
38 def __init__(self, *args, **kw): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43418
diff
changeset
|
39 self.hint = kw.pop('hint', None) |
29510
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29509
diff
changeset
|
40 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
|
41 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
42 |
39776
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
43 class StorageError(Hint, Exception): |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
44 """Raised when an error occurs in a storage layer. |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
45 |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
46 Usually subclassed by a storage-specific exception. |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
47 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
48 |
39776
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
49 __bytes__ = _tobytes |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
50 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
51 |
39776
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
52 class RevlogError(StorageError): |
45775
5bb900885311
errors: remove unnecessary override of __bytes__ in RevlogError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45682
diff
changeset
|
53 pass |
7633 | 54 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
55 |
43034
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
56 class SidedataHashError(RevlogError): |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
57 def __init__(self, key, expected, got): |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
58 self.sidedatakey = key |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
59 self.expecteddigest = expected |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
60 self.actualdigest = got |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
61 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
62 |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
63 class FilteredIndexError(IndexError): |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
64 __bytes__ = _tobytes |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
65 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
66 |
7633 | 67 class LookupError(RevlogError, KeyError): |
68 def __init__(self, name, index, message): | |
69 self.name = name | |
24038
10d02cd18604
error: store filename and message on LookupError for later
Martin von Zweigbergk <martinvonz@google.com>
parents:
23415
diff
changeset
|
70 self.index = index |
24137
dcfdfd63bde4
error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents:
24120
diff
changeset
|
71 # 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
|
72 # 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
|
73 self.lookupmessage = message |
36541
c6a7b99f150a
error: fix isinstnace check to use bytes instead of str
Augie Fackler <augie@google.com>
parents:
35105
diff
changeset
|
74 if isinstance(name, bytes) and len(name) == 20: |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
75 from .node import short |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
76 |
7633 | 77 name = short(name) |
45503
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
78 # if name is a binary node, it can be None |
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
79 RevlogError.__init__( |
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
80 self, b'%s@%s: %s' % (index, pycompat.bytestr(name), message) |
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
81 ) |
7633 | 82 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
83 def __bytes__(self): |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
84 return RevlogError.__bytes__(self) |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
85 |
7633 | 86 def __str__(self): |
87 return RevlogError.__str__(self) | |
7636 | 88 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
89 |
38841
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38607
diff
changeset
|
90 class AmbiguousPrefixLookupError(LookupError): |
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38607
diff
changeset
|
91 pass |
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38607
diff
changeset
|
92 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
93 |
23015
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
94 class FilteredLookupError(LookupError): |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
95 pass |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
96 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
97 |
18855
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
98 class ManifestLookupError(LookupError): |
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
99 pass |
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
100 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
101 |
11287
b901bb751999
error: change ParseError to CommandError
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
102 class CommandError(Exception): |
7636 | 103 """Exception raised on errors in parsing the command line.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
104 |
45678
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
105 def __init__(self, command, message): |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
106 self.command = command |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
107 self.message = message |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
108 super(CommandError, self).__init__() |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
109 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
110 __bytes__ = _tobytes |
7637 | 111 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
112 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
113 class UnknownCommand(Exception): |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
114 """Exception raised if command is not in the command table.""" |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
115 |
45680
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
116 def __init__(self, command, all_commands=None): |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
117 self.command = command |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
118 self.all_commands = all_commands |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
119 super(UnknownCommand, self).__init__() |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
120 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
121 __bytes__ = _tobytes |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
122 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
123 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
124 class AmbiguousCommand(Exception): |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
125 """Exception raised if command shortcut matches more than one command.""" |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
126 |
45679
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
127 def __init__(self, prefix, matches): |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
128 self.prefix = prefix |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
129 self.matches = matches |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
130 super(AmbiguousCommand, self).__init__() |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
131 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
132 __bytes__ = _tobytes |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
133 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
134 |
45825
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
135 class WorkerError(Exception): |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
136 """Exception raised when a worker process dies.""" |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
137 |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
138 def __init__(self, status_code): |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
139 self.status_code = status_code |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
140 |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
141 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
142 class InterventionRequired(Hint, Exception): |
18931
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
143 """Exception raised when a command requires human intervention.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
144 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
145 __bytes__ = _tobytes |
18931
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
146 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
147 |
45151
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
148 class ConflictResolutionRequired(InterventionRequired): |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
149 """Exception raised when a continuable command required merge conflict resolution.""" |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
150 |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
151 def __init__(self, opname): |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
152 from .i18n import _ |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
153 |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
154 self.opname = opname |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
155 InterventionRequired.__init__( |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
156 self, |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
157 _( |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
158 b"unresolved conflicts (see 'hg resolve', then 'hg %s --continue')" |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
159 ) |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
160 % opname, |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
161 ) |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
162 |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
163 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
164 class Abort(Hint, Exception): |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
165 """Raised if a command needs to print an error and exit.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
166 |
45682
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
167 def __init__(self, message, hint=None): |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
168 self.message = message |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
169 self.hint = hint |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
170 # Pass the message into the Exception constructor to help extensions |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
171 # that look for exc.args[0]. |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
172 Exception.__init__(self, message) |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
173 |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
174 def __bytes__(self): |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
175 return self.message |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
176 |
43417
822202e72f69
py3: do not reimplement Abort.__str__() on Python 2
Yuya Nishihara <yuya@tcha.org>
parents:
43402
diff
changeset
|
177 if pycompat.ispy3: |
822202e72f69
py3: do not reimplement Abort.__str__() on Python 2
Yuya Nishihara <yuya@tcha.org>
parents:
43402
diff
changeset
|
178 |
822202e72f69
py3: do not reimplement Abort.__str__() on Python 2
Yuya Nishihara <yuya@tcha.org>
parents:
43402
diff
changeset
|
179 def __str__(self): |
43418
ca3dca416f8d
py3: add inline comment about encoding issue of str(Abort())
Yuya Nishihara <yuya@tcha.org>
parents:
43417
diff
changeset
|
180 # the output would be unreadable if the message was translated, |
ca3dca416f8d
py3: add inline comment about encoding issue of str(Abort())
Yuya Nishihara <yuya@tcha.org>
parents:
43417
diff
changeset
|
181 # but do not replace it with encoding.strfromlocal(), which |
ca3dca416f8d
py3: add inline comment about encoding issue of str(Abort())
Yuya Nishihara <yuya@tcha.org>
parents:
43417
diff
changeset
|
182 # may raise another exception. |
43417
822202e72f69
py3: do not reimplement Abort.__str__() on Python 2
Yuya Nishihara <yuya@tcha.org>
parents:
43402
diff
changeset
|
183 return pycompat.sysstr(self.__bytes__()) |
43402
40bf3d7ecc42
py3: add a __str__ method to Abort
Denis Laxalde <denis@laxalde.org>
parents:
43077
diff
changeset
|
184 |
45885
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45884
diff
changeset
|
185 def format(self): |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45884
diff
changeset
|
186 from .i18n import _ |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45884
diff
changeset
|
187 |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45884
diff
changeset
|
188 message = _(b"abort: %s\n") % self.message |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45884
diff
changeset
|
189 if self.hint: |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45884
diff
changeset
|
190 message += _(b"(%s)\n") % self.hint |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45884
diff
changeset
|
191 return message |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45884
diff
changeset
|
192 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
193 |
45827
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
194 class InputError(Abort): |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
195 """Indicates that the user made an error in their input. |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
196 |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
197 Examples: Invalid command, invalid flags, invalid revision. |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
198 """ |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
199 |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
200 |
45840
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
201 class StateError(Abort): |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
202 """Indicates that the operation might work if retried in a different state. |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
203 |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
204 Examples: Unresolved merge conflicts, unfinished operations. |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
205 """ |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
206 |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
207 |
45877
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
208 class CanceledError(Abort): |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
209 """Indicates that the user canceled the operation. |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
210 |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
211 Examples: Close commit editor with error status, quit chistedit. |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
212 """ |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
213 |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
214 |
26692
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
215 class HookLoadError(Abort): |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
216 """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
|
217 |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
218 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
|
219 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
220 |
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
|
221 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
|
222 """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
|
223 |
cdbb85489c41
hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23016
diff
changeset
|
224 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
|
225 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
226 |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
227 class ConfigError(Abort): |
22359
e3714b927af5
error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents:
21747
diff
changeset
|
228 """Exception raised when parsing config files""" |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
7947
diff
changeset
|
229 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
230 |
26683
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
231 class UpdateAbort(Abort): |
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
232 """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
|
233 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
234 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
235 class MergeDestAbort(Abort): |
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
236 """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
|
237 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
238 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
239 class NoMergeDestAbort(MergeDestAbort): |
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
240 """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
|
241 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
242 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
243 class ManyMergeDestAbort(MergeDestAbort): |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
29536
diff
changeset
|
244 """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
|
245 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
246 |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
247 class ResponseExpected(Abort): |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
248 """Raised when an EOF is received for a prompt""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
249 |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
250 def __init__(self): |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
251 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
252 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
253 Abort.__init__(self, _(b'response expected')) |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
254 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
255 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
256 class OutOfBandError(Hint, Exception): |
22359
e3714b927af5
error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents:
21747
diff
changeset
|
257 """Exception raised when a remote repo reports failure""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
258 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
259 __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
|
260 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
261 |
45887
7eb221b9af6c
errors: make ParseError a subtype of Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
45885
diff
changeset
|
262 class ParseError(Abort): |
24040
7f375d2de945
error: update docstring on ParseError
Augie Fackler <augie@google.com>
parents:
24038
diff
changeset
|
263 """Raised when parsing config files and {rev,file}sets (msg[, pos])""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
264 |
45776
0fc8b066928a
errors: name arguments to ParseError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45775
diff
changeset
|
265 def __init__(self, message, location=None, hint=None): |
45887
7eb221b9af6c
errors: make ParseError a subtype of Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
45885
diff
changeset
|
266 super(ParseError, self).__init__(message, hint=hint) |
45776
0fc8b066928a
errors: name arguments to ParseError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45775
diff
changeset
|
267 self.location = location |
0fc8b066928a
errors: name arguments to ParseError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45775
diff
changeset
|
268 |
45884
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
269 def format(self): |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
270 from .i18n import _ |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
271 |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
272 if self.location is not None: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
273 message = _(b"hg: parse error at %s: %s\n") % ( |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
274 pycompat.bytestr(self.location), |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
275 self.message, |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
276 ) |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
277 else: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
278 message = _(b"hg: parse error: %s\n") % self.message |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
279 if self.hint: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
280 message += _(b"(%s)\n") % self.hint |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
281 return message |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
282 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
283 |
34251
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32616
diff
changeset
|
284 class PatchError(Exception): |
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32616
diff
changeset
|
285 __bytes__ = _tobytes |
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32616
diff
changeset
|
286 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
287 |
45882
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
288 def getsimilar(symbols, value): |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
289 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio() |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
290 # The cutoff for similarity here is pretty arbitrary. It should |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
291 # probably be investigated and tweaked. |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
292 return [s for s in symbols if sim(s) > 0.6] |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
293 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
294 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
295 def similarity_hint(similar): |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
296 from .i18n import _ |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
297 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
298 if len(similar) == 1: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
299 return _(b"did you mean %s?") % similar[0] |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
300 elif similar: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
301 ss = b", ".join(sorted(similar)) |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
302 return _(b"did you mean one of %s?") % ss |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
303 else: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
304 return None |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
305 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
306 |
24217
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
307 class UnknownIdentifier(ParseError): |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
308 """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
|
309 |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
310 def __init__(self, function, symbols): |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
311 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
312 |
45883
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
313 similar = getsimilar(symbols, function) |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
314 hint = similarity_hint(similar) |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
315 |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
316 ParseError.__init__( |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
317 self, _(b"unknown identifier: %s") % function, hint=hint |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
318 ) |
24217
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
319 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
320 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
321 class RepoError(Hint, Exception): |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
322 __bytes__ = _tobytes |
7637 | 323 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
324 |
9423
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
325 class RepoLookupError(RepoError): |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
326 pass |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
327 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
328 |
23016
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
329 class FilteredRepoLookupError(RepoLookupError): |
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
330 pass |
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
331 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
332 |
7637 | 333 class CapabilityError(RepoError): |
334 pass | |
7640 | 335 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
336 |
13447
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
337 class RequirementError(RepoError): |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
338 """Exception raised if .hg/requires has an unknown entry.""" |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
339 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
340 |
31959
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
341 class StdioError(IOError): |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
342 """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
|
343 |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
344 def __init__(self, err): |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
345 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
|
346 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
347 # 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
|
348 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
349 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
350 class UnsupportedMergeRecords(Abort): |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
351 def __init__(self, recordtypes): |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
352 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
353 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
354 self.recordtypes = sorted(recordtypes) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
355 s = b' '.join(self.recordtypes) |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
356 Abort.__init__( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
357 self, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
358 _(b'unsupported merge state records: %s') % s, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
359 hint=_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
360 b'see https://mercurial-scm.org/wiki/MergeStateRecords for ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
361 b'more information' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
362 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
363 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
364 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
365 |
32596
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
366 class UnknownVersion(Abort): |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
367 """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
|
368 """ |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
369 |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
370 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
|
371 self.version = version |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
372 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
|
373 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
374 |
7640 | 375 class LockError(IOError): |
376 def __init__(self, errno, strerror, filename, desc): | |
377 IOError.__init__(self, errno, strerror, filename) | |
378 self.desc = desc | |
379 | |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
380 # 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
|
381 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
382 |
7640 | 383 class LockHeld(LockError): |
384 def __init__(self, errno, filename, desc, locker): | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
385 LockError.__init__(self, errno, b'Lock held', filename, desc) |
7640 | 386 self.locker = locker |
387 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
388 |
7640 | 389 class LockUnavailable(LockError): |
390 pass | |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
391 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
392 |
26355
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
393 # 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
|
394 class LockInheritanceContractViolation(RuntimeError): |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
395 __bytes__ = _tobytes |
26355
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
396 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
397 |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
398 class ResponseError(Exception): |
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
399 """Raised to print an error with part of output and exit.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
400 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
401 __bytes__ = _tobytes |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
402 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
403 |
7644
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
404 # derived from KeyboardInterrupt to simplify some breakout code |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
405 class SignalInterrupt(KeyboardInterrupt): |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
406 """Exception raised on SIGTERM and SIGHUP.""" |
7646 | 407 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
408 |
7646 | 409 class SignatureError(Exception): |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
410 __bytes__ = _tobytes |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
411 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
412 |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
413 class PushRaced(RuntimeError): |
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
414 """An exception raised during unbundling that indicate a push race""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
415 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
416 __bytes__ = _tobytes |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
417 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
418 |
32340
9c023179e8d0
error: add hint to ProgrammingError
Yuya Nishihara <yuya@tcha.org>
parents:
32023
diff
changeset
|
419 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
|
420 """Raised if a mercurial (core or extension) developer made a mistake""" |
39579
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39559
diff
changeset
|
421 |
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39559
diff
changeset
|
422 def __init__(self, msg, *args, **kwargs): |
39596
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39579
diff
changeset
|
423 # On Python 3, turn the message back into a string since this is |
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39579
diff
changeset
|
424 # an internal-only error that won't be printed except in a |
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39579
diff
changeset
|
425 # stack traces. |
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39579
diff
changeset
|
426 msg = pycompat.sysstr(msg) |
39579
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39559
diff
changeset
|
427 super(ProgrammingError, self).__init__(msg, *args, **kwargs) |
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39559
diff
changeset
|
428 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
429 __bytes__ = _tobytes |
30573 | 430 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
431 |
32402
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32340
diff
changeset
|
432 class WdirUnsupported(Exception): |
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32340
diff
changeset
|
433 """An exception which is raised when 'wdir()' is not supported""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
434 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
435 __bytes__ = _tobytes |
32402
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32340
diff
changeset
|
436 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
437 |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
438 # bundle2 related errors |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
439 class BundleValueError(ValueError): |
21621
b6eb56a9335d
bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21620
diff
changeset
|
440 """error raised when bundle2 cannot be processed""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
441 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
442 __bytes__ = _tobytes |
21620
6eaa71b2a3cc
bundle2: introduce a parttype attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21618
diff
changeset
|
443 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
444 |
26393
cff70549a959
bundle2: rename error exception class for unsupported feature
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26355
diff
changeset
|
445 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
|
446 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
|
447 self.parttype = parttype |
21621
b6eb56a9335d
bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21620
diff
changeset
|
448 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
|
449 self.values = values |
21627
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
450 if self.parttype is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
451 msg = b'Stream Parameter' |
21627
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
452 else: |
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
453 msg = parttype |
26394
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
454 entries = self.params |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
455 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
|
456 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
|
457 entries = [] |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
458 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
|
459 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
|
460 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
|
461 entries.append(val) |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
462 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
463 entries.append(b"%s=%r" % (par, pycompat.maybebytestr(val))) |
26394
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
464 if entries: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
465 msg = b'%s - %s' % (msg, b', '.join(entries)) |
21747
fecead61d222
error: restore python 2.4 compatibility for BundleValueError
Brendan Cully <brendan@kublai.com>
parents:
21627
diff
changeset
|
466 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
|
467 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
468 |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
469 class ReadOnlyPartError(RuntimeError): |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
470 """error raised when code tries to alter a part being generated""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
471 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
472 __bytes__ = _tobytes |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
473 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
474 |
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
|
475 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
|
476 """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
|
477 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
478 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
479 self, partid, namespace=None, key=None, new=None, old=None, ret=None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
480 ): |
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
|
481 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
|
482 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
|
483 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
|
484 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
|
485 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
|
486 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
|
487 # no i18n expected to be processed into a better message |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
488 Abort.__init__( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
489 self, b'failed to update value for "%s/%s"' % (namespace, key) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
490 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
491 |
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
|
492 |
39777
b63dee7bd0d9
global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
493 class CensoredNodeError(StorageError): |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
494 """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
|
495 |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
496 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
|
497 """ |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
498 |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
499 def __init__(self, filename, node, tombstone): |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
500 from .node import short |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
501 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
502 StorageError.__init__(self, b'%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
|
503 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
|
504 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
505 |
39777
b63dee7bd0d9
global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
506 class CensoredBaseError(StorageError): |
24120
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
507 """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
|
508 |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
509 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
|
510 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
|
511 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
|
512 """ |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
513 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
514 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
515 class InvalidBundleSpecification(Exception): |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
516 """error raised when a bundle specification is invalid. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
517 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
518 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
|
519 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
520 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
521 __bytes__ = _tobytes |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
522 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
523 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
524 class UnsupportedBundleSpecification(Exception): |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
525 """error raised when a bundle specification is not supported.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
526 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
527 __bytes__ = _tobytes |
29536
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
528 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
529 |
29536
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
530 class CorruptedState(Exception): |
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
531 """error raised when a command is not able to read its state from file""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
532 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
533 __bytes__ = _tobytes |
32002
bf855efe5664
httppeer: wrap HTTPResponse.read() globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31959
diff
changeset
|
534 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
535 |
32023
a29580905771
error: rename RichIOError to PeerTransportError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32002
diff
changeset
|
536 class PeerTransportError(Abort): |
a29580905771
error: rename RichIOError to PeerTransportError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32002
diff
changeset
|
537 """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
|
538 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
539 |
35105
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34251
diff
changeset
|
540 class InMemoryMergeConflictsError(Exception): |
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34251
diff
changeset
|
541 """Exception raised when merge conflicts arose during an in-memory merge.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
542 |
35105
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34251
diff
changeset
|
543 __bytes__ = _tobytes |
39559
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
544 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
545 |
39559
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
546 class WireprotoCommandError(Exception): |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
547 """Represents an error during execution of a wire protocol command. |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
548 |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
549 Should only be thrown by wire protocol version 2 commands. |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
550 |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
551 The error is a formatter string and an optional iterable of arguments. |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
552 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
553 |
39559
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
554 def __init__(self, message, args=None): |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
555 self.message = message |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
556 self.messageargs = args |