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