##// END OF EJS Templates
rhg: Align with Python on some more error messages...
Simon Sapin -
r47469:12d59eec default
parent child Browse files
Show More
@@ -286,9 +286,9 b' dependencies = ['
286
286
287 [[package]]
287 [[package]]
288 name = "format-bytes"
288 name = "format-bytes"
289 version = "0.2.1"
289 version = "0.2.2"
290 source = "registry+https://github.com/rust-lang/crates.io-index"
290 source = "registry+https://github.com/rust-lang/crates.io-index"
291 checksum = "8030ff4b04f0ca1c612d6fe49f2fc18caf56fb01497cb370b41cfd36d89b3b06"
291 checksum = "1c4e89040c7fd7b4e6ba2820ac705a45def8a0c098ec78d170ae88f1ef1d5762"
292 dependencies = [
292 dependencies = [
293 "format-bytes-macros",
293 "format-bytes-macros",
294 "proc-macro-hack",
294 "proc-macro-hack",
@@ -28,7 +28,7 b' log = "0.4.8"'
28 memmap = "0.7.0"
28 memmap = "0.7.0"
29 zstd = "0.5.3"
29 zstd = "0.5.3"
30 rust-crypto = "0.2.36"
30 rust-crypto = "0.2.36"
31 format-bytes = "0.2.0"
31 format-bytes = "0.2.2"
32
32
33 # We don't use the `miniz-oxide` backend to not change rhg benchmarks and until
33 # We don't use the `miniz-oxide` backend to not change rhg benchmarks and until
34 # we have a clearer view of which backend is the fastest.
34 # we have a clearer view of which backend is the fastest.
@@ -7,7 +7,7 b''
7 // This software may be used and distributed according to the terms of the
7 // This software may be used and distributed according to the terms of the
8 // GNU General Public License version 2 or any later version.
8 // GNU General Public License version 2 or any later version.
9
9
10 use crate::errors::{HgError, IoResultExt};
10 use crate::errors::HgError;
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::{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;
@@ -74,7 +74,7 b' impl ConfigLayer {'
74 layer.add(section, item, value, None);
74 layer.add(section, item, value, None);
75 } else {
75 } else {
76 Err(HgError::abort(format!(
76 Err(HgError::abort(format!(
77 "malformed --config option: '{}' \
77 "abort: malformed --config option: '{}' \
78 (use --config section.name=value)",
78 (use --config section.name=value)",
79 String::from_utf8_lossy(arg),
79 String::from_utf8_lossy(arg),
80 )))?
80 )))?
@@ -147,6 +147,7 b' impl ConfigLayer {'
147 let mut section = b"".to_vec();
147 let mut section = b"".to_vec();
148
148
149 while let Some((index, bytes)) = lines_iter.next() {
149 while let Some((index, bytes)) = lines_iter.next() {
150 let line = Some(index + 1);
150 if let Some(m) = INCLUDE_RE.captures(&bytes) {
151 if let Some(m) = INCLUDE_RE.captures(&bytes) {
151 let filename_bytes = &m[1];
152 let filename_bytes = &m[1];
152 // `Path::parent` only fails for the root directory,
153 // `Path::parent` only fails for the root directory,
@@ -158,8 +159,17 b' impl ConfigLayer {'
158 // `Path::join` with an absolute argument correctly ignores the
159 // `Path::join` with an absolute argument correctly ignores the
159 // base path
160 // base path
160 let filename = dir.join(&get_path_from_bytes(&filename_bytes));
161 let filename = dir.join(&get_path_from_bytes(&filename_bytes));
161 let data =
162 let data = std::fs::read(&filename).map_err(|io_error| {
162 std::fs::read(&filename).when_reading_file(&filename)?;
163 ConfigParseError {
164 origin: ConfigOrigin::File(src.to_owned()),
165 line,
166 message: format_bytes!(
167 b"cannot include {} ({})",
168 filename_bytes,
169 format_bytes::Utf8(io_error)
170 ),
171 }
172 })?;
163 layers.push(current_layer);
173 layers.push(current_layer);
164 layers.extend(Self::parse(&filename, &data)?);
174 layers.extend(Self::parse(&filename, &data)?);
165 current_layer = Self::new(ConfigOrigin::File(src.to_owned()));
175 current_layer = Self::new(ConfigOrigin::File(src.to_owned()));
@@ -184,12 +194,7 b' impl ConfigLayer {'
184 };
194 };
185 lines_iter.next();
195 lines_iter.next();
186 }
196 }
187 current_layer.add(
197 current_layer.add(section.clone(), item, value, line);
188 section.clone(),
189 item,
190 value,
191 Some(index + 1),
192 );
193 } else if let Some(m) = UNSET_RE.captures(&bytes) {
198 } else if let Some(m) = UNSET_RE.captures(&bytes) {
194 if let Some(map) = current_layer.sections.get_mut(&section) {
199 if let Some(map) = current_layer.sections.get_mut(&section) {
195 map.remove(&m[1]);
200 map.remove(&m[1]);
@@ -202,7 +207,7 b' impl ConfigLayer {'
202 };
207 };
203 return Err(ConfigParseError {
208 return Err(ConfigParseError {
204 origin: ConfigOrigin::File(src.to_owned()),
209 origin: ConfigOrigin::File(src.to_owned()),
205 line: Some(index + 1),
210 line,
206 message,
211 message,
207 }
212 }
208 .into());
213 .into());
@@ -81,7 +81,7 b' impl fmt::Display for HgError {'
81 write!(f, "abort: {}: {}", context, error)
81 write!(f, "abort: {}: {}", context, error)
82 }
82 }
83 HgError::CorruptedRepository(explanation) => {
83 HgError::CorruptedRepository(explanation) => {
84 write!(f, "abort: corrupted repository: {}", explanation)
84 write!(f, "abort: {}", explanation)
85 }
85 }
86 HgError::UnsupportedFeature(explanation) => {
86 HgError::UnsupportedFeature(explanation) => {
87 write!(f, "unsupported feature: {}", explanation)
87 write!(f, "unsupported feature: {}", explanation)
@@ -141,20 +141,22 b' impl Repo {'
141
141
142 if share_safe && !source_is_share_safe {
142 if share_safe && !source_is_share_safe {
143 return Err(match config
143 return Err(match config
144 .get(b"safe-mismatch", b"source-not-safe")
144 .get(b"share", b"safe-mismatch.source-not-safe")
145 {
145 {
146 Some(b"abort") | None => HgError::abort(
146 Some(b"abort") | None => HgError::abort(
147 "share source does not support share-safe requirement",
147 "abort: share source does not support share-safe requirement\n\
148 (see `hg help config.format.use-share-safe` for more information)",
148 ),
149 ),
149 _ => HgError::unsupported("share-safe downgrade"),
150 _ => HgError::unsupported("share-safe downgrade"),
150 }
151 }
151 .into());
152 .into());
152 } else if source_is_share_safe && !share_safe {
153 } else if source_is_share_safe && !share_safe {
153 return Err(
154 return Err(
154 match config.get(b"safe-mismatch", b"source-safe") {
155 match config.get(b"share", b"safe-mismatch.source-safe") {
155 Some(b"abort") | None => HgError::abort(
156 Some(b"abort") | None => HgError::abort(
156 "version mismatch: source uses share-safe \
157 "abort: version mismatch: source uses share-safe \
157 functionality while the current share does not",
158 functionality while the current share does not\n\
159 (see `hg help config.format.use-share-safe` for more information)",
158 ),
160 ),
159 _ => HgError::unsupported("share-safe upgrade"),
161 _ => HgError::unsupported("share-safe upgrade"),
160 }
162 }
@@ -72,7 +72,7 b' impl From<RepoError> for CommandError {'
72 match error {
72 match error {
73 RepoError::NotFound { at } => CommandError::Abort {
73 RepoError::NotFound { at } => CommandError::Abort {
74 message: format_bytes!(
74 message: format_bytes!(
75 b"repository {} not found",
75 b"abort: repository {} not found",
76 get_bytes_from_path(at)
76 get_bytes_from_path(at)
77 ),
77 ),
78 },
78 },
@@ -187,7 +187,7 b' Requirements'
187
187
188 $ echo -e '\xFF' >> .hg/requires
188 $ echo -e '\xFF' >> .hg/requires
189 $ $NO_FALLBACK rhg debugrequirements
189 $ $NO_FALLBACK rhg debugrequirements
190 abort: corrupted repository: parse error in 'requires' file
190 abort: parse error in 'requires' file
191 [255]
191 [255]
192
192
193 Persistent nodemap
193 Persistent nodemap
General Comments 0
You need to be logged in to leave comments. Login now