diff rust/hg-core/src/sparse.rs @ 49489:7c93e38a0bbd

rhg-status: add support for narrow clones
author Rapha?l Gom?s <rgomes@octobus.net>
date Mon, 25 Jul 2022 15:39:04 +0200
parents ffd4b1f1c9cb
children 52464a20add0
line wrap: on
line diff
--- a/rust/hg-core/src/sparse.rs	Tue Jul 19 17:07:09 2022 +0200
+++ b/rust/hg-core/src/sparse.rs	Mon Jul 25 15:39:04 2022 +0200
@@ -54,14 +54,14 @@
 #[derive(Debug, Default)]
 pub struct SparseConfig {
     // Line-separated
-    includes: Vec<u8>,
+    pub(crate) includes: Vec<u8>,
     // Line-separated
-    excludes: Vec<u8>,
-    profiles: HashSet<Vec<u8>>,
-    warnings: Vec<SparseWarning>,
+    pub(crate) excludes: Vec<u8>,
+    pub(crate) profiles: HashSet<Vec<u8>>,
+    pub(crate) warnings: Vec<SparseWarning>,
 }
 
-/// All possible errors when reading sparse config
+/// All possible errors when reading sparse/narrow config
 #[derive(Debug, derive_more::From)]
 pub enum SparseConfigError {
     IncludesAfterExcludes {
@@ -71,6 +71,11 @@
         context: SparseConfigContext,
         line: Vec<u8>,
     },
+    /// Narrow config does not support '%include' directives
+    IncludesInNarrow,
+    /// An invalid pattern prefix was given to the narrow spec. Includes the
+    /// entire pattern for context.
+    InvalidNarrowPrefix(Vec<u8>),
     #[from]
     HgError(HgError),
     #[from]
@@ -78,7 +83,7 @@
 }
 
 /// Parse sparse config file content.
-fn parse_config(
+pub(crate) fn parse_config(
     raw: &[u8],
     context: SparseConfigContext,
 ) -> Result<SparseConfig, SparseConfigError> {