Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/config/layer.rs @ 46744:3d692e724d06
rhg: Align config file parse error formatting with Python
Differences can cause tests to fail
Differential Revision: https://phab.mercurial-scm.org/D10110
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 03 Mar 2021 19:47:48 +0100 |
parents | 28a54c128e82 |
children | 1bac7764ceef |
line wrap: on
line diff
--- a/rust/hg-core/src/config/layer.rs Wed Mar 03 19:08:27 2021 +0100 +++ b/rust/hg-core/src/config/layer.rs Wed Mar 03 19:47:48 2021 +0100 @@ -9,7 +9,7 @@ use crate::errors::{HgError, IoResultExt}; use crate::utils::files::{get_bytes_from_path, get_path_from_bytes}; -use format_bytes::{write_bytes, DisplayBytes}; +use format_bytes::{format_bytes, write_bytes, DisplayBytes}; use lazy_static::lazy_static; use regex::bytes::Regex; use std::collections::HashMap; @@ -187,10 +187,15 @@ map.remove(&m[1]); } } else { + let message = if bytes.starts_with(b" ") { + format_bytes!(b"unexpected leading whitespace: {}", bytes) + } else { + bytes.to_owned() + }; return Err(ConfigParseError { origin: ConfigOrigin::File(src.to_owned()), line: Some(index + 1), - bytes: bytes.to_owned(), + message, } .into()); } @@ -278,7 +283,7 @@ pub struct ConfigParseError { pub origin: ConfigOrigin, pub line: Option<usize>, - pub bytes: Vec<u8>, + pub message: Vec<u8>, } #[derive(Debug, derive_more::From)]