Mercurial > hg
comparison mercurial/ui.py @ 46623:b91a695b3b08
config: use level to properly deal with value priority
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.
Differential Revision: https://phab.mercurial-scm.org/D9927
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 29 Jan 2021 12:17:11 +0100 |
parents | a3dced4b7b04 |
children | 66fb04552122 |
comparison
equal
deleted
inserted
replaced
46622:a3dced4b7b04 | 46623:b91a695b3b08 |
---|---|
660 b"config item: '%s.%s' '%s'" | 660 b"config item: '%s.%s' '%s'" |
661 ) | 661 ) |
662 msg %= (section, name, pycompat.bytestr(default)) | 662 msg %= (section, name, pycompat.bytestr(default)) |
663 self.develwarn(msg, 2, b'warn-config-default') | 663 self.develwarn(msg, 2, b'warn-config-default') |
664 | 664 |
665 candidates = [] | |
666 config = self._data(untrusted) | |
665 for s, n in alternates: | 667 for s, n in alternates: |
666 candidate = self._data(untrusted).get(s, n, None) | 668 candidate = config.get(s, n, None) |
667 if candidate is not None: | 669 if candidate is not None: |
668 value = candidate | 670 candidates.append((s, n, candidate)) |
669 break | 671 if candidates: |
672 | |
673 def level(x): | |
674 return config.level(x[0], x[1]) | |
675 | |
676 value = max(candidates, key=level)[2] | |
670 | 677 |
671 if self.debugflag and not untrusted and self._reportuntrusted: | 678 if self.debugflag and not untrusted and self._reportuntrusted: |
672 for s, n in alternates: | 679 for s, n in alternates: |
673 uvalue = self._ucfg.get(s, n) | 680 uvalue = self._ucfg.get(s, n) |
674 if uvalue is not None and uvalue != value: | 681 if uvalue is not None and uvalue != value: |