##// 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 def _loadnewui(srcui, args):
271 if ':' in source or source == '--config':
271 if ':' in source or source == '--config':
272 # path:line or command line
272 # path:line or command line
273 continue
273 continue
274 if source == 'none':
275 # ui.configsource returns 'none' by default
276 source = ''
277 newui.setconfig(section, name, value, source)
274 newui.setconfig(section, name, value, source)
278
275
279 # load wd and repo config, copied from dispatch.py
276 # load wd and repo config, copied from dispatch.py
@@ -1804,29 +1804,28 def config(ui, repo, *values, **opts):
1804 raise error.Abort(_('only one config item permitted'))
1804 raise error.Abort(_('only one config item permitted'))
1805 matched = False
1805 matched = False
1806 for section, name, value in ui.walkconfig(untrusted=untrusted):
1806 for section, name, value in ui.walkconfig(untrusted=untrusted):
1807 source = ui.configsource(section, name, untrusted)
1807 value = str(value)
1808 value = str(value)
1808 if fm.isplain():
1809 if fm.isplain():
1810 source = source or 'none'
1809 value = value.replace('\n', '\\n')
1811 value = value.replace('\n', '\\n')
1810 entryname = section + '.' + name
1812 entryname = section + '.' + name
1811 if values:
1813 if values:
1812 for v in values:
1814 for v in values:
1813 if v == section:
1815 if v == section:
1814 fm.startitem()
1816 fm.startitem()
1815 fm.condwrite(ui.debugflag, 'source', '%s: ',
1817 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1816 ui.configsource(section, name, untrusted))
1817 fm.write('name value', '%s=%s\n', entryname, value)
1818 fm.write('name value', '%s=%s\n', entryname, value)
1818 matched = True
1819 matched = True
1819 elif v == entryname:
1820 elif v == entryname:
1820 fm.startitem()
1821 fm.startitem()
1821 fm.condwrite(ui.debugflag, 'source', '%s: ',
1822 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1822 ui.configsource(section, name, untrusted))
1823 fm.write('value', '%s\n', value)
1823 fm.write('value', '%s\n', value)
1824 fm.data(name=entryname)
1824 fm.data(name=entryname)
1825 matched = True
1825 matched = True
1826 else:
1826 else:
1827 fm.startitem()
1827 fm.startitem()
1828 fm.condwrite(ui.debugflag, 'source', '%s: ',
1828 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1829 ui.configsource(section, name, untrusted))
1830 fm.write('name value', '%s=%s\n', entryname, value)
1829 fm.write('name value', '%s=%s\n', entryname, value)
1831 matched = True
1830 matched = True
1832 fm.end()
1831 fm.end()
@@ -249,8 +249,9 class ui(object):
249 if not p:
249 if not p:
250 continue
250 continue
251 if '%%' in p:
251 if '%%' in p:
252 s = self.configsource('paths', n) or 'none'
252 self.warn(_("(deprecated '%%' in path %s=%s from %s)\n")
253 self.warn(_("(deprecated '%%' in path %s=%s from %s)\n")
253 % (n, p, self.configsource('paths', n)))
254 % (n, p, s))
254 p = p.replace('%%', '%')
255 p = p.replace('%%', '%')
255 p = util.expandpath(p)
256 p = util.expandpath(p)
256 if not util.hasscheme(p) and not os.path.isabs(p):
257 if not util.hasscheme(p) and not os.path.isabs(p):
@@ -291,7 +292,7 class ui(object):
291 return untrusted and self._ucfg or self._tcfg
292 return untrusted and self._ucfg or self._tcfg
292
293
293 def configsource(self, section, name, untrusted=False):
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 def config(self, section, name, default=None, untrusted=False):
297 def config(self, section, name, default=None, untrusted=False):
297 if isinstance(name, list):
298 if isinstance(name, list):
@@ -84,6 +84,32 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 Test "%unset"
113 Test "%unset"
88
114
89 $ cat >> $HGRCPATH <<EOF
115 $ cat >> $HGRCPATH <<EOF
General Comments 0
You need to be logged in to leave comments. Login now