config: give a useful hint of source for the most common command line settings
authorMads Kiilerich <madski@unity3d.com>
Wed, 19 Mar 2014 02:45:04 +0100
changeset 20788 f144928dd058
parent 20787 be179da10d5f
child 20789 d19c9bdbbf35
config: give a useful hint of source for the most common command line settings 'hg showconfig --debug' will instead of: none: ui.verbose=False give the better hint: --verbose: ui.verbose=False
mercurial/dispatch.py
mercurial/ui.py
tests/test-hgrc.t
--- a/mercurial/dispatch.py	Wed Mar 19 01:59:15 2014 +0100
+++ b/mercurial/dispatch.py	Wed Mar 19 02:45:04 2014 +0100
@@ -40,7 +40,7 @@
         if not req.ui:
             req.ui = uimod.ui()
         if '--traceback' in req.args:
-            req.ui.setconfig('ui', 'traceback', 'on')
+            req.ui.setconfig('ui', 'traceback', 'on', '--traceback')
 
         # set ui streams from the request
         if req.fin:
@@ -104,7 +104,7 @@
                 # copy configs that were passed on the cmdline (--config) to
                 # the repo ui
                 for cfg in cfgs:
-                    req.repo.ui.setconfig(*cfg)
+                    req.repo.ui.setconfig(*cfg, source='--config')
 
             # if we are in HGPLAIN mode, then disable custom debugging
             debugger = ui.config("ui", "debugger")
@@ -518,7 +518,7 @@
             section, name = name.split('.', 1)
             if not section or not name:
                 raise IndexError
-            ui.setconfig(section, name, value)
+            ui.setconfig(section, name, value, '--config')
             configs.append((section, name, value))
         except (IndexError, ValueError):
             raise util.Abort(_('malformed --config option: %r '
@@ -735,19 +735,19 @@
         for opt in ('verbose', 'debug', 'quiet'):
             val = str(bool(options[opt]))
             for ui_ in uis:
-                ui_.setconfig('ui', opt, val)
+                ui_.setconfig('ui', opt, val, '--' + opt)
 
     if options['traceback']:
         for ui_ in uis:
-            ui_.setconfig('ui', 'traceback', 'on')
+            ui_.setconfig('ui', 'traceback', 'on', '--traceback')
 
     if options['noninteractive']:
         for ui_ in uis:
-            ui_.setconfig('ui', 'interactive', 'off')
+            ui_.setconfig('ui', 'interactive', 'off', '-y')
 
     if cmdoptions.get('insecure', False):
         for ui_ in uis:
-            ui_.setconfig('web', 'cacerts', '')
+            ui_.setconfig('web', 'cacerts', '', '--insecure')
 
     if options['version']:
         return commands.version_(ui)
@@ -773,7 +773,7 @@
                 repo = hg.repository(ui, path=path)
                 if not repo.local():
                     raise util.Abort(_("repository '%s' is not local") % path)
-                repo.ui.setconfig("bundle", "mainreporoot", repo.root)
+                repo.ui.setconfig("bundle", "mainreporoot", repo.root, 'repo')
             except error.RequirementError:
                 raise
             except error.RepoError:
--- a/mercurial/ui.py	Wed Mar 19 01:59:15 2014 +0100
+++ b/mercurial/ui.py	Wed Mar 19 02:45:04 2014 +0100
@@ -157,9 +157,9 @@
         self._tcfg.restore(data[1])
         self._ucfg.restore(data[2])
 
-    def setconfig(self, section, name, value):
+    def setconfig(self, section, name, value, source=''):
         for cfg in (self._ocfg, self._tcfg, self._ucfg):
-            cfg.set(section, name, value)
+            cfg.set(section, name, value, source)
         self.fixconfig(section=section)
 
     def _data(self, untrusted):
--- a/tests/test-hgrc.t	Wed Mar 19 01:59:15 2014 +0100
+++ b/tests/test-hgrc.t	Wed Mar 19 02:45:04 2014 +0100
@@ -141,7 +141,7 @@
   $ hg showconfig
   read config from: $TESTTMP/hgrc
   $TESTTMP/hgrc:13: alias.log=log -g
-  none: bundle.mainreporoot=$TESTTMP
+  repo: bundle.mainreporoot=$TESTTMP
   $TESTTMP/hgrc:11: defaults.identify=-n
   $TESTTMP/hgrc:2: ui.debug=true
   $TESTTMP/hgrc:3: ui.fallbackencoding=ASCII
@@ -157,11 +157,11 @@
   $ HGPLAIN=; export HGPLAIN
   $ hg showconfig --config ui.traceback=True --debug
   read config from: $TESTTMP/hgrc
-  none: bundle.mainreporoot=$TESTTMP
-  none: ui.traceback=True
-  none: ui.verbose=False
-  none: ui.debug=True
-  none: ui.quiet=False
+  repo: bundle.mainreporoot=$TESTTMP
+  --config: ui.traceback=True
+  --verbose: ui.verbose=False
+  --debug: ui.debug=True
+  --quiet: ui.quiet=False
 
 plain mode with exceptions
 
@@ -175,29 +175,29 @@
   $ hg showconfig --config ui.traceback=True --debug
   plain: True
   read config from: $TESTTMP/hgrc
-  none: bundle.mainreporoot=$TESTTMP
+  repo: bundle.mainreporoot=$TESTTMP
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
-  none: ui.traceback=True
-  none: ui.verbose=False
-  none: ui.debug=True
-  none: ui.quiet=False
+  --config: ui.traceback=True
+  --verbose: ui.verbose=False
+  --debug: ui.debug=True
+  --quiet: ui.quiet=False
   $ unset HGPLAIN
   $ hg showconfig --config ui.traceback=True --debug
   plain: True
   read config from: $TESTTMP/hgrc
-  none: bundle.mainreporoot=$TESTTMP
+  repo: bundle.mainreporoot=$TESTTMP
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
-  none: ui.traceback=True
-  none: ui.verbose=False
-  none: ui.debug=True
-  none: ui.quiet=False
+  --config: ui.traceback=True
+  --verbose: ui.verbose=False
+  --debug: ui.debug=True
+  --quiet: ui.quiet=False
   $ HGPLAINEXCEPT=i18n; export HGPLAINEXCEPT
   $ hg showconfig --config ui.traceback=True --debug
   plain: True
   read config from: $TESTTMP/hgrc
-  none: bundle.mainreporoot=$TESTTMP
+  repo: bundle.mainreporoot=$TESTTMP
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
-  none: ui.traceback=True
-  none: ui.verbose=False
-  none: ui.debug=True
-  none: ui.quiet=False
+  --config: ui.traceback=True
+  --verbose: ui.verbose=False
+  --debug: ui.debug=True
+  --quiet: ui.quiet=False