Patchwork D10111: rhg: Sort config files when adding a directory

login
register
mail settings
Submitter phabricator
Date March 4, 2021, 11:11 a.m.
Message ID <differential-rev-PHID-DREV-lf7jawwase7yn7zp4bdj-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48425/
State Superseded
Headers show

Comments

phabricator - March 4, 2021, 11:11 a.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  For example in `/etc/mercurial/hgrc.d/` or with `HGRCPATH=some-directory`

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10111

AFFECTED FILES
  rust/hg-core/src/config/config.rs

CHANGE DETAILS




To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/config/config.rs b/rust/hg-core/src/config/config.rs
--- a/rust/hg-core/src/config/config.rs
+++ b/rust/hg-core/src/config/config.rs
@@ -107,8 +107,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)?
                 }