Changeset - 89c30b145bb8
[Not reviewed]
default
0 2 0
Mads Kiilerich - 7 years ago 2018-08-08 02:23:11
mads@kiilerich.com
middleware: inline the _set_extras invocation from the __inject_extras method, leaving behind only functionality for augmenting ui from hgrc

I don't know about the logic for merging hg configs ... but for now it is left untouched.
2 files changed with 8 insertions and 29 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/middleware/simplegit.py
Show inline comments
 
@@ -132,7 +132,7 @@ class SimpleGit(BaseVCSController):
 
        fix_PATH()
 
        log.debug('HOOKS extras is %s', extras)
 
        baseui = make_ui('db')
 
        self.__inject_extras(repo_path, baseui, extras)
 
        _set_extras(extras or {})
 

	
 
        try:
 
            self._handle_githooks(repo_name, action, baseui, environ)
 
@@ -225,12 +225,3 @@ class SimpleGit(BaseVCSController):
 
            pull_lock_handling(ui=baseui, repo=_repo._repo)
 
        if action == 'pull' and _hooks.get(Ui.HOOK_PULL_LOG):
 
            log_pull_action(ui=baseui, repo=_repo._repo)
 

	
 
    def __inject_extras(self, repo_path, baseui, extras=None):
 
        """
 
        Injects some extra params into baseui instance
 

	
 
        :param baseui: baseui instance
 
        :param extras: dict with extra params to put into baseui
 
        """
 
        _set_extras(extras or {})
kallithea/lib/middleware/simplehg.py
Show inline comments
 
@@ -142,7 +142,8 @@ class SimpleHg(BaseVCSController):
 
        fix_PATH()
 
        log.debug('HOOKS extras is %s', extras)
 
        baseui = make_ui('db')
 
        self.__inject_extras(repo_path, baseui, extras)
 
        self._augment_hgrc(repo_path, baseui)
 
        _set_extras(extras or {})
 

	
 
        try:
 
            log.info('%s action on Mercurial repo "%s" by "%s" from %s',
 
@@ -223,23 +224,10 @@ class SimpleHg(BaseVCSController):
 
        # Note: the client doesn't get the helpful error message
 
        raise HTTPBadRequest('Unable to detect pull/push action! Are you using non standard command or client?')
 

	
 
    def __inject_extras(self, repo_path, baseui, extras=None):
 
        """
 
        Injects some extra params into baseui instance
 

	
 
        also overwrites global settings with those takes from local hgrc file
 

	
 
        :param baseui: baseui instance
 
        :param extras: dict with extra params to put into baseui
 
        """
 

	
 
    def _augment_hgrc(self, repo_path, baseui):
 
        """Augment baseui with config settings from the repo_path repo"""
 
        hgrc = os.path.join(repo_path, '.hg', 'hgrc')
 

	
 
        repoui = make_ui('file', hgrc)
 

	
 
        if repoui:
 
            # overwrite our ui instance with the section from hgrc file
 
            for section in ui_sections:
 
                for k, v in repoui.configitems(section):
 
                    baseui.setconfig(section, k, v)
 
        _set_extras(extras or {})
 
        for section in ui_sections:
 
            for k, v in repoui.configitems(section):
 
                baseui.setconfig(section, k, v)
0 comments (0 inline, 0 general)