diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -35,6 +35,7 @@ pathutil, profiling, pycompat, + rcutil, registrar, scmutil, templater, @@ -192,11 +193,12 @@ continue u = ui.copy() - try: - u.readconfig(os.path.join(path, b'.hg', b'hgrc')) - except Exception as e: - u.warn(_(b'error reading %s/.hg/hgrc: %s\n') % (path, e)) - continue + if rcutil.use_repo_hgrc(): + try: + u.readconfig(os.path.join(path, b'.hg', b'hgrc')) + except Exception as e: + u.warn(_(b'error reading %s/.hg/hgrc: %s\n') % (path, e)) + continue def get(section, name, default=uimod._unset): return u.config(section, name, default, untrusted=True) diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t --- a/tests/test-hgrc.t +++ b/tests/test-hgrc.t @@ -281,3 +281,21 @@ $ HGRCSKIPREPO=1 hg path foo = $TESTTMP/bar +Check that hgweb respect HGRCSKIPREPO=1 + + $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log + hg: parse error at $TESTTMP/.hg/hgrc:3: [broken + [255] + $ test -f hg.pid && (cat hg.pid >> $DAEMON_PIDS) + [1] + $ killdaemons.py + $ test -f access.log && cat access.log + [1] + $ test -f errors.log && cat errors.log + [1] + + $ HGRCSKIPREPO=1 hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log + $ cat hg.pid >> $DAEMON_PIDS + $ killdaemons.py + $ cat access.log + $ cat errors.log