--- a/rust/hg-core/src/sparse.rs Fri Jan 10 16:14:40 2025 +0000
+++ b/rust/hg-core/src/sparse.rs Tue Jan 28 17:29:59 2025 +0000
@@ -87,6 +87,10 @@
/// An invalid pattern prefix was given to the narrow spec. Includes the
/// entire pattern for context.
InvalidNarrowPrefix(Vec<u8>),
+ /// Narrow/sparse patterns can not begin or end in whitespace
+ /// because the Python parser strips the whitespace when parsing
+ /// the config file.
+ WhitespaceAtEdgeOfPattern(Vec<u8>),
#[from]
HgError(HgError),
#[from]
@@ -136,6 +140,20 @@
VALID_PREFIXES.join(", ")
)),
},
+ SparseConfigError::WhitespaceAtEdgeOfPattern(vec) => {
+ HgError::Abort {
+ message: String::from_utf8_lossy(&format_bytes!(
+ b"narrow pattern with whitespace at the edge: {}",
+ vec
+ ))
+ .to_string(),
+ detailed_exit_code: STATE_ERROR,
+ hint: Some(
+ "narrow patterns can't begin or end in whitespace"
+ .to_string(),
+ ),
+ }
+ }
SparseConfigError::HgError(hg_error) => hg_error,
SparseConfigError::PatternError(pattern_error) => HgError::Abort {
message: pattern_error.to_string(),