[Updated] D10141: rhg: Silently ignore missing files in config %include
SimonSapin
phabricator at mercurial-scm.org
Tue Mar 16 21:48:11 UTC 2021
Closed by commit rHG84a3deca963a: rhg: Silently ignore missing files in config %include (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10141?vs=26347&id=26424
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10141/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10141
AFFECTED FILES
rust/hg-core/src/config/layer.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/config/layer.rs b/rust/hg-core/src/config/layer.rs
--- a/rust/hg-core/src/config/layer.rs
+++ b/rust/hg-core/src/config/layer.rs
@@ -160,20 +160,28 @@
// `Path::join` with an absolute argument correctly ignores the
// base path
let filename = dir.join(&get_path_from_bytes(&filename_bytes));
- let data = std::fs::read(&filename).map_err(|io_error| {
- ConfigParseError {
- origin: ConfigOrigin::File(src.to_owned()),
- line,
- message: format_bytes!(
- b"cannot include {} ({})",
- filename_bytes,
- format_bytes::Utf8(io_error)
- ),
+ match std::fs::read(&filename) {
+ Ok(data) => {
+ layers.push(current_layer);
+ layers.extend(Self::parse(&filename, &data)?);
+ current_layer =
+ Self::new(ConfigOrigin::File(src.to_owned()));
}
- })?;
- layers.push(current_layer);
- layers.extend(Self::parse(&filename, &data)?);
- current_layer = Self::new(ConfigOrigin::File(src.to_owned()));
+ Err(error) => {
+ if error.kind() != std::io::ErrorKind::NotFound {
+ return Err(ConfigParseError {
+ origin: ConfigOrigin::File(src.to_owned()),
+ line,
+ message: format_bytes!(
+ b"cannot include {} ({})",
+ filename_bytes,
+ format_bytes::Utf8(error)
+ ),
+ }
+ .into());
+ }
+ }
+ }
} else if let Some(_) = EMPTY_RE.captures(&bytes) {
} else if let Some(m) = SECTION_RE.captures(&bytes) {
section = m[1].to_vec();
To: SimonSapin, #hg-reviewers, marmoute, Alphare
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210316/c01d94e5/attachment-0002.html>
More information about the Mercurial-patches
mailing list