Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/config/layer.rs @ 47407:6e49769b7f97
rhg: add exit code to HgError::Abort()
My previous attempts to have rhg end with correct exit code was more of bug
hunting. I found cases which were failing and fixed them. But as one might
expect, more tests started failing.
Let's add exit code `HgError::Abort()` and make it users explicitly tell what
exit code they want.
Differential Revision: https://phab.mercurial-scm.org/D10838
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 07 Jun 2021 17:27:49 +0530 |
parents | 84a3deca963a |
children | a2e278b5e265 |
line wrap: on
line diff
--- a/rust/hg-core/src/config/layer.rs Mon Jun 07 17:19:46 2021 +0530 +++ b/rust/hg-core/src/config/layer.rs Mon Jun 07 17:27:49 2021 +0530 @@ -8,6 +8,7 @@ // GNU General Public License version 2 or any later version. use crate::errors::HgError; +use crate::exit_codes::CONFIG_PARSE_ERROR_ABORT; use crate::utils::files::{get_bytes_from_path, get_path_from_bytes}; use format_bytes::{format_bytes, write_bytes, DisplayBytes}; use lazy_static::lazy_static; @@ -73,11 +74,14 @@ if let Some((section, item, value)) = parse_one(arg) { layer.add(section, item, value, None); } else { - Err(HgError::abort(format!( - "abort: malformed --config option: '{}' \ + Err(HgError::abort( + format!( + "abort: malformed --config option: '{}' \ (use --config section.name=value)", - String::from_utf8_lossy(arg), - )))? + String::from_utf8_lossy(arg), + ), + CONFIG_PARSE_ERROR_ABORT, + ))? } } if layer.sections.is_empty() {