Changeset - a1115795fabb
[Not reviewed]
default
0 4 0
Mads Kiilerich (kiilerix) - 6 years ago 2019-11-16 15:49:04
mads@kiilerich.com
Grafted from: 39f8314d4b0e
utils: drop make_ui parameter clear_session - this utility function should never mess with sessions

clear_session seems to have been based on the idea that utility functions that
happened to create a session also should clean up. But instead, we now
consistently take care of session removal at a high level.
4 files changed with 6 insertions and 8 deletions:
0 comments (0 inline, 0 general) First comment
kallithea/lib/utils.py
Show inline comments
 
@@ -322,7 +322,7 @@ ui_sections = ['alias', 'auth',
 
                'ui', 'web', ]
 

	
 

	
 
def make_ui(repo_path=None, clear_session=True):
 
def make_ui(repo_path=None):
 
    """
 
    Create an Mercurial 'ui' object based on database Ui settings, possibly
 
    augmenting with content from a hgrc file.
 
@@ -342,8 +342,6 @@ def make_ui(repo_path=None, clear_sessio
 
                      ui_.ui_key, ui_val)
 
            baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key),
 
                             ui_val)
 
    if clear_session:
 
        meta.Session.remove()
 

	
 
    # force set push_ssl requirement to False, Kallithea handles that
 
    baseui.setconfig('web', 'push_ssl', False)
kallithea/model/db.py
Show inline comments
 
@@ -1190,7 +1190,7 @@ class Repository(Base, BaseDbModel):
 
        Creates an db based ui object for this repository
 
        """
 
        from kallithea.lib.utils import make_ui
 
        return make_ui(clear_session=False)
 
        return make_ui()
 

	
 
    @classmethod
 
    def is_valid(cls, repo_name):
kallithea/model/repo.py
Show inline comments
 
@@ -290,7 +290,7 @@ class RepoModel(object):
 
                # clone_uri is modified - if given a value, check it is valid
 
                if clone_uri != '':
 
                    # will raise exception on error
 
                    is_valid_repo_uri(cur_repo.repo_type, clone_uri, make_ui(clear_session=False))
 
                    is_valid_repo_uri(cur_repo.repo_type, clone_uri, make_ui())
 
                cur_repo.clone_uri = clone_uri
 

	
 
            if 'repo_name' in kwargs:
 
@@ -360,7 +360,7 @@ class RepoModel(object):
 
            new_repo.private = private
 
            if clone_uri:
 
                # will raise exception on error
 
                is_valid_repo_uri(repo_type, clone_uri, make_ui(clear_session=False))
 
                is_valid_repo_uri(repo_type, clone_uri, make_ui())
 
            new_repo.clone_uri = clone_uri
 
            new_repo.landing_rev = landing_rev
 

	
 
@@ -661,7 +661,7 @@ class RepoModel(object):
 
        backend = get_backend(repo_type)
 

	
 
        if repo_type == 'hg':
 
            baseui = make_ui(clear_session=False)
 
            baseui = make_ui()
 
            # patch and reset hooks section of UI config to not run any
 
            # hooks on creating remote repo
 
            for k, v in baseui.configitems('hooks'):
kallithea/model/validators.py
Show inline comments
 
@@ -412,7 +412,7 @@ def ValidCloneUri():
 

	
 
            if url and url != value.get('clone_uri_hidden'):
 
                try:
 
                    is_valid_repo_uri(repo_type, url, make_ui(clear_session=False))
 
                    is_valid_repo_uri(repo_type, url, make_ui())
 
                except Exception:
 
                    log.exception('URL validation failed')
 
                    msg = self.message('clone_uri', state)
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now