Mercurial > public > mercurial-scm > hg-stable
annotate rust/hg-core/src/errors.rs @ 52552:66e34bc44280
rhg: set the expected temp file permissions (0o666 minus umask)
This continues the theme of a48c688d3e80, and fixes the bug #6375,
which was causing some problems for us, where a non-group-readable
file can't be copied, which breaks some tools that copy the repo.
This affects both the `checkexec` file and the temporary file we
use for filesystem time measurement, since either of these files
remaining on disk can cause this problem, and the 0666 permissions
are just the better default here.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Thu, 05 Dec 2024 13:17:32 +0000 |
parents | 09a36de53b60 |
children |
rev | line source |
---|---|
46637
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
1 use crate::config::ConfigValueParseError; |
47413
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
2 use crate::exit_codes; |
52376
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
3 use crate::revlog::RevlogError; |
52074
de317a87ea6a
rust-pathauditor: match more of Python's behavior and display messages
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49697
diff
changeset
|
4 use crate::utils::hg_path::HgPathError; |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
5 use std::fmt; |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
6 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
7 /// Common error cases that can happen in many different APIs |
46637
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
8 #[derive(Debug, derive_more::From)] |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
9 pub enum HgError { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
10 IoError { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
11 error: std::io::Error, |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
12 context: IoErrorContext, |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
13 }, |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
14 |
46544
f031fe1c6ede
rhg: Abort based on config on share-safe mismatch
Simon Sapin <simon.sapin@octobus.net>
parents:
46542
diff
changeset
|
15 /// A file under `.hg/` normally only written by Mercurial is not in the |
f031fe1c6ede
rhg: Abort based on config on share-safe mismatch
Simon Sapin <simon.sapin@octobus.net>
parents:
46542
diff
changeset
|
16 /// expected format. This indicates a bug in Mercurial, filesystem |
f031fe1c6ede
rhg: Abort based on config on share-safe mismatch
Simon Sapin <simon.sapin@octobus.net>
parents:
46542
diff
changeset
|
17 /// corruption, or hardware failure. |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
18 /// |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
19 /// The given string is a short explanation for users, not intended to be |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
20 /// machine-readable. |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
21 CorruptedRepository(String), |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
22 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
23 /// The respository or requested operation involves a feature not |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
24 /// supported by the Rust implementation. Falling back to the Python |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
25 /// implementation may or may not work. |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
26 /// |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
27 /// The given string is a short explanation for users, not intended to be |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
28 /// machine-readable. |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
29 UnsupportedFeature(String), |
46544
f031fe1c6ede
rhg: Abort based on config on share-safe mismatch
Simon Sapin <simon.sapin@octobus.net>
parents:
46542
diff
changeset
|
30 |
f031fe1c6ede
rhg: Abort based on config on share-safe mismatch
Simon Sapin <simon.sapin@octobus.net>
parents:
46542
diff
changeset
|
31 /// Operation cannot proceed for some other reason. |
f031fe1c6ede
rhg: Abort based on config on share-safe mismatch
Simon Sapin <simon.sapin@octobus.net>
parents:
46542
diff
changeset
|
32 /// |
47413
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
33 /// The message is a short explanation for users, not intended to be |
46544
f031fe1c6ede
rhg: Abort based on config on share-safe mismatch
Simon Sapin <simon.sapin@octobus.net>
parents:
46542
diff
changeset
|
34 /// machine-readable. |
47413
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
35 Abort { |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
36 message: String, |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
37 detailed_exit_code: exit_codes::ExitCode, |
49501
9f14126cfc4c
rust: add support for hints in error messages
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49209
diff
changeset
|
38 hint: Option<String>, |
47413
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
39 }, |
46637
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
40 |
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
41 /// A configuration value is not in the expected syntax. |
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
42 /// |
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
43 /// These errors can happen in many places in the code because values are |
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
44 /// parsed lazily as the file-level parser does not know the expected type |
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
45 /// and syntax of each value. |
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
46 #[from] |
bc08c2331f99
rust: Add a `ConfigValueParseError` variant to common errors
Simon Sapin <simon.sapin@octobus.net>
parents:
46544
diff
changeset
|
47 ConfigValueParseError(ConfigValueParseError), |
49209
3f86ee422095
censor: make rhg fall back to python when encountering a censored node
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48464
diff
changeset
|
48 |
3f86ee422095
censor: make rhg fall back to python when encountering a censored node
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48464
diff
changeset
|
49 /// Censored revision data. |
3f86ee422095
censor: make rhg fall back to python when encountering a censored node
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48464
diff
changeset
|
50 CensoredNodeError, |
49697
491f3dd080eb
dirstate: deal with read-race for pure rust code path (rhg)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49501
diff
changeset
|
51 /// A race condition has been detected. This *must* be handled locally |
491f3dd080eb
dirstate: deal with read-race for pure rust code path (rhg)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49501
diff
changeset
|
52 /// and not directly surface to the user. |
491f3dd080eb
dirstate: deal with read-race for pure rust code path (rhg)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49501
diff
changeset
|
53 RaceDetected(String), |
52074
de317a87ea6a
rust-pathauditor: match more of Python's behavior and display messages
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49697
diff
changeset
|
54 /// An invalid path was found |
de317a87ea6a
rust-pathauditor: match more of Python's behavior and display messages
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49697
diff
changeset
|
55 Path(HgPathError), |
52183
96b113d22b34
rust-update: handle SIGINT from long-running update threads
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
56 /// An interrupt was received and we need to stop whatever we're doing |
96b113d22b34
rust-update: handle SIGINT from long-running update threads
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
57 InterruptReceived, |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
58 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
59 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
60 /// Details about where an I/O error happened |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
61 #[derive(Debug)] |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
62 pub enum IoErrorContext { |
47779
cf5f8da2244c
rhg: Propagate permission errors when finding a repository
Simon Sapin <simon.sapin@octobus.net>
parents:
47413
diff
changeset
|
63 /// `std::fs::metadata` |
cf5f8da2244c
rhg: Propagate permission errors when finding a repository
Simon Sapin <simon.sapin@octobus.net>
parents:
47413
diff
changeset
|
64 ReadingMetadata(std::path::PathBuf), |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
65 ReadingFile(std::path::PathBuf), |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
66 WritingFile(std::path::PathBuf), |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
67 RemovingFile(std::path::PathBuf), |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
68 RenamingFile { |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
69 from: std::path::PathBuf, |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
70 to: std::path::PathBuf, |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
71 }, |
52297
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
72 CopyingFile { |
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
73 from: std::path::PathBuf, |
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
74 to: std::path::PathBuf, |
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
75 }, |
46753
97ac588b6d9e
rhg: Don?t make repository path absolute too early
Simon Sapin <simon.sapin@octobus.net>
parents:
46748
diff
changeset
|
76 /// `std::fs::canonicalize` |
97ac588b6d9e
rhg: Don?t make repository path absolute too early
Simon Sapin <simon.sapin@octobus.net>
parents:
46748
diff
changeset
|
77 CanonicalizingPath(std::path::PathBuf), |
46542
2845892dd489
rust: Parse system and user configuration
Simon Sapin <simon.sapin@octobus.net>
parents:
46524
diff
changeset
|
78 /// `std::env::current_dir` |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
79 CurrentDir, |
46542
2845892dd489
rust: Parse system and user configuration
Simon Sapin <simon.sapin@octobus.net>
parents:
46524
diff
changeset
|
80 /// `std::env::current_exe` |
2845892dd489
rust: Parse system and user configuration
Simon Sapin <simon.sapin@octobus.net>
parents:
46524
diff
changeset
|
81 CurrentExe, |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
82 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
83 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
84 impl HgError { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
85 pub fn corrupted(explanation: impl Into<String>) -> Self { |
46511
43d63979a75e
rust: use HgError in RevlogError and Vfs
Simon Sapin <simon.sapin@octobus.net>
parents:
46506
diff
changeset
|
86 // TODO: capture a backtrace here and keep it in the error value |
43d63979a75e
rust: use HgError in RevlogError and Vfs
Simon Sapin <simon.sapin@octobus.net>
parents:
46506
diff
changeset
|
87 // to aid debugging? |
43d63979a75e
rust: use HgError in RevlogError and Vfs
Simon Sapin <simon.sapin@octobus.net>
parents:
46506
diff
changeset
|
88 // https://doc.rust-lang.org/std/backtrace/struct.Backtrace.html |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
89 HgError::CorruptedRepository(explanation.into()) |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
90 } |
46524
d03b0601e0eb
rhg: initial support for shared repositories
Simon Sapin <simon.sapin@octobus.net>
parents:
46511
diff
changeset
|
91 |
d03b0601e0eb
rhg: initial support for shared repositories
Simon Sapin <simon.sapin@octobus.net>
parents:
46511
diff
changeset
|
92 pub fn unsupported(explanation: impl Into<String>) -> Self { |
d03b0601e0eb
rhg: initial support for shared repositories
Simon Sapin <simon.sapin@octobus.net>
parents:
46511
diff
changeset
|
93 HgError::UnsupportedFeature(explanation.into()) |
d03b0601e0eb
rhg: initial support for shared repositories
Simon Sapin <simon.sapin@octobus.net>
parents:
46511
diff
changeset
|
94 } |
47413
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
95 |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
96 pub fn abort( |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
97 explanation: impl Into<String>, |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
98 exit_code: exit_codes::ExitCode, |
49501
9f14126cfc4c
rust: add support for hints in error messages
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49209
diff
changeset
|
99 hint: Option<String>, |
47413
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
100 ) -> Self { |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
101 HgError::Abort { |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
102 message: explanation.into(), |
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
103 detailed_exit_code: exit_code, |
49501
9f14126cfc4c
rust: add support for hints in error messages
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49209
diff
changeset
|
104 hint, |
47413
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
105 } |
46544
f031fe1c6ede
rhg: Abort based on config on share-safe mismatch
Simon Sapin <simon.sapin@octobus.net>
parents:
46542
diff
changeset
|
106 } |
52376
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
107 |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
108 pub fn abort_simple(explanation: impl Into<String>) -> Self { |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
109 HgError::Abort { |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
110 message: explanation.into(), |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
111 detailed_exit_code: exit_codes::ABORT, |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
112 hint: None, |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
113 } |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
114 } |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
115 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
116 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
117 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly? |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
118 impl fmt::Display for HgError { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
119 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
120 match self { |
47413
6e49769b7f97
rhg: add exit code to HgError::Abort()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46799
diff
changeset
|
121 HgError::Abort { message, .. } => write!(f, "{}", message), |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
122 HgError::IoError { error, context } => { |
46744
3d692e724d06
rhg: Align config file parse error formatting with Python
Simon Sapin <simon.sapin@octobus.net>
parents:
46638
diff
changeset
|
123 write!(f, "abort: {}: {}", context, error) |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
124 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
125 HgError::CorruptedRepository(explanation) => { |
46748
12d59eec7f1d
rhg: Align with Python on some more error messages
Simon Sapin <simon.sapin@octobus.net>
parents:
46744
diff
changeset
|
126 write!(f, "abort: {}", explanation) |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
127 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
128 HgError::UnsupportedFeature(explanation) => { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
129 write!(f, "unsupported feature: {}", explanation) |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
130 } |
49209
3f86ee422095
censor: make rhg fall back to python when encountering a censored node
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48464
diff
changeset
|
131 HgError::CensoredNodeError => { |
3f86ee422095
censor: make rhg fall back to python when encountering a censored node
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48464
diff
changeset
|
132 write!(f, "encountered a censored node") |
3f86ee422095
censor: make rhg fall back to python when encountering a censored node
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48464
diff
changeset
|
133 } |
46799
bcdcb4423ae3
rhg: Add more conversions between error types
Simon Sapin <simon.sapin@octobus.net>
parents:
46753
diff
changeset
|
134 HgError::ConfigValueParseError(error) => error.fmt(f), |
49697
491f3dd080eb
dirstate: deal with read-race for pure rust code path (rhg)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49501
diff
changeset
|
135 HgError::RaceDetected(context) => { |
491f3dd080eb
dirstate: deal with read-race for pure rust code path (rhg)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49501
diff
changeset
|
136 write!(f, "encountered a race condition {context}") |
491f3dd080eb
dirstate: deal with read-race for pure rust code path (rhg)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49501
diff
changeset
|
137 } |
52074
de317a87ea6a
rust-pathauditor: match more of Python's behavior and display messages
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49697
diff
changeset
|
138 HgError::Path(hg_path_error) => write!(f, "{}", hg_path_error), |
52183
96b113d22b34
rust-update: handle SIGINT from long-running update threads
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
139 HgError::InterruptReceived => write!(f, "interrupt received"), |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
140 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
141 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
142 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
143 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
144 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly? |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
145 impl fmt::Display for IoErrorContext { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
146 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
147 match self { |
47779
cf5f8da2244c
rhg: Propagate permission errors when finding a repository
Simon Sapin <simon.sapin@octobus.net>
parents:
47413
diff
changeset
|
148 IoErrorContext::ReadingMetadata(path) => { |
cf5f8da2244c
rhg: Propagate permission errors when finding a repository
Simon Sapin <simon.sapin@octobus.net>
parents:
47413
diff
changeset
|
149 write!(f, "when reading metadata of {}", path.display()) |
cf5f8da2244c
rhg: Propagate permission errors when finding a repository
Simon Sapin <simon.sapin@octobus.net>
parents:
47413
diff
changeset
|
150 } |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
151 IoErrorContext::ReadingFile(path) => { |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
152 write!(f, "when reading {}", path.display()) |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
153 } |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
154 IoErrorContext::WritingFile(path) => { |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
155 write!(f, "when writing {}", path.display()) |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
156 } |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
157 IoErrorContext::RemovingFile(path) => { |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
158 write!(f, "when removing {}", path.display()) |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
159 } |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
160 IoErrorContext::RenamingFile { from, to } => write!( |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
161 f, |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
162 "when renaming {} to {}", |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
163 from.display(), |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
164 to.display() |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
165 ), |
52297
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
166 IoErrorContext::CopyingFile { from, to } => write!( |
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
167 f, |
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
168 "when copying {} to {}", |
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
169 from.display(), |
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
170 to.display() |
7be39c5110c9
hg-core: add a complete VFS
Rapha?l Gom?s <rgomes@octobus.net>
parents:
52074
diff
changeset
|
171 ), |
46753
97ac588b6d9e
rhg: Don?t make repository path absolute too early
Simon Sapin <simon.sapin@octobus.net>
parents:
46748
diff
changeset
|
172 IoErrorContext::CanonicalizingPath(path) => { |
97ac588b6d9e
rhg: Don?t make repository path absolute too early
Simon Sapin <simon.sapin@octobus.net>
parents:
46748
diff
changeset
|
173 write!(f, "when canonicalizing {}", path.display()) |
97ac588b6d9e
rhg: Don?t make repository path absolute too early
Simon Sapin <simon.sapin@octobus.net>
parents:
46748
diff
changeset
|
174 } |
46744
3d692e724d06
rhg: Align config file parse error formatting with Python
Simon Sapin <simon.sapin@octobus.net>
parents:
46638
diff
changeset
|
175 IoErrorContext::CurrentDir => { |
3d692e724d06
rhg: Align config file parse error formatting with Python
Simon Sapin <simon.sapin@octobus.net>
parents:
46638
diff
changeset
|
176 write!(f, "error getting current working directory") |
3d692e724d06
rhg: Align config file parse error formatting with Python
Simon Sapin <simon.sapin@octobus.net>
parents:
46638
diff
changeset
|
177 } |
3d692e724d06
rhg: Align config file parse error formatting with Python
Simon Sapin <simon.sapin@octobus.net>
parents:
46638
diff
changeset
|
178 IoErrorContext::CurrentExe => { |
3d692e724d06
rhg: Align config file parse error formatting with Python
Simon Sapin <simon.sapin@octobus.net>
parents:
46638
diff
changeset
|
179 write!(f, "error getting current executable") |
3d692e724d06
rhg: Align config file parse error formatting with Python
Simon Sapin <simon.sapin@octobus.net>
parents:
46638
diff
changeset
|
180 } |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
181 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
182 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
183 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
184 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
185 pub trait IoResultExt<T> { |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
186 /// Annotate a possible I/O error as related to a reading a file at the |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
187 /// given path. |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
188 /// |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
189 /// This allows printing something like “File not found when reading |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
190 /// example.txt” instead of just “File not found”. |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
191 /// |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
192 /// Converts a `Result` with `std::io::Error` into one with `HgError`. |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
193 fn when_reading_file(self, path: &std::path::Path) -> Result<T, HgError>; |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
194 |
48464
abeae090ce67
rust: Add Vfs::write_atomic
Simon Sapin <simon.sapin@octobus.net>
parents:
47779
diff
changeset
|
195 fn when_writing_file(self, path: &std::path::Path) -> Result<T, HgError>; |
abeae090ce67
rust: Add Vfs::write_atomic
Simon Sapin <simon.sapin@octobus.net>
parents:
47779
diff
changeset
|
196 |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
197 fn with_context( |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
198 self, |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
199 context: impl FnOnce() -> IoErrorContext, |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
200 ) -> Result<T, HgError>; |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
201 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
202 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
203 impl<T> IoResultExt<T> for std::io::Result<T> { |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
204 fn when_reading_file(self, path: &std::path::Path) -> Result<T, HgError> { |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
205 self.with_context(|| IoErrorContext::ReadingFile(path.to_owned())) |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
206 } |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
207 |
48464
abeae090ce67
rust: Add Vfs::write_atomic
Simon Sapin <simon.sapin@octobus.net>
parents:
47779
diff
changeset
|
208 fn when_writing_file(self, path: &std::path::Path) -> Result<T, HgError> { |
abeae090ce67
rust: Add Vfs::write_atomic
Simon Sapin <simon.sapin@octobus.net>
parents:
47779
diff
changeset
|
209 self.with_context(|| IoErrorContext::WritingFile(path.to_owned())) |
abeae090ce67
rust: Add Vfs::write_atomic
Simon Sapin <simon.sapin@octobus.net>
parents:
47779
diff
changeset
|
210 } |
abeae090ce67
rust: Add Vfs::write_atomic
Simon Sapin <simon.sapin@octobus.net>
parents:
47779
diff
changeset
|
211 |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
212 fn with_context( |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
213 self, |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
214 context: impl FnOnce() -> IoErrorContext, |
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
215 ) -> Result<T, HgError> { |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
216 self.map_err(|error| HgError::IoError { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
217 error, |
46638
1f55cd5b292f
rust: Add a log file rotation utility
Simon Sapin <simon.sapin@octobus.net>
parents:
46637
diff
changeset
|
218 context: context(), |
46506
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
219 }) |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
220 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
221 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
222 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
223 pub trait HgResultExt<T> { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
224 /// Handle missing files separately from other I/O error cases. |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
225 /// |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
226 /// Wraps the `Ok` type in an `Option`: |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
227 /// |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
228 /// * `Ok(x)` becomes `Ok(Some(x))` |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
229 /// * An I/O "not found" error becomes `Ok(None)` |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
230 /// * Other errors are unchanged |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
231 fn io_not_found_as_none(self) -> Result<Option<T>, HgError>; |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
232 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
233 |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
234 impl<T> HgResultExt<T> for Result<T, HgError> { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
235 fn io_not_found_as_none(self) -> Result<Option<T>, HgError> { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
236 match self { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
237 Ok(x) => Ok(Some(x)), |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
238 Err(HgError::IoError { error, .. }) |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
239 if error.kind() == std::io::ErrorKind::NotFound => |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
240 { |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
241 Ok(None) |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
242 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
243 Err(other_error) => Err(other_error), |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
244 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
245 } |
39e9407820ac
rust: Introduce an `HgError` enum for common error cases
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
246 } |
52376
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
247 |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
248 impl From<RevlogError> for HgError { |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
249 fn from(err: RevlogError) -> HgError { |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
250 match err { |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
251 RevlogError::WDirUnsupported => HgError::abort_simple( |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
252 "abort: working directory revision cannot be specified", |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
253 ), |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
254 RevlogError::InvalidRevision(r) => HgError::abort_simple(format!( |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
255 "abort: invalid revision identifier: {}", |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
256 r |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
257 )), |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
258 RevlogError::AmbiguousPrefix(r) => HgError::abort_simple(format!( |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
259 "abort: ambiguous revision identifier: {}", |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
260 r |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
261 )), |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
262 RevlogError::Other(error) => error, |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
263 } |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
264 } |
09a36de53b60
rust: implement conversion of RevlogError into HgError
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
52313
diff
changeset
|
265 } |