config: also respect HGRCSKIPREPO in hgwebdir_mod stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 04 Feb 2020 12:07:42 +0100
branchstable
changeset 44245 bf23d6ee7ec7
parent 44244 ef11dfc56674
child 44246 eecc005229ff
config: also respect HGRCSKIPREPO in hgwebdir_mod Differential Revision: https://phab.mercurial-scm.org/D8074
mercurial/hgweb/hgwebdir_mod.py
tests/test-hgrc.t
--- a/mercurial/hgweb/hgwebdir_mod.py	Mon Feb 03 20:41:11 2020 +0100
+++ b/mercurial/hgweb/hgwebdir_mod.py	Tue Feb 04 12:07:42 2020 +0100
@@ -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)
--- a/tests/test-hgrc.t	Mon Feb 03 20:41:11 2020 +0100
+++ b/tests/test-hgrc.t	Tue Feb 04 12:07:42 2020 +0100
@@ -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