[PATCH 07 of 10] config: list environment variables in debug output

Jun Wu quark at fb.com
Mon Mar 13 23:44:52 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 d640c97a1c2b7098581753814ec8e3c72ce53dfd
# Parent  685e4b92293443041840afc47a2445290c63f13b
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r d640c97a1c2b
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