diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1461,6 +1461,52 @@ def commit(ui, repo, *pats, **opts): cmdutil.commitstatus(repo, node, branch, bheads, opts) +@command('config|showconfig|debugconfig', + [('u', 'untrusted', None, _('show untrusted configuration options'))], + _('[-u] [NAME]...')) +def config(ui, repo, *values, **opts): + """show combined config settings from all hgrc files + + With no arguments, print names and values of all config items. + + With one argument of the form section.name, print just the value + of that config item. + + With multiple arguments, print names and values of all config + items with matching section names. + + With --debug, the source (filename and line number) is printed + for each config item. + + Returns 0 on success. + """ + + for f in scmutil.rcpath(): + ui.debug('read config from: %s\n' % f) + untrusted = bool(opts.get('untrusted')) + if values: + sections = [v for v in values if '.' not in v] + items = [v for v in values if '.' in v] + if len(items) > 1 or items and sections: + raise util.Abort(_('only one config item permitted')) + for section, name, value in ui.walkconfig(untrusted=untrusted): + value = str(value).replace('\n', '\\n') + sectname = section + '.' + name + if values: + for v in values: + if v == section: + ui.debug('%s: ' % + ui.configsource(section, name, untrusted)) + ui.write('%s=%s\n' % (sectname, value)) + elif v == sectname: + ui.debug('%s: ' % + ui.configsource(section, name, untrusted)) + ui.write(value, '\n') + else: + ui.debug('%s: ' % + ui.configsource(section, name, untrusted)) + ui.write('%s=%s\n' % (sectname, value)) + @command('copy|cp', [('A', 'after', None, _('record a copy that has already occurred')), ('f', 'force', None, _('forcibly copy over an existing managed file')), @@ -5162,52 +5208,6 @@ class httpservice(object): self.httpd.serve_forever() -@command('showconfig|debugconfig', - [('u', 'untrusted', None, _('show untrusted configuration options'))], - _('[-u] [NAME]...')) -def showconfig(ui, repo, *values, **opts): - """show combined config settings from all hgrc files - - With no arguments, print names and values of all config items. - - With one argument of the form section.name, print just the value - of that config item. - - With multiple arguments, print names and values of all config - items with matching section names. - - With --debug, the source (filename and line number) is printed - for each config item. - - Returns 0 on success. - """ - - for f in scmutil.rcpath(): - ui.debug('read config from: %s\n' % f) - untrusted = bool(opts.get('untrusted')) - if values: - sections = [v for v in values if '.' not in v] - items = [v for v in values if '.' in v] - if len(items) > 1 or items and sections: - raise util.Abort(_('only one config item permitted')) - for section, name, value in ui.walkconfig(untrusted=untrusted): - value = str(value).replace('\n', '\\n') - sectname = section + '.' + name - if values: - for v in values: - if v == section: - ui.debug('%s: ' % - ui.configsource(section, name, untrusted)) - ui.write('%s=%s\n' % (sectname, value)) - elif v == sectname: - ui.debug('%s: ' % - ui.configsource(section, name, untrusted)) - ui.write(value, '\n') - else: - ui.debug('%s: ' % - ui.configsource(section, name, untrusted)) - ui.write('%s=%s\n' % (sectname, value)) - @command('^status|st', [('A', 'all', None, _('show status of all files')), ('m', 'modified', None, _('show only modified files')), diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -13,6 +13,7 @@ Show all commands except debug commands cat clone commit + config copy diff export @@ -43,7 +44,6 @@ Show all commands except debug commands rollback root serve - showconfig status summary tag @@ -222,6 +222,7 @@ Show all commands + options branches: active, closed bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure cat: output, rev, decode, include, exclude + config: untrusted copy: after, force, include, exclude, dry-run debugancestor: debugbuilddag: mergeable-file, overwritten-file, new-file @@ -275,7 +276,6 @@ Show all commands + options revert: all, date, rev, no-backup, include, exclude, dry-run rollback: dry-run, force root: - showconfig: untrusted tag: force, local, rev, remove, edit, message, date, user tags: tip: patch, git, style, template diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t --- a/tests/test-globalopts.t +++ b/tests/test-globalopts.t @@ -297,6 +297,7 @@ Testing -h/--help: cat output the current or given revision of files clone make a copy of an existing repository commit commit the specified files or all outstanding changes + config show combined config settings from all hgrc files copy mark files as copied for the next commit diff diff repository (or selected files) export dump the header and diffs for one or more changesets @@ -326,7 +327,6 @@ Testing -h/--help: revert restore files to their checkout state root print the root (top) of the current working directory serve start stand-alone webserver - showconfig show combined config settings from all hgrc files status show changed files in the working directory summary summarize working directory state tag add one or more tags for the current or given revision @@ -379,6 +379,7 @@ Testing -h/--help: cat output the current or given revision of files clone make a copy of an existing repository commit commit the specified files or all outstanding changes + config show combined config settings from all hgrc files copy mark files as copied for the next commit diff diff repository (or selected files) export dump the header and diffs for one or more changesets @@ -408,7 +409,6 @@ Testing -h/--help: revert restore files to their checkout state root print the root (top) of the current working directory serve start stand-alone webserver - showconfig show combined config settings from all hgrc files status show changed files in the working directory summary summarize working directory state tag add one or more tags for the current or given revision diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -62,6 +62,7 @@ Short help: cat output the current or given revision of files clone make a copy of an existing repository commit commit the specified files or all outstanding changes + config show combined config settings from all hgrc files copy mark files as copied for the next commit diff diff repository (or selected files) export dump the header and diffs for one or more changesets @@ -91,7 +92,6 @@ Short help: revert restore files to their checkout state root print the root (top) of the current working directory serve start stand-alone webserver - showconfig show combined config settings from all hgrc files status show changed files in the working directory summary summarize working directory state tag add one or more tags for the current or given revision @@ -138,6 +138,7 @@ Short help: cat output the current or given revision of files clone make a copy of an existing repository commit commit the specified files or all outstanding changes + config show combined config settings from all hgrc files copy mark files as copied for the next commit diff diff repository (or selected files) export dump the header and diffs for one or more changesets @@ -167,7 +168,6 @@ Short help: revert restore files to their checkout state root print the root (top) of the current working directory serve start stand-alone webserver - showconfig show combined config settings from all hgrc files status show changed files in the working directory summary summarize working directory state tag add one or more tags for the current or given revision @@ -623,6 +623,7 @@ Test that default list of commands omits cat output the current or given revision of files clone make a copy of an existing repository commit commit the specified files or all outstanding changes + config show combined config settings from all hgrc files copy mark files as copied for the next commit diff diff repository (or selected files) export dump the header and diffs for one or more changesets @@ -652,7 +653,6 @@ Test that default list of commands omits revert restore files to their checkout state root print the root (top) of the current working directory serve start stand-alone webserver - showconfig show combined config settings from all hgrc files status show changed files in the working directory summary summarize working directory state tag add one or more tags for the current or given revision @@ -1259,6 +1259,13 @@ Dish up an empty repo; serve it cold. output the current or given revision of files + + config + + + show combined config settings from all hgrc files + + copy @@ -1399,13 +1406,6 @@ Dish up an empty repo; serve it cold. print the root (top) of the current working directory - - showconfig - - - show combined config settings from all hgrc files - - tag