# HG changeset patch # User Pierre-Yves David # Date 2020-02-03 19:41:11 # Node ID ef11dfc5667459b5b04f70a21de3fa7965889d9d # Parent 238790674d699a5db3a6b07e83f0e677d95ab029 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 diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -37,6 +37,7 @@ from . import ( hook, profiling, pycompat, + rcutil, registrar, scmutil, ui as uimod, @@ -902,17 +903,20 @@ def _getlocal(ui, rpath, wd=None): _(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 diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t --- a/tests/test-hgrc.t +++ b/tests/test-hgrc.t @@ -271,3 +271,13 @@ Test we can skip the user configuration $ HGRCSKIPREPO=1 hg path foo = $TESTTMP/bar + $ cat >> .hg/hgrc < [broken + > EOF + + $ hg path + hg: parse error at $TESTTMP/.hg/hgrc:3: [broken + [255] + $ HGRCSKIPREPO=1 hg path + foo = $TESTTMP/bar +