567 requirements |= _readrequires(storevfs, False) |
567 requirements |= _readrequires(storevfs, False) |
568 |
568 |
569 # The .hg/hgrc file may load extensions or contain config options |
569 # The .hg/hgrc file may load extensions or contain config options |
570 # that influence repository construction. Attempt to load it and |
570 # that influence repository construction. Attempt to load it and |
571 # process any new extensions that it may have pulled in. |
571 # process any new extensions that it may have pulled in. |
572 if loadhgrc(ui, wdirvfs, hgvfs, requirements): |
572 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs): |
573 afterhgrcload(ui, wdirvfs, hgvfs, requirements) |
573 afterhgrcload(ui, wdirvfs, hgvfs, requirements) |
574 extensions.loadall(ui) |
574 extensions.loadall(ui) |
575 extensions.populateui(ui) |
575 extensions.populateui(ui) |
576 |
576 |
577 # Set of module names of extensions loaded for this repository. |
577 # Set of module names of extensions loaded for this repository. |
695 features=features, |
695 features=features, |
696 intents=intents, |
696 intents=intents, |
697 ) |
697 ) |
698 |
698 |
699 |
699 |
700 def loadhgrc(ui, wdirvfs, hgvfs, requirements): |
700 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None): |
701 """Load hgrc files/content into a ui instance. |
701 """Load hgrc files/content into a ui instance. |
702 |
702 |
703 This is called during repository opening to load any additional |
703 This is called during repository opening to load any additional |
704 config files or settings relevant to the current repository. |
704 config files or settings relevant to the current repository. |
705 |
705 |
706 Returns a bool indicating whether any additional configs were loaded. |
706 Returns a bool indicating whether any additional configs were loaded. |
707 |
707 |
708 Extensions should monkeypatch this function to modify how per-repo |
708 Extensions should monkeypatch this function to modify how per-repo |
709 configs are loaded. For example, an extension may wish to pull in |
709 configs are loaded. For example, an extension may wish to pull in |
710 configs from alternate files or sources. |
710 configs from alternate files or sources. |
|
711 |
|
712 sharedvfs is vfs object pointing to source repo if the current one is a |
|
713 shared one |
711 """ |
714 """ |
712 if not rcutil.use_repo_hgrc(): |
715 if not rcutil.use_repo_hgrc(): |
713 return False |
716 return False |
|
717 |
|
718 # first load config from shared source if we has to |
|
719 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs: |
|
720 try: |
|
721 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base) |
|
722 except IOError: |
|
723 pass |
|
724 |
714 try: |
725 try: |
715 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base) |
726 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base) |
716 return True |
727 return True |
717 except IOError: |
728 except IOError: |
718 return False |
729 return False |