D9927: config: use level to properly deal with value priority
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Sat Jan 30 01:40:30 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
A higher priority alias will now take precedence over lower priority ones.
This was a requirements step before using alias more widely, especially to
rename existing and established config option.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D9927
AFFECTED FILES
mercurial/ui.py
tests/test-config.t
CHANGE DETAILS
diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -477,8 +477,7 @@
$ HGRCPATH="file-B.rc" hg log -r .
value-B
$ HGRCPATH="file-A.rc:file-B.rc" hg log -r .
- value-A (known-bad-output !)
- value-B (missing-correct-output !)
+ value-B
Alias and include
-----------------
@@ -486,15 +485,12 @@
The pre/post include priority should also apply when tie-breaking alternatives.
$ HGRCPATH="file-C.rc" hg log -r .
- value-included (known-bad-output !)
- value-C (missing-correct-output !)
+ value-C
$ HGRCPATH="file-D.rc" hg log -r .
- value-D (known-bad-output !)
- value-included (missing-correct-output !)
+ value-included
command line override
---------------------
$ HGRCPATH="file-A.rc:file-B.rc" hg log -r . --config ui.logtemplate="value-CLI\n"
- value-A (known-bad-output !)
- value-CLI (missing-correct-output !)
+ value-CLI
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -664,11 +664,18 @@
msg %= (section, name, pycompat.bytestr(default))
self.develwarn(msg, 2, b'warn-config-default')
+ candidates = []
+ config = self._data(untrusted)
for s, n in alternates:
- candidate = self._data(untrusted).get(s, n, None)
+ candidate = config.get(s, n, None)
if candidate is not None:
- value = candidate
- break
+ candidates.append((s, n, candidate))
+ if candidates:
+
+ def level(x):
+ return config.level(x[0], x[1])
+
+ value = max(candidates, key=level)[2]
if self.debugflag and not untrusted and self._reportuntrusted:
for s, n in alternates:
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list