D9269: config: read system hgrc in lexicographical order

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Nov 3 19:26:52 UTC 2020


martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is similar to edbcf5b239f9 <https://phab.mercurial-scm.org/rHGedbcf5b239f9482b839e0212bc306b7ddbe175b7> (config: read configs from directories
  in lexicographical order, 2019-04-03). Apparently I forgot to sort the
  system hgrc files there. That's fixed by this patch. I also made it so
  we sort user hgrc files, even though they are much less likely to be
  more than one.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rcutil.py
  tests/test-config-env.py
  tests/test-config-env.py.out

CHANGE DETAILS

diff --git a/tests/test-config-env.py.out b/tests/test-config-env.py.out
--- a/tests/test-config-env.py.out
+++ b/tests/test-config-env.py.out
@@ -1,6 +1,6 @@
-pager.pager=p0 # $TESTTMP/sysrc:4
-ui.editor=e1 # $TESTTMP/userrc:2
+pager.pager=p2 # $TESTTMP/sysrc2:4
+ui.editor=e2 # $TESTTMP/userrc2:2
 
-pager.pager=p2 # $PAGER
-ui.editor=e1 # $TESTTMP/userrc:2
+pager.pager=p3 # $PAGER
+ui.editor=e2 # $TESTTMP/userrc2:2
 
diff --git a/tests/test-config-env.py b/tests/test-config-env.py
--- a/tests/test-config-env.py
+++ b/tests/test-config-env.py
@@ -21,19 +21,25 @@
     return os.path.join(testtmp, name)
 
 
-with open(join(b'sysrc'), 'wb') as f:
-    f.write(b'[ui]\neditor=e0\n[pager]\npager=p0\n')
+with open(join(b'sysrc1'), 'wb') as f:
+    f.write(b'[ui]\neditor=e0\n[pager]\npager=p1\n')
+
+with open(join(b'sysrc2'), 'wb') as f:
+    f.write(b'[ui]\neditor=e0\n[pager]\npager=p2\n')
 
-with open(join(b'userrc'), 'wb') as f:
+with open(join(b'userrc1'), 'wb') as f:
     f.write(b'[ui]\neditor=e1')
 
+with open(join(b'userrc2'), 'wb') as f:
+    f.write(b'[ui]\neditor=e2')
+
 # replace rcpath functions so they point to the files above
 def systemrcpath():
-    return [join(b'sysrc')]
+    return [join(b'sysrc2'), join(b'sysrc1')]
 
 
 def userrcpath():
-    return [join(b'userrc')]
+    return [join(b'userrc2'), join(b'userrc1')]
 
 
 extensions.wrapfunction(rcutil, 'default_rc_resources', lambda orig: [])
@@ -56,4 +62,4 @@
 
 # environment variable overrides
 printconfigs({})
-printconfigs({b'EDITOR': b'e2', b'PAGER': b'p2'})
+printconfigs({b'EDITOR': b'e3', b'PAGER': b'p3'})
diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -99,7 +99,7 @@
         _rccomponents = [(b'resource', r) for r in default_rc_resources()]
 
         normpaths = lambda paths: [
-            (b'path', os.path.normpath(p)) for p in paths
+            (b'path', os.path.normpath(p)) for p in sorted(paths)
         ]
         _rccomponents.extend(normpaths(systemrcpath()))
         _rccomponents.append(envrc)



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


More information about the Mercurial-devel mailing list