[PATCH 08 of 11 V2] config: list environment variables in debug output

Jun Wu quark at fb.com
Wed Mar 22 03:50:57 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1489455351 25200
#      Mon Mar 13 18:35:51 2017 -0700
# Node ID 23b2b1ed59763e5e676f06a4ac4f6bf567874220
# Parent  add83f47bf3a51edbd58aa0fb6e571d186bdae6e
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 23b2b1ed5976
config: list environment variables in debug output

So we can verify the feature in tests.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1803,6 +1803,12 @@ def config(ui, repo, *values, **opts):
     ui.pager('config')
     fm = ui.formatter('config', opts)
-    for f in scmutil.rcpath():
-        ui.debug('read config from: %s\n' % f)
+    for (t, f) in scmutil.rccomponents():
+        if t == 'path':
+            ui.debug('read config from: %s\n' % f)
+        elif t == 'items' and f:
+            for item in f:
+                source = item[3]
+                ui.debug('set config by: %s\n' % source)
+
     untrusted = bool(opts.get('untrusted'))
     if values:
diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
--- a/tests/test-hgrc.t
+++ b/tests/test-hgrc.t
@@ -177,4 +177,18 @@ plain hgrc
   --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
 


More information about the Mercurial-devel mailing list