diff -r 1c83ebf78f74 -r 77b95a4abbb2 rust/hg-core/src/sparse.rs --- 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), + /// Narrow/sparse patterns can not begin or end in whitespace + /// because the Python parser strips the whitespace when parsing + /// the config file. + WhitespaceAtEdgeOfPattern(Vec), #[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(),