Show More
@@ -9,7 +9,7 b'' | |||||
9 |
|
9 | |||
10 | use crate::errors::{HgError, IoResultExt}; |
|
10 | use crate::errors::{HgError, IoResultExt}; | |
11 | use crate::utils::files::{get_bytes_from_path, get_path_from_bytes}; |
|
11 | use crate::utils::files::{get_bytes_from_path, get_path_from_bytes}; | |
12 | use format_bytes::{write_bytes, DisplayBytes}; |
|
12 | use format_bytes::{format_bytes, write_bytes, DisplayBytes}; | |
13 | use lazy_static::lazy_static; |
|
13 | use lazy_static::lazy_static; | |
14 | use regex::bytes::Regex; |
|
14 | use regex::bytes::Regex; | |
15 | use std::collections::HashMap; |
|
15 | use std::collections::HashMap; | |
@@ -187,10 +187,15 b' impl ConfigLayer {' | |||||
187 | map.remove(&m[1]); |
|
187 | map.remove(&m[1]); | |
188 | } |
|
188 | } | |
189 | } else { |
|
189 | } else { | |
|
190 | let message = if bytes.starts_with(b" ") { | |||
|
191 | format_bytes!(b"unexpected leading whitespace: {}", bytes) | |||
|
192 | } else { | |||
|
193 | bytes.to_owned() | |||
|
194 | }; | |||
190 | return Err(ConfigParseError { |
|
195 | return Err(ConfigParseError { | |
191 | origin: ConfigOrigin::File(src.to_owned()), |
|
196 | origin: ConfigOrigin::File(src.to_owned()), | |
192 | line: Some(index + 1), |
|
197 | line: Some(index + 1), | |
193 |
|
|
198 | message, | |
194 | } |
|
199 | } | |
195 | .into()); |
|
200 | .into()); | |
196 | } |
|
201 | } | |
@@ -278,7 +283,7 b' impl DisplayBytes for ConfigOrigin {' | |||||
278 | pub struct ConfigParseError { |
|
283 | pub struct ConfigParseError { | |
279 | pub origin: ConfigOrigin, |
|
284 | pub origin: ConfigOrigin, | |
280 | pub line: Option<usize>, |
|
285 | pub line: Option<usize>, | |
281 |
pub |
|
286 | pub message: Vec<u8>, | |
282 | } |
|
287 | } | |
283 |
|
288 | |||
284 | #[derive(Debug, derive_more::From)] |
|
289 | #[derive(Debug, derive_more::From)] |
@@ -78,10 +78,10 b' impl fmt::Display for HgError {' | |||||
78 | match self { |
|
78 | match self { | |
79 | HgError::Abort(explanation) => write!(f, "{}", explanation), |
|
79 | HgError::Abort(explanation) => write!(f, "{}", explanation), | |
80 | HgError::IoError { error, context } => { |
|
80 | HgError::IoError { error, context } => { | |
81 |
write!(f, "{}: {}", |
|
81 | write!(f, "abort: {}: {}", context, error) | |
82 | } |
|
82 | } | |
83 | HgError::CorruptedRepository(explanation) => { |
|
83 | HgError::CorruptedRepository(explanation) => { | |
84 | write!(f, "corrupted repository: {}", explanation) |
|
84 | write!(f, "abort: corrupted repository: {}", explanation) | |
85 | } |
|
85 | } | |
86 | HgError::UnsupportedFeature(explanation) => { |
|
86 | HgError::UnsupportedFeature(explanation) => { | |
87 | write!(f, "unsupported feature: {}", explanation) |
|
87 | write!(f, "unsupported feature: {}", explanation) | |
@@ -128,8 +128,12 b' impl fmt::Display for IoErrorContext {' | |||||
128 | from.display(), |
|
128 | from.display(), | |
129 | to.display() |
|
129 | to.display() | |
130 | ), |
|
130 | ), | |
131 |
IoErrorContext::CurrentDir => |
|
131 | IoErrorContext::CurrentDir => { | |
132 | IoErrorContext::CurrentExe => write!(f, "current executable"), |
|
132 | write!(f, "error getting current working directory") | |
|
133 | } | |||
|
134 | IoErrorContext::CurrentExe => { | |||
|
135 | write!(f, "error getting current executable") | |||
|
136 | } | |||
133 | } |
|
137 | } | |
134 | } |
|
138 | } | |
135 | } |
|
139 | } |
@@ -87,7 +87,7 b" impl<'a> From<&'a NoRepoInCwdError> for " | |||||
87 | let NoRepoInCwdError { cwd } = error; |
|
87 | let NoRepoInCwdError { cwd } = error; | |
88 | CommandError::Abort { |
|
88 | CommandError::Abort { | |
89 | message: format_bytes!( |
|
89 | message: format_bytes!( | |
90 | b"no repository found in '{}' (.hg not found)!", |
|
90 | b"abort: no repository found in '{}' (.hg not found)!", | |
91 | get_bytes_from_path(cwd) |
|
91 | get_bytes_from_path(cwd) | |
92 | ), |
|
92 | ), | |
93 | } |
|
93 | } | |
@@ -108,19 +108,19 b' impl From<ConfigParseError> for CommandE' | |||||
108 | let ConfigParseError { |
|
108 | let ConfigParseError { | |
109 | origin, |
|
109 | origin, | |
110 | line, |
|
110 | line, | |
111 |
|
|
111 | message, | |
112 | } = error; |
|
112 | } = error; | |
113 | let line_message = if let Some(line_number) = line { |
|
113 | let line_message = if let Some(line_number) = line { | |
114 |
format_bytes!(b" |
|
114 | format_bytes!(b":{}", line_number.to_string().into_bytes()) | |
115 | } else { |
|
115 | } else { | |
116 | Vec::new() |
|
116 | Vec::new() | |
117 | }; |
|
117 | }; | |
118 | CommandError::Abort { |
|
118 | CommandError::Abort { | |
119 | message: format_bytes!( |
|
119 | message: format_bytes!( | |
120 |
b"config |
|
120 | b"config error at {}{}: {}", | |
121 | origin, |
|
121 | origin, | |
122 | line_message, |
|
122 | line_message, | |
123 |
|
|
123 | message | |
124 | ), |
|
124 | ), | |
125 | } |
|
125 | } | |
126 | } |
|
126 | } | |
@@ -130,11 +130,11 b' impl From<(RevlogError, &str)> for Comma' | |||||
130 | fn from((err, rev): (RevlogError, &str)) -> CommandError { |
|
130 | fn from((err, rev): (RevlogError, &str)) -> CommandError { | |
131 | match err { |
|
131 | match err { | |
132 | RevlogError::InvalidRevision => CommandError::abort(format!( |
|
132 | RevlogError::InvalidRevision => CommandError::abort(format!( | |
133 | "invalid revision identifier {}", |
|
133 | "abort: invalid revision identifier: {}", | |
134 | rev |
|
134 | rev | |
135 | )), |
|
135 | )), | |
136 | RevlogError::AmbiguousPrefix => CommandError::abort(format!( |
|
136 | RevlogError::AmbiguousPrefix => CommandError::abort(format!( | |
137 | "ambiguous revision identifier {}", |
|
137 | "abort: ambiguous revision identifier: {}", | |
138 | rev |
|
138 | rev | |
139 | )), |
|
139 | )), | |
140 | RevlogError::Other(error) => error.into(), |
|
140 | RevlogError::Other(error) => error.into(), |
@@ -201,8 +201,7 b' fn exit(' | |||||
201 | if !message.is_empty() { |
|
201 | if !message.is_empty() { | |
202 | // Ignore errors when writing to stderr, we’re already exiting |
|
202 | // Ignore errors when writing to stderr, we’re already exiting | |
203 | // with failure code so there’s not much more we can do. |
|
203 | // with failure code so there’s not much more we can do. | |
204 | let _ = |
|
204 | let _ = ui.write_stderr(&format_bytes!(b"{}\n", message)); | |
205 | ui.write_stderr(&format_bytes!(b"abort: {}\n", message)); |
|
|||
206 | } |
|
205 | } | |
207 | } |
|
206 | } | |
208 | Err(CommandError::UnsupportedFeature { message }) => { |
|
207 | Err(CommandError::UnsupportedFeature { message }) => { |
@@ -45,7 +45,7 b' Unwritable file descriptor' | |||||
45 | Deleted repository |
|
45 | Deleted repository | |
46 | $ rm -rf `pwd` |
|
46 | $ rm -rf `pwd` | |
47 | $ $NO_FALLBACK rhg root |
|
47 | $ $NO_FALLBACK rhg root | |
48 | abort: $ENOENT$: current directory |
|
48 | abort: error getting current working directory: $ENOENT$ | |
49 | [255] |
|
49 | [255] | |
50 |
|
50 | |||
51 | Listing tracked files |
|
51 | Listing tracked files | |
@@ -122,7 +122,7 b' Specifying revisions by changeset ID' | |||||
122 | $ $NO_FALLBACK rhg cat -r cf8b83 file-2 |
|
122 | $ $NO_FALLBACK rhg cat -r cf8b83 file-2 | |
123 | 2 |
|
123 | 2 | |
124 | $ $NO_FALLBACK rhg cat -r c file-2 |
|
124 | $ $NO_FALLBACK rhg cat -r c file-2 | |
125 |
abort: ambiguous revision |
|
125 | abort: ambiguous revision identifier: c | |
126 | [255] |
|
126 | [255] | |
127 | $ $NO_FALLBACK rhg cat -r d file-2 |
|
127 | $ $NO_FALLBACK rhg cat -r d file-2 | |
128 | 2 |
|
128 | 2 |
General Comments 0
You need to be logged in to leave comments.
Login now