Mercurial > hg-stable
changeset 46745:60fe9ebae29b
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
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 03 Mar 2021 20:02:07 +0100 |
parents | 3d692e724d06 |
children | 1bac7764ceef |
files | rust/hg-core/src/config/config.rs |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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::<Result<Vec<_>, _>>()?; + 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)? }