equal
deleted
inserted
replaced
10 use super::layer; |
10 use super::layer; |
11 use crate::config::layer::{ |
11 use crate::config::layer::{ |
12 ConfigError, ConfigLayer, ConfigParseError, ConfigValue, |
12 ConfigError, ConfigLayer, ConfigParseError, ConfigValue, |
13 }; |
13 }; |
14 use crate::utils::files::get_bytes_from_path; |
14 use crate::utils::files::get_bytes_from_path; |
|
15 use format_bytes::{write_bytes, DisplayBytes}; |
15 use std::env; |
16 use std::env; |
16 use std::path::{Path, PathBuf}; |
17 use std::path::{Path, PathBuf}; |
17 |
18 |
18 use crate::errors::{HgResultExt, IoResultExt}; |
19 use crate::errors::{HgResultExt, IoResultExt}; |
19 |
20 |
21 /// TODO update this docstring once we support more sources |
22 /// TODO update this docstring once we support more sources |
22 pub struct Config { |
23 pub struct Config { |
23 layers: Vec<layer::ConfigLayer>, |
24 layers: Vec<layer::ConfigLayer>, |
24 } |
25 } |
25 |
26 |
26 impl std::fmt::Debug for Config { |
27 impl DisplayBytes for Config { |
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
28 fn display_bytes( |
|
29 &self, |
|
30 out: &mut dyn std::io::Write, |
|
31 ) -> std::io::Result<()> { |
28 for (index, layer) in self.layers.iter().rev().enumerate() { |
32 for (index, layer) in self.layers.iter().rev().enumerate() { |
29 write!( |
33 write_bytes!( |
30 f, |
34 out, |
31 "==== Layer {} (trusted: {}) ====\n{:?}", |
35 b"==== Layer {} (trusted: {}) ====\n{}", |
32 index, layer.trusted, layer |
36 index, |
|
37 if layer.trusted { |
|
38 &b"yes"[..] |
|
39 } else { |
|
40 &b"no"[..] |
|
41 }, |
|
42 layer |
33 )?; |
43 )?; |
34 } |
44 } |
35 Ok(()) |
45 Ok(()) |
36 } |
46 } |
37 } |
47 } |