# HG changeset patch # User Simon Sapin # Date 1614798127 -3600 # Node ID 60fe9ebae29bc89646a50d7ef458fbe04f93e161 # Parent 3d692e724d068013d0aaf1c0d290c89f2020a409 rhg: Sort config files when adding a directory For example in `/etc/mercurial/hgrc.d/` or with `HGRCPATH=some-directory`. Previously files where parsed in the order returned by the filesystem, which is undefined. But order is significant when multiple files define the same configuration key: the "last" one wins. Differential Revision: https://phab.mercurial-scm.org/D10111 diff -r 3d692e724d06 -r 60fe9ebae29b rust/hg-core/src/config/config.rs --- a/rust/hg-core/src/config/config.rs Wed Mar 03 19:47:48 2021 +0100 +++ b/rust/hg-core/src/config/config.rs Wed Mar 03 20:02:07 2021 +0100 @@ -125,8 +125,13 @@ .when_reading_file(path) .io_not_found_as_none()? { - for entry in entries { - let file_path = entry.when_reading_file(path)?.path(); + let mut file_paths = entries + .map(|result| { + result.when_reading_file(path).map(|entry| entry.path()) + }) + .collect::, _>>()?; + file_paths.sort(); + for file_path in &file_paths { if file_path.extension() == Some(std::ffi::OsStr::new("rc")) { self.add_trusted_file(&file_path)? }