# HG changeset patch # User Yuya Nishihara # Date 1477212420 -32400 # Node ID 201b44c8875cdface4dd9b69f996fc6c348e1918 # Parent 32a07b8a9f77d62e98a834bf44236829a55c6b24 ui: do not translate empty configsource() to 'none' (API) It should be processed when displaying data, so we can get "source": "" in JSON output. diff -r 32a07b8a9f77 -r 201b44c8875c mercurial/chgserver.py --- a/mercurial/chgserver.py Sun Dec 18 16:20:04 2016 +0900 +++ b/mercurial/chgserver.py Sun Oct 23 17:47:00 2016 +0900 @@ -271,9 +271,6 @@ if ':' in source or source == '--config': # path:line or command line continue - if source == 'none': - # ui.configsource returns 'none' by default - source = '' newui.setconfig(section, name, value, source) # load wd and repo config, copied from dispatch.py diff -r 32a07b8a9f77 -r 201b44c8875c mercurial/commands.py --- a/mercurial/commands.py Sun Dec 18 16:20:04 2016 +0900 +++ b/mercurial/commands.py Sun Oct 23 17:47:00 2016 +0900 @@ -1804,29 +1804,28 @@ raise error.Abort(_('only one config item permitted')) matched = False for section, name, value in ui.walkconfig(untrusted=untrusted): + source = ui.configsource(section, name, untrusted) value = str(value) if fm.isplain(): + source = source or 'none' value = value.replace('\n', '\\n') entryname = section + '.' + name if values: for v in values: if v == section: fm.startitem() - fm.condwrite(ui.debugflag, 'source', '%s: ', - ui.configsource(section, name, untrusted)) + fm.condwrite(ui.debugflag, 'source', '%s: ', source) fm.write('name value', '%s=%s\n', entryname, value) matched = True elif v == entryname: fm.startitem() - fm.condwrite(ui.debugflag, 'source', '%s: ', - ui.configsource(section, name, untrusted)) + fm.condwrite(ui.debugflag, 'source', '%s: ', source) fm.write('value', '%s\n', value) fm.data(name=entryname) matched = True else: fm.startitem() - fm.condwrite(ui.debugflag, 'source', '%s: ', - ui.configsource(section, name, untrusted)) + fm.condwrite(ui.debugflag, 'source', '%s: ', source) fm.write('name value', '%s=%s\n', entryname, value) matched = True fm.end() diff -r 32a07b8a9f77 -r 201b44c8875c mercurial/ui.py --- a/mercurial/ui.py Sun Dec 18 16:20:04 2016 +0900 +++ b/mercurial/ui.py Sun Oct 23 17:47:00 2016 +0900 @@ -249,8 +249,9 @@ if not p: continue if '%%' in p: + s = self.configsource('paths', n) or 'none' self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") - % (n, p, self.configsource('paths', n))) + % (n, p, s)) p = p.replace('%%', '%') p = util.expandpath(p) if not util.hasscheme(p) and not os.path.isabs(p): @@ -291,7 +292,7 @@ return untrusted and self._ucfg or self._tcfg def configsource(self, section, name, untrusted=False): - return self._data(untrusted).source(section, name) or 'none' + return self._data(untrusted).source(section, name) def config(self, section, name, default=None, untrusted=False): if isinstance(name, list): diff -r 32a07b8a9f77 -r 201b44c8875c tests/test-config.t --- a/tests/test-config.t Sun Dec 18 16:20:04 2016 +0900 +++ b/tests/test-config.t Sun Oct 23 17:47:00 2016 +0900 @@ -84,6 +84,32 @@ } ] +Test empty config source: + + $ cat < emptysource.py + > def reposetup(ui, repo): + > ui.setconfig('empty', 'source', 'value') + > EOF + $ cp .hg/hgrc .hg/hgrc.orig + $ cat <> .hg/hgrc + > [extensions] + > emptysource = `pwd`/emptysource.py + > EOF + + $ hg config --debug empty.source + read config from: * (glob) + none: value + $ hg config empty.source -Tjson + [ + { + "name": "empty.source", + "source": "", + "value": "value" + } + ] + + $ cp .hg/hgrc.orig .hg/hgrc + Test "%unset" $ cat >> $HGRCPATH <