Patchwork D8072: config: add a function in `rcutil` to abstract HGRCSKIPREPO

login
register
mail settings
Submitter phabricator
Date Feb. 4, 2020, 10:50 p.m.
Message ID <differential-rev-PHID-DREV-jlkoagmokelhfjwyiqmk-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44925/
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.

REVISION SUMMARY
  We wil need to respect this environment variable in more place.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/rcutil.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -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
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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)