Mercurial > public > mercurial-scm > hg-stable
diff mercurial/ui.py @ 42699:51a2e3102db2
config: add defaultvalue template keyword
This patch tries to fix one of the issues mentioned in issue6014.
This adds a new `defaultvalue` template keyword to be used with
`hg showconfig` to get the default value of the config item.
Differential Revision: https://phab.mercurial-scm.org/D6704
author | Navaneeth Suresh <navaneeths1998@gmail.com> |
---|---|
date | Thu, 01 Aug 2019 22:03:52 +0530 |
parents | 44e99811bea7 |
children | 2372284d9457 |
line wrap: on
line diff
--- a/mercurial/ui.py Thu Aug 01 12:23:07 2019 -0400 +++ b/mercurial/ui.py Thu Aug 01 22:03:52 2019 +0530 @@ -783,6 +783,17 @@ return None return default + def configdefault(self, section, name): + """returns the default value of the config item""" + item = self._knownconfig.get(section, {}).get(name) + itemdefault = None + if item is not None: + if callable(item.default): + itemdefault = item.default() + else: + itemdefault = item.default + return itemdefault + def hasconfig(self, section, name, untrusted=False): return self._data(untrusted).hasitem(section, name)