comparison rust/hg-core/src/sparse.rs @ 49502: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
comparison
equal deleted inserted replaced
49501:9f14126cfc4c 49502:7c93e38a0bbd
52 52
53 /// Parsed sparse config 53 /// Parsed sparse config
54 #[derive(Debug, Default)] 54 #[derive(Debug, Default)]
55 pub struct SparseConfig { 55 pub struct SparseConfig {
56 // Line-separated 56 // Line-separated
57 includes: Vec<u8>, 57 pub(crate) includes: Vec<u8>,
58 // Line-separated 58 // Line-separated
59 excludes: Vec<u8>, 59 pub(crate) excludes: Vec<u8>,
60 profiles: HashSet<Vec<u8>>, 60 pub(crate) profiles: HashSet<Vec<u8>>,
61 warnings: Vec<SparseWarning>, 61 pub(crate) warnings: Vec<SparseWarning>,
62 } 62 }
63 63
64 /// All possible errors when reading sparse config 64 /// All possible errors when reading sparse/narrow config
65 #[derive(Debug, derive_more::From)] 65 #[derive(Debug, derive_more::From)]
66 pub enum SparseConfigError { 66 pub enum SparseConfigError {
67 IncludesAfterExcludes { 67 IncludesAfterExcludes {
68 context: SparseConfigContext, 68 context: SparseConfigContext,
69 }, 69 },
70 EntryOutsideSection { 70 EntryOutsideSection {
71 context: SparseConfigContext, 71 context: SparseConfigContext,
72 line: Vec<u8>, 72 line: Vec<u8>,
73 }, 73 },
74 /// Narrow config does not support '%include' directives
75 IncludesInNarrow,
76 /// An invalid pattern prefix was given to the narrow spec. Includes the
77 /// entire pattern for context.
78 InvalidNarrowPrefix(Vec<u8>),
74 #[from] 79 #[from]
75 HgError(HgError), 80 HgError(HgError),
76 #[from] 81 #[from]
77 PatternError(PatternError), 82 PatternError(PatternError),
78 } 83 }
79 84
80 /// Parse sparse config file content. 85 /// Parse sparse config file content.
81 fn parse_config( 86 pub(crate) fn parse_config(
82 raw: &[u8], 87 raw: &[u8],
83 context: SparseConfigContext, 88 context: SparseConfigContext,
84 ) -> Result<SparseConfig, SparseConfigError> { 89 ) -> Result<SparseConfig, SparseConfigError> {
85 let mut includes = vec![]; 90 let mut includes = vec![];
86 let mut excludes = vec![]; 91 let mut excludes = vec![];