diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -271,9 +271,6 @@ def _loadnewui(srcui, args): 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 --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1804,29 +1804,28 @@ def config(ui, repo, *values, **opts): 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 --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -249,8 +249,9 @@ class ui(object): 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 @@ class ui(object): 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 --git a/tests/test-config.t b/tests/test-config.t --- a/tests/test-config.t +++ b/tests/test-config.t @@ -84,6 +84,32 @@ Test case sensitive configuration } ] +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 <