changeset 44161:ef11dfc56674 stable

config: also respect HGRCSKIPREPO in `dispatch._getlocal` For some reason, we are also reading the local config in that function. Differential Revision: https://phab.mercurial-scm.org/D8073
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 Feb 2020 20:41:11 +0100
parents 238790674d69
children bf23d6ee7ec7
files mercurial/dispatch.py tests/test-hgrc.t
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Tue Feb 04 12:31:19 2020 +0100
+++ b/mercurial/dispatch.py	Mon Feb 03 20:41:11 2020 +0100
@@ -37,6 +37,7 @@
     hook,
     profiling,
     pycompat,
+    rcutil,
     registrar,
     scmutil,
     ui as uimod,
@@ -902,17 +903,20 @@
                 _(b"error getting current working directory: %s")
                 % encoding.strtolocal(e.strerror)
             )
+
     path = cmdutil.findrepo(wd) or b""
     if not path:
         lui = ui
     else:
         lui = ui.copy()
-        lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
+        if rcutil.use_repo_hgrc():
+            lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
 
     if rpath:
         path = lui.expandpath(rpath)
         lui = ui.copy()
-        lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
+        if rcutil.use_repo_hgrc():
+            lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
 
     return path, lui
 
--- a/tests/test-hgrc.t	Tue Feb 04 12:31:19 2020 +0100
+++ b/tests/test-hgrc.t	Mon Feb 03 20:41:11 2020 +0100
@@ -271,3 +271,13 @@
   $ HGRCSKIPREPO=1 hg path
   foo = $TESTTMP/bar
 
+  $ cat >> .hg/hgrc <<EOF
+  > [broken
+  > EOF
+
+  $ hg path
+  hg: parse error at $TESTTMP/.hg/hgrc:3: [broken
+  [255]
+  $ HGRCSKIPREPO=1 hg path
+  foo = $TESTTMP/bar
+