##// END OF EJS Templates
rhg: Silently ignore missing files in config %include...
Simon Sapin -
r47477:84a3deca default
parent child Browse files
Show More
@@ -160,20 +160,28 impl ConfigLayer {
160 // `Path::join` with an absolute argument correctly ignores the
160 // `Path::join` with an absolute argument correctly ignores the
161 // base path
161 // base path
162 let filename = dir.join(&get_path_from_bytes(&filename_bytes));
162 let filename = dir.join(&get_path_from_bytes(&filename_bytes));
163 let data = std::fs::read(&filename).map_err(|io_error| {
163 match std::fs::read(&filename) {
164 ConfigParseError {
164 Ok(data) => {
165 layers.push(current_layer);
166 layers.extend(Self::parse(&filename, &data)?);
167 current_layer =
168 Self::new(ConfigOrigin::File(src.to_owned()));
169 }
170 Err(error) => {
171 if error.kind() != std::io::ErrorKind::NotFound {
172 return Err(ConfigParseError {
165 origin: ConfigOrigin::File(src.to_owned()),
173 origin: ConfigOrigin::File(src.to_owned()),
166 line,
174 line,
167 message: format_bytes!(
175 message: format_bytes!(
168 b"cannot include {} ({})",
176 b"cannot include {} ({})",
169 filename_bytes,
177 filename_bytes,
170 format_bytes::Utf8(io_error)
178 format_bytes::Utf8(error)
171 ),
179 ),
172 }
180 }
173 })?;
181 .into());
174 layers.push(current_layer);
182 }
175 layers.extend(Self::parse(&filename, &data)?);
183 }
176 current_layer = Self::new(ConfigOrigin::File(src.to_owned()));
184 }
177 } else if let Some(_) = EMPTY_RE.captures(&bytes) {
185 } else if let Some(_) = EMPTY_RE.captures(&bytes) {
178 } else if let Some(m) = SECTION_RE.captures(&bytes) {
186 } else if let Some(m) = SECTION_RE.captures(&bytes) {
179 section = m[1].to_vec();
187 section = m[1].to_vec();
General Comments 0
You need to be logged in to leave comments. Login now