##// END OF EJS Templates
rust: implement conversion of RevlogError into HgError...
Arseniy Alekseyev -
r53241:09a36de5 default
parent child Browse files
Show More
@@ -1,5 +1,6
1 use crate::config::ConfigValueParseError;
1 use crate::config::ConfigValueParseError;
2 use crate::exit_codes;
2 use crate::exit_codes;
3 use crate::revlog::RevlogError;
3 use crate::utils::hg_path::HgPathError;
4 use crate::utils::hg_path::HgPathError;
4 use std::fmt;
5 use std::fmt;
5
6
@@ -103,6 +104,14 impl HgError {
103 hint,
104 hint,
104 }
105 }
105 }
106 }
107
108 pub fn abort_simple(explanation: impl Into<String>) -> Self {
109 HgError::Abort {
110 message: explanation.into(),
111 detailed_exit_code: exit_codes::ABORT,
112 hint: None,
113 }
114 }
106 }
115 }
107
116
108 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly?
117 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly?
@@ -235,3 +244,22 impl<T> HgResultExt<T> for Result<T, HgE
235 }
244 }
236 }
245 }
237 }
246 }
247
248 impl From<RevlogError> for HgError {
249 fn from(err: RevlogError) -> HgError {
250 match err {
251 RevlogError::WDirUnsupported => HgError::abort_simple(
252 "abort: working directory revision cannot be specified",
253 ),
254 RevlogError::InvalidRevision(r) => HgError::abort_simple(format!(
255 "abort: invalid revision identifier: {}",
256 r
257 )),
258 RevlogError::AmbiguousPrefix(r) => HgError::abort_simple(format!(
259 "abort: ambiguous revision identifier: {}",
260 r
261 )),
262 RevlogError::Other(error) => error,
263 }
264 }
265 }
@@ -206,20 +206,8 impl From<ConfigParseError> for CommandE
206
206
207 impl From<RevlogError> for CommandError {
207 impl From<RevlogError> for CommandError {
208 fn from(err: RevlogError) -> CommandError {
208 fn from(err: RevlogError) -> CommandError {
209 match err {
209 let err: HgError = err.into();
210 RevlogError::WDirUnsupported => CommandError::abort(
210 err.into()
211 "abort: working directory revision cannot be specified",
212 ),
213 RevlogError::InvalidRevision(r) => CommandError::abort(format!(
214 "abort: invalid revision identifier: {}",
215 r
216 )),
217 RevlogError::AmbiguousPrefix(r) => CommandError::abort(format!(
218 "abort: ambiguous revision identifier: {}",
219 r
220 )),
221 RevlogError::Other(error) => error.into(),
222 }
223 }
211 }
224 }
212 }
225
213
General Comments 0
You need to be logged in to leave comments. Login now