# HG changeset patch # User Mads Kiilerich # Date 2020-03-06 18:10:02 # Node ID f83326e2e66c26985420ac88f91e54324ce401d9 # Parent 802fdeefc8ccba0e4808cf839f1bb80fa28d28a3 hg: read everything from hgrc, without config section whitelisting (Issue #246) The whitelisting seems pointless, is hard to maintain, and can't be customized. Also, mercurial.localrepo.instance will read the full config file anyway. diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py --- a/kallithea/lib/utils.py +++ b/kallithea/lib/utils.py @@ -315,19 +315,6 @@ def is_valid_repo_group(repo_group_name, return False -# propagated from mercurial documentation -ui_sections = ['alias', 'auth', - 'decode/encode', 'defaults', - 'diff', 'email', - 'extensions', 'format', - 'merge-patterns', 'merge-tools', - 'hooks', 'http_proxy', - 'smtp', 'patch', - 'paths', 'profiling', - 'server', 'trusted', - 'ui', 'web', ] - - def make_ui(repo_path=None): """ Create an Mercurial 'ui' object based on database Ui settings, possibly @@ -359,17 +346,8 @@ def make_ui(repo_path=None): baseui.setconfig(b'hooks', b'outgoing.kallithea_log_pull_action', b'python:kallithea.lib.hooks.log_pull_action') if repo_path is not None: - hgrc_path = os.path.join(repo_path, '.hg', 'hgrc') - if os.path.isfile(hgrc_path): - log.debug('reading hgrc from %s', hgrc_path) - cfg = mercurial.config.config() - cfg.read(safe_bytes(hgrc_path)) - for section in ui_sections: - for k, v in cfg.items(section): - log.debug('config from file: [%s] %s=%s', section, k, v) - baseui.setconfig(ascii_bytes(section), ascii_bytes(k), safe_bytes(v)) - else: - log.debug('hgrc file is not present at %s, skipping...', hgrc_path) + # Note: MercurialRepository / mercurial.localrepo.instance will do this too, so it will always be possible to override db settings or what is hardcoded above + baseui.readconfig(repo_path) assert baseui.plain() # set by hgcompat.monkey_do (invoked from import of vcs.backends.hg) to minimize potential impact of loading config files return baseui