config: add a function in `rcutil` to abstract HGRCSKIPREPO stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 04 Feb 2020 12:31:19 +0100
branchstable
changeset 44243 238790674d69
parent 44242 847e582f3cc9
child 44244 ef11dfc56674
config: add a function in `rcutil` to abstract HGRCSKIPREPO We wil need to respect this environment variable in more place. Differential Revision: https://phab.mercurial-scm.org/D8072
mercurial/localrepo.py
mercurial/rcutil.py
--- a/mercurial/localrepo.py	Mon Feb 03 20:12:47 2020 -0500
+++ b/mercurial/localrepo.py	Tue Feb 04 12:31:19 2020 +0100
@@ -53,6 +53,7 @@
     phases,
     pushkey,
     pycompat,
+    rcutil,
     repoview,
     revset,
     revsetlang,
@@ -676,7 +677,7 @@
     configs are loaded. For example, an extension may wish to pull in
     configs from alternate files or sources.
     """
-    if b'HGRCSKIPREPO' in encoding.environ:
+    if not rcutil.use_repo_hgrc():
         return False
     try:
         ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
--- a/mercurial/rcutil.py	Mon Feb 03 20:12:47 2020 -0500
+++ b/mercurial/rcutil.py	Tue Feb 04 12:31:19 2020 +0100
@@ -112,3 +112,8 @@
     intended to be set before starting a pager.
     '''
     return {b'LESS': b'FRX', b'LV': b'-c'}
+
+
+def use_repo_hgrc():
+    """True if repositories `.hg/hgrc` config should be read"""
+    return b'HGRCSKIPREPO' not in encoding.environ