##// END OF EJS Templates
ui: do not translate empty configsource() to 'none' (API)...
Yuya Nishihara -
r30618:201b44c8 default
parent child Browse files
Show More
@@ -271,9 +271,6 b' def _loadnewui(srcui, args):'
271 271 if ':' in source or source == '--config':
272 272 # path:line or command line
273 273 continue
274 if source == 'none':
275 # ui.configsource returns 'none' by default
276 source = ''
277 274 newui.setconfig(section, name, value, source)
278 275
279 276 # load wd and repo config, copied from dispatch.py
@@ -1804,29 +1804,28 b' def config(ui, repo, *values, **opts):'
1804 1804 raise error.Abort(_('only one config item permitted'))
1805 1805 matched = False
1806 1806 for section, name, value in ui.walkconfig(untrusted=untrusted):
1807 source = ui.configsource(section, name, untrusted)
1807 1808 value = str(value)
1808 1809 if fm.isplain():
1810 source = source or 'none'
1809 1811 value = value.replace('\n', '\\n')
1810 1812 entryname = section + '.' + name
1811 1813 if values:
1812 1814 for v in values:
1813 1815 if v == section:
1814 1816 fm.startitem()
1815 fm.condwrite(ui.debugflag, 'source', '%s: ',
1816 ui.configsource(section, name, untrusted))
1817 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1817 1818 fm.write('name value', '%s=%s\n', entryname, value)
1818 1819 matched = True
1819 1820 elif v == entryname:
1820 1821 fm.startitem()
1821 fm.condwrite(ui.debugflag, 'source', '%s: ',
1822 ui.configsource(section, name, untrusted))
1822 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1823 1823 fm.write('value', '%s\n', value)
1824 1824 fm.data(name=entryname)
1825 1825 matched = True
1826 1826 else:
1827 1827 fm.startitem()
1828 fm.condwrite(ui.debugflag, 'source', '%s: ',
1829 ui.configsource(section, name, untrusted))
1828 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1830 1829 fm.write('name value', '%s=%s\n', entryname, value)
1831 1830 matched = True
1832 1831 fm.end()
@@ -249,8 +249,9 b' class ui(object):'
249 249 if not p:
250 250 continue
251 251 if '%%' in p:
252 s = self.configsource('paths', n) or 'none'
252 253 self.warn(_("(deprecated '%%' in path %s=%s from %s)\n")
253 % (n, p, self.configsource('paths', n)))
254 % (n, p, s))
254 255 p = p.replace('%%', '%')
255 256 p = util.expandpath(p)
256 257 if not util.hasscheme(p) and not os.path.isabs(p):
@@ -291,7 +292,7 b' class ui(object):'
291 292 return untrusted and self._ucfg or self._tcfg
292 293
293 294 def configsource(self, section, name, untrusted=False):
294 return self._data(untrusted).source(section, name) or 'none'
295 return self._data(untrusted).source(section, name)
295 296
296 297 def config(self, section, name, default=None, untrusted=False):
297 298 if isinstance(name, list):
@@ -84,6 +84,32 b' Test case sensitive configuration'
84 84 }
85 85 ]
86 86
87 Test empty config source:
88
89 $ cat <<EOF > emptysource.py
90 > def reposetup(ui, repo):
91 > ui.setconfig('empty', 'source', 'value')
92 > EOF
93 $ cp .hg/hgrc .hg/hgrc.orig
94 $ cat <<EOF >> .hg/hgrc
95 > [extensions]
96 > emptysource = `pwd`/emptysource.py
97 > EOF
98
99 $ hg config --debug empty.source
100 read config from: * (glob)
101 none: value
102 $ hg config empty.source -Tjson
103 [
104 {
105 "name": "empty.source",
106 "source": "",
107 "value": "value"
108 }
109 ]
110
111 $ cp .hg/hgrc.orig .hg/hgrc
112
87 113 Test "%unset"
88 114
89 115 $ cat >> $HGRCPATH <<EOF
General Comments 0
You need to be logged in to leave comments. Login now