mercurial/commands.py
changeset 20782 13fcb9ca9ccc
parent 20773 efbf15979538
child 20783 43054dc84abd
--- a/mercurial/commands.py	Tue Mar 18 17:56:27 2014 -0500
+++ b/mercurial/commands.py	Tue Mar 18 18:49:30 2014 -0500
@@ -1462,8 +1462,10 @@
 
 @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 @@
     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