Martin Geisler committed 6bba865

Sort projrc settings before user and repository settings

Comments (0)

Files changed (3)

 from mercurial.i18n import _
+def classifycfgpath(path):
+    path = path.rsplit(":", 1)[0]
+    if path in util.system_rcpath():
+        return 1
+    if path.endswith(".hg/projrc"):
+        return 2
+    if path in util.user_rcpath():
+        return 3
+    # .hg/hgrc, file in $HGRCPATH, or an included file
+    return 4
 def loadprojrc(ui, projrc, root):
     ui.readconfig(projrc, root)
+    # ui.walkconfig is almost what we want, but it runs str on all
+    # values and replaces \n with \\n for some reason.
+    cfg = ui._data(untrusted=False)
+    for section in cfg:
+        items = []
+        for key, value in cfg.items(section):
+            src = cfg.source(section, key)
+            items.append((classifycfgpath(src), key, value, src))
+        items.sort() # list.sort implements a stable sort
+        for order, key, value, src in items:
+            cfg.set(section, key, value, src)
 def readprojrc(ui, rpath):
     # Modelled after dispatch._getlocal but reads the projrc settings
     # directly into the ui object.


   4) x reposetup
   4) y reposetup
   4) z reposetup
+  extensions.z=$TESTTMP/
   extensions.projrc=*/ (glob)
-  extensions.z=$TESTTMP/
 test reading of .hg/projrc file
   $ hg showconfig extensions
+  extensions.children=
   extensions.projrc=*/ (glob)
-  extensions.children=
 check that extension is loaded
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd b
   $ hg showconfig extensions
+  extensions.children=
   extensions.projrc=*/ (glob)
-  extensions.children=
 test pull of changes into .hg/projrc file
   searching for changes
   no changes found
   $ hg showconfig extensions
-  extensions.projrc=*/ (glob)
+  extensions.projrc=*/ (glob)
 test pull of deleted .hg/projrc file
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.