# HG changeset patch # User Matt Mackall # Date 2014-03-18 23:49:30 # Node ID 13fcb9ca9ccc7654ae90d06ec10004a24cef07d2 # Parent 8ecfa225bd16803d7b53153b29bc3958f2e53606 config: add --global and --local flags These start an editor on the system-wide or repository-level config files. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1462,8 +1462,10 @@ def commit(ui, repo, *pats, **opts): @command('config|showconfig|debugconfig', [('u', 'untrusted', None, _('show untrusted configuration options')), - ('e', 'edit', None, _('start editor'))], - _('[-u] [NAME]...')) + ('e', 'edit', None, _('edit user config')), + ('l', 'local', None, _('edit repository config')), + ('g', 'global', None, _('edit global config'))], + _('[-u] [NAME]...')) def config(ui, repo, *values, **opts): """show combined config settings from all hgrc files @@ -1481,8 +1483,19 @@ def config(ui, repo, *values, **opts): Returns 0 on success. """ - if opts.get('edit'): - paths = scmutil.userrcpath() + if opts.get('edit') or opts.get('local') or opts.get('global'): + if opts.get('local') and opts.get('global'): + raise util.Abort(_("can't use --local and --global together")) + + if opts.get('local'): + if not repo: + raise util.Abort(_("can't use --local outside a repository")) + paths = [repo.join('hgrc')] + elif opts.get('global'): + paths = scmutil.systemrcpath() + else: + paths = scmutil.userrcpath() + for f in paths: if os.path.exists(f): break diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -222,7 +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, edit + config: untrusted, edit, local, global copy: after, force, include, exclude, dry-run debugancestor: debugbuilddag: mergeable-file, overwritten-file, new-file