Patchwork D8074: config: also respect HGRCSKIPREPO in hgwebdir_mod

login
register
mail settings
Submitter phabricator
Date Feb. 4, 2020, 10:50 p.m.
Message ID <differential-rev-PHID-DREV-fz5dyyhgafkjmov5bq5b-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44926/
State Superseded
Headers show

Comments

phabricator - Feb. 4, 2020, 10:50 p.m.
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D8074

AFFECTED FILES
  mercurial/hgweb/hgwebdir_mod.py
  tests/test-hgrc.t

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-devel

Patch

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
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)