Show More
@@ -11,7 +11,7 b' use super::layer;' | |||
|
11 | 11 | use crate::config::layer::{ |
|
12 | 12 | ConfigError, ConfigLayer, ConfigParseError, ConfigValue, |
|
13 | 13 | }; |
|
14 |
use crate::utils::files::get_bytes_from_ |
|
|
14 | use crate::utils::files::get_bytes_from_os_str; | |
|
15 | 15 | use format_bytes::{write_bytes, DisplayBytes}; |
|
16 | 16 | use std::env; |
|
17 | 17 | use std::path::{Path, PathBuf}; |
@@ -134,8 +134,7 b' impl Config {' | |||
|
134 | 134 | layer.add( |
|
135 | 135 | section.to_owned(), |
|
136 | 136 | key.to_owned(), |
|
137 | // `value` is not a path but this works for any `OsStr`: | |
|
138 | get_bytes_from_path(value), | |
|
137 | get_bytes_from_os_str(value), | |
|
139 | 138 | None, |
|
140 | 139 | ); |
|
141 | 140 | self.layers.push(layer) |
@@ -17,6 +17,7 b' use crate::utils::{' | |||
|
17 | 17 | use lazy_static::lazy_static; |
|
18 | 18 | use same_file::is_same_file; |
|
19 | 19 | use std::borrow::{Cow, ToOwned}; |
|
20 | use std::ffi::OsStr; | |
|
20 | 21 | use std::fs::Metadata; |
|
21 | 22 | use std::iter::FusedIterator; |
|
22 | 23 | use std::ops::Deref; |
@@ -40,8 +41,13 b' pub fn get_path_from_bytes(bytes: &[u8])' | |||
|
40 | 41 | // that's why Vec<u8> is returned. |
|
41 | 42 | #[cfg(unix)] |
|
42 | 43 | pub fn get_bytes_from_path(path: impl AsRef<Path>) -> Vec<u8> { |
|
44 | get_bytes_from_os_str(path.as_ref()) | |
|
45 | } | |
|
46 | ||
|
47 | #[cfg(unix)] | |
|
48 | pub fn get_bytes_from_os_str(str: impl AsRef<OsStr>) -> Vec<u8> { | |
|
43 | 49 | use std::os::unix::ffi::OsStrExt; |
|
44 |
|
|
|
50 | str.as_ref().as_bytes().to_vec() | |
|
45 | 51 | } |
|
46 | 52 | |
|
47 | 53 | /// An iterator over repository path yielding itself and its ancestors. |
@@ -70,8 +70,7 b' fn main_with_result(ui: &ui::Ui) -> Resu' | |||
|
70 | 70 | }; |
|
71 | 71 | |
|
72 | 72 | let config_args = values_of_global_arg("config") |
|
73 | // `get_bytes_from_path` works for OsStr the same as for Path | |
|
74 | .map(hg::utils::files::get_bytes_from_path); | |
|
73 | .map(hg::utils::files::get_bytes_from_os_str); | |
|
75 | 74 | let non_repo_config = &hg::config::Config::load(config_args)?; |
|
76 | 75 | |
|
77 | 76 | let repo_path = value_of_global_arg("repository").map(Path::new); |
General Comments 0
You need to be logged in to leave comments.
Login now