##// END OF EJS Templates
config: add template support...
Mathias De Maré -
r29950:80fef525 default
parent child Browse files
Show More
@@ -1788,7 +1788,7 b' def _docommit(ui, repo, *pats, **opts):'
1788 1788 [('u', 'untrusted', None, _('show untrusted configuration options')),
1789 1789 ('e', 'edit', None, _('edit user config')),
1790 1790 ('l', 'local', None, _('edit repository config')),
1791 ('g', 'global', None, _('edit global config'))],
1791 ('g', 'global', None, _('edit global config'))] + formatteropts,
1792 1792 _('[-u] [NAME]...'),
1793 1793 optionalrepo=True)
1794 1794 def config(ui, repo, *values, **opts):
@@ -1849,6 +1849,7 b' def config(ui, repo, *values, **opts):'
1849 1849 onerr=error.Abort, errprefix=_("edit failed"))
1850 1850 return
1851 1851
1852 fm = ui.formatter('config', opts)
1852 1853 for f in scmutil.rcpath():
1853 1854 ui.debug('read config from: %s\n' % f)
1854 1855 untrusted = bool(opts.get('untrusted'))
@@ -1859,25 +1860,32 b' def config(ui, repo, *values, **opts):'
1859 1860 raise error.Abort(_('only one config item permitted'))
1860 1861 matched = False
1861 1862 for section, name, value in ui.walkconfig(untrusted=untrusted):
1862 value = str(value).replace('\n', '\\n')
1863 sectname = section + '.' + name
1863 value = str(value)
1864 if fm.isplain():
1865 value = value.replace('\n', '\\n')
1866 entryname = section + '.' + name
1864 1867 if values:
1865 1868 for v in values:
1866 1869 if v == section:
1867 ui.debug('%s: ' %
1868 ui.configsource(section, name, untrusted))
1869 ui.write('%s=%s\n' % (sectname, value))
1870 fm.startitem()
1871 fm.condwrite(ui.debugflag, 'source', '%s: ',
1872 ui.configsource(section, name, untrusted))
1873 fm.write('name value', '%s=%s\n', entryname, value)
1870 1874 matched = True
1871 elif v == sectname:
1872 ui.debug('%s: ' %
1873 ui.configsource(section, name, untrusted))
1874 ui.write(value, '\n')
1875 elif v == entryname:
1876 fm.startitem()
1877 fm.condwrite(ui.debugflag, 'source', '%s: ',
1878 ui.configsource(section, name, untrusted))
1879 fm.write('value', '%s\n', value)
1880 fm.data(name=entryname)
1875 1881 matched = True
1876 1882 else:
1877 ui.debug('%s: ' %
1878 ui.configsource(section, name, untrusted))
1879 ui.write('%s=%s\n' % (sectname, value))
1883 fm.startitem()
1884 fm.condwrite(ui.debugflag, 'source', '%s: ',
1885 ui.configsource(section, name, untrusted))
1886 fm.write('name value', '%s=%s\n', entryname, value)
1880 1887 matched = True
1888 fm.end()
1881 1889 if matched:
1882 1890 return 0
1883 1891 return 1
@@ -232,7 +232,7 b' Show all commands + options'
232 232 branches: active, closed, template
233 233 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
234 234 cat: output, rev, decode, include, exclude
235 config: untrusted, edit, local, global
235 config: untrusted, edit, local, global, template
236 236 copy: after, force, include, exclude, dry-run
237 237 debugancestor:
238 238 debugapplystreamclonebundle:
@@ -54,6 +54,36 b' Test case sensitive configuration'
54 54 Section.KeY=Case Sensitive
55 55 Section.key=lower case
56 56
57 $ hg showconfig Section -Tjson
58 [
59 {
60 "name": "Section.KeY",
61 "source": "*.hgrc:16", (glob)
62 "value": "Case Sensitive"
63 },
64 {
65 "name": "Section.key",
66 "source": "*.hgrc:17", (glob)
67 "value": "lower case"
68 }
69 ]
70 $ hg showconfig Section.KeY -Tjson
71 [
72 {
73 "name": "Section.KeY",
74 "source": "*.hgrc:16", (glob)
75 "value": "Case Sensitive"
76 }
77 ]
78 $ hg showconfig -Tjson | tail -7
79 },
80 {
81 "name": "*", (glob)
82 "source": "*", (glob)
83 "value": "*" (glob)
84 }
85 ]
86
57 87 Test "%unset"
58 88
59 89 $ cat >> $HGRCPATH <<EOF
General Comments 0
You need to be logged in to leave comments. Login now