Mercurial > hg
comparison mercurial/ui.py @ 42672: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 |
comparison
equal
deleted
inserted
replaced
42671:e77be7e2109f | 42672:51a2e3102db2 |
---|---|
780 return self.configwith(dateutil.parsedate, section, name, default, | 780 return self.configwith(dateutil.parsedate, section, name, default, |
781 'date', untrusted) | 781 'date', untrusted) |
782 if default is _unset: | 782 if default is _unset: |
783 return None | 783 return None |
784 return default | 784 return default |
785 | |
786 def configdefault(self, section, name): | |
787 """returns the default value of the config item""" | |
788 item = self._knownconfig.get(section, {}).get(name) | |
789 itemdefault = None | |
790 if item is not None: | |
791 if callable(item.default): | |
792 itemdefault = item.default() | |
793 else: | |
794 itemdefault = item.default | |
795 return itemdefault | |
785 | 796 |
786 def hasconfig(self, section, name, untrusted=False): | 797 def hasconfig(self, section, name, untrusted=False): |
787 return self._data(untrusted).hasitem(section, name) | 798 return self._data(untrusted).hasitem(section, name) |
788 | 799 |
789 def has_section(self, section, untrusted=False): | 800 def has_section(self, section, untrusted=False): |