Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 45496:b71858b42963
localrepo: load the share source .hg/hgrc also in share-safe mode (API)
The second part of the Share Safe Plan is to share source repo config also.
This patch adds logic to load the source repo .hg/hgrc if we are in share safe
mode. On unshare, we copy and prepend source config to current repo so that
config which was shared is persisted.
A test is added to show that now if we enable a hook on the source repo, that
also runs on the shared repositories.
API change as a new optional argument sharedvfs added to localrepo.loadhgrc()
Differential Revision: https://phab.mercurial-scm.org/D8656
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Thu, 02 Jul 2020 16:23:36 +0530 |
parents | d252f51ab032 |
children | 0ce6af73f481 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Fri Aug 07 17:42:15 2020 +0530 +++ b/mercurial/localrepo.py Thu Jul 02 16:23:36 2020 +0530 @@ -569,7 +569,7 @@ # The .hg/hgrc file may load extensions or contain config options # that influence repository construction. Attempt to load it and # process any new extensions that it may have pulled in. - if loadhgrc(ui, wdirvfs, hgvfs, requirements): + if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs): afterhgrcload(ui, wdirvfs, hgvfs, requirements) extensions.loadall(ui) extensions.populateui(ui) @@ -697,7 +697,7 @@ ) -def loadhgrc(ui, wdirvfs, hgvfs, requirements): +def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None): """Load hgrc files/content into a ui instance. This is called during repository opening to load any additional @@ -708,9 +708,20 @@ Extensions should monkeypatch this function to modify how per-repo configs are loaded. For example, an extension may wish to pull in configs from alternate files or sources. + + sharedvfs is vfs object pointing to source repo if the current one is a + shared one """ if not rcutil.use_repo_hgrc(): return False + + # first load config from shared source if we has to + if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs: + try: + ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base) + except IOError: + pass + try: ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base) return True