##// END OF EJS Templates
showconfig: use set to filter sections and entry names...
Yuya Nishihara -
r36434:07e207e8 default
parent child Browse files
Show More
@@ -1693,11 +1693,16 b' def config(ui, repo, *values, **opts):'
1693 else:
1693 else:
1694 raise error.ProgrammingError('unknown rctype: %s' % t)
1694 raise error.ProgrammingError('unknown rctype: %s' % t)
1695 untrusted = bool(opts.get('untrusted'))
1695 untrusted = bool(opts.get('untrusted'))
1696
1697 selsections = selentries = []
1696 if values:
1698 if values:
1697 sections = [v for v in values if '.' not in v]
1699 selsections = [v for v in values if '.' not in v]
1698 items = [v for v in values if '.' in v]
1700 selentries = [v for v in values if '.' in v]
1699 if len(items) > 1 or items and sections:
1701 if len(selentries) > 1 or selentries and selsections:
1700 raise error.Abort(_('only one config item permitted'))
1702 raise error.Abort(_('only one config item permitted'))
1703 selsections = set(selsections)
1704 selentries = set(selentries)
1705
1701 matched = False
1706 matched = False
1702 for section, name, value in ui.walkconfig(untrusted=untrusted):
1707 for section, name, value in ui.walkconfig(untrusted=untrusted):
1703 source = ui.configsource(section, name, untrusted)
1708 source = ui.configsource(section, name, untrusted)
@@ -1707,18 +1712,17 b' def config(ui, repo, *values, **opts):'
1707 value = value.replace('\n', '\\n')
1712 value = value.replace('\n', '\\n')
1708 entryname = section + '.' + name
1713 entryname = section + '.' + name
1709 if values:
1714 if values:
1710 for v in values:
1715 if section in selsections:
1711 if v == section:
1716 fm.startitem()
1712 fm.startitem()
1717 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1713 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1718 fm.write('name value', '%s=%s\n', entryname, value)
1714 fm.write('name value', '%s=%s\n', entryname, value)
1719 matched = True
1715 matched = True
1720 elif entryname in selentries:
1716 elif v == entryname:
1721 fm.startitem()
1717 fm.startitem()
1722 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1718 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1723 fm.write('value', '%s\n', value)
1719 fm.write('value', '%s\n', value)
1724 fm.data(name=entryname)
1720 fm.data(name=entryname)
1725 matched = True
1721 matched = True
1722 else:
1726 else:
1723 fm.startitem()
1727 fm.startitem()
1724 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1728 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
@@ -126,6 +126,11 b' showconfig with multiple arguments'
126 $ hg showconfig alias defaults
126 $ hg showconfig alias defaults
127 alias.log=log -g
127 alias.log=log -g
128 defaults.identify=-n
128 defaults.identify=-n
129 $ hg showconfig alias alias
130 alias.log=log -g
131 $ hg showconfig alias.log alias.log
132 abort: only one config item permitted
133 [255]
129 $ hg showconfig alias defaults.identify
134 $ hg showconfig alias defaults.identify
130 abort: only one config item permitted
135 abort: only one config item permitted
131 [255]
136 [255]
General Comments 0
You need to be logged in to leave comments. Login now