# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 2017-03-27 04:40:22
# Node ID fbc4eb8e24338f45a430efe2457ddff2ea13fec9
# Parent  d83e51654c8af95c371608dffcc0d498d686d58a

debugconfig: list environment variables in debug output

Since we print "read config from" for config files, printing environment
variables will make it more consistent.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1808,7 +1808,8 @@ def config(ui, repo, *values, **opts):
         if t == 'path':
             ui.debug('read config from: %s\n' % f)
         elif t == 'items':
-            pass
+            for section, name, value, source in f:
+                ui.debug('set config by: %s\n' % source)
         else:
             raise error.ProgrammingError('unknown rctype: %s' % t)
     untrusted = bool(opts.get('untrusted'))
diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
--- a/tests/test-hgrc.t
+++ b/tests/test-hgrc.t
@@ -176,6 +176,20 @@ plain hgrc
   --debug: ui.debug=True
   --quiet: ui.quiet=False
 
+with environment variables
+
+  $ PAGER=p1 EDITOR=e1 VISUAL=e2 hg showconfig --debug
+  set config by: $EDITOR
+  set config by: $VISUAL
+  set config by: $PAGER
+  read config from: $TESTTMP/hgrc
+  repo: bundle.mainreporoot=$TESTTMP
+  $PAGER: pager.pager=p1
+  $VISUAL: ui.editor=e2
+  --verbose: ui.verbose=False
+  --debug: ui.debug=True
+  --quiet: ui.quiet=False
+
 plain mode with exceptions
 
   $ cat > plain.py <<EOF