diff --git a/rust/hg-core/src/config/layer.rs b/rust/hg-core/src/config/layer.rs --- a/rust/hg-core/src/config/layer.rs +++ b/rust/hg-core/src/config/layer.rs @@ -73,11 +73,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), + ), + 10, + ))? } } if layer.sections.is_empty() { diff --git a/rust/hg-core/src/errors.rs b/rust/hg-core/src/errors.rs --- a/rust/hg-core/src/errors.rs +++ b/rust/hg-core/src/errors.rs @@ -29,7 +29,7 @@ /// /// The given string is a short explanation for users, not intended to be /// machine-readable. - Abort(String), + Abort(String, i32), /// A configuration value is not in the expected syntax. /// @@ -69,8 +69,9 @@ pub fn unsupported(explanation: impl Into) -> Self { HgError::UnsupportedFeature(explanation.into()) } - pub fn abort(explanation: impl Into) -> Self { - HgError::Abort(explanation.into()) + + pub fn abort(explanation: impl Into, exit_code: i32) -> Self { + HgError::Abort(explanation.into(), exit_code) } } @@ -78,7 +79,7 @@ impl fmt::Display for HgError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - HgError::Abort(explanation) => write!(f, "{}", explanation), + HgError::Abort(explanation, _) => write!(f, "{}", explanation), HgError::IoError { error, context } => { write!(f, "abort: {}: {}", context, error) } diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs --- a/rust/hg-core/src/repo.rs +++ b/rust/hg-core/src/repo.rs @@ -152,6 +152,7 @@ Some(b"abort") | None => HgError::abort( "abort: share source does not support share-safe requirement\n\ (see `hg help config.format.use-share-safe` for more information)", + 30, ), _ => HgError::unsupported("share-safe downgrade"), } @@ -163,6 +164,7 @@ "abort: version mismatch: source uses share-safe \ functionality while the current share does not\n\ (see `hg help config.format.use-share-safe` for more information)", + 30, ), _ => HgError::unsupported("share-safe upgrade"), }