Show More
@@ -1872,6 +1872,7 b' def config(ui, repo, *values, **opts):' | |||
|
1872 | 1872 | for section, name, value in ui.walkconfig(untrusted=untrusted): |
|
1873 | 1873 | source = ui.configsource(section, name, untrusted) |
|
1874 | 1874 | value = pycompat.bytestr(value) |
|
1875 | defaultvalue = pycompat.bytestr(ui.configdefault(section, name)) | |
|
1875 | 1876 | if fm.isplain(): |
|
1876 | 1877 | source = source or 'none' |
|
1877 | 1878 | value = value.replace('\n', '\\n') |
@@ -1881,7 +1882,7 b' def config(ui, repo, *values, **opts):' | |||
|
1881 | 1882 | fm.startitem() |
|
1882 | 1883 | fm.condwrite(ui.debugflag, 'source', '%s: ', source) |
|
1883 | 1884 | if uniquesel: |
|
1884 | fm.data(name=entryname) | |
|
1885 | fm.data(name=entryname, defaultvalue=defaultvalue) | |
|
1885 | 1886 | fm.write('value', '%s\n', value) |
|
1886 | 1887 | else: |
|
1887 | 1888 | fm.write('name value', '%s=%s\n', entryname, value) |
@@ -783,6 +783,17 b' class ui(object):' | |||
|
783 | 783 | return None |
|
784 | 784 | return default |
|
785 | 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 | |
|
796 | ||
|
786 | 797 | def hasconfig(self, section, name, untrusted=False): |
|
787 | 798 | return self._data(untrusted).hasitem(section, name) |
|
788 | 799 |
@@ -70,6 +70,7 b' Test case sensitive configuration' | |||
|
70 | 70 | $ hg showconfig Section.KeY -Tjson |
|
71 | 71 | [ |
|
72 | 72 | { |
|
73 | "defaultvalue": "None", | |
|
73 | 74 | "name": "Section.KeY", |
|
74 | 75 | "source": "*.hgrc:*", (glob) |
|
75 | 76 | "value": "Case Sensitive" |
@@ -102,6 +103,7 b' Test empty config source:' | |||
|
102 | 103 | $ hg config empty.source -Tjson |
|
103 | 104 | [ |
|
104 | 105 | { |
|
106 | "defaultvalue": "None", | |
|
105 | 107 | "name": "empty.source", |
|
106 | 108 | "source": "", |
|
107 | 109 | "value": "value" |
General Comments 0
You need to be logged in to leave comments.
Login now