rust/hg-core/src/config/layer.rs
changeset 46481 0d734c0ae1cf
parent 46447 0cb1b02228a6
child 46482 39128182f04e
equal deleted inserted replaced
46480:05dd091dfa6a 46481:0d734c0ae1cf
     6 //
     6 //
     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, IoResultExt};
    11 use crate::utils::files::{
    11 use crate::utils::files::{get_bytes_from_path, get_path_from_bytes};
    12     get_bytes_from_path, get_path_from_bytes, read_whole_file,
       
    13 };
       
    14 use format_bytes::format_bytes;
    12 use format_bytes::format_bytes;
    15 use lazy_static::lazy_static;
    13 use lazy_static::lazy_static;
    16 use regex::bytes::Regex;
    14 use regex::bytes::Regex;
    17 use std::collections::HashMap;
    15 use std::collections::HashMap;
    18 use std::io;
    16 use std::io;
   242 fn read_include(
   240 fn read_include(
   243     old_src: &Path,
   241     old_src: &Path,
   244     new_src: &Path,
   242     new_src: &Path,
   245 ) -> (PathBuf, io::Result<Vec<u8>>) {
   243 ) -> (PathBuf, io::Result<Vec<u8>>) {
   246     if new_src.is_absolute() {
   244     if new_src.is_absolute() {
   247         (new_src.to_path_buf(), read_whole_file(&new_src))
   245         (new_src.to_path_buf(), std::fs::read(&new_src))
   248     } else {
   246     } else {
   249         let dir = old_src.parent().unwrap();
   247         let dir = old_src.parent().unwrap();
   250         let new_src = dir.join(&new_src);
   248         let new_src = dir.join(&new_src);
   251         (new_src.to_owned(), read_whole_file(&new_src))
   249         (new_src.to_owned(), std::fs::read(&new_src))
   252     }
   250     }
   253 }
   251 }