changeset 7998:a1115795fabb

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.
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 16 Nov 2019 16:49:04 +0100
parents 58ea5a9ded33
children 1a409593f352
files kallithea/lib/utils.py kallithea/model/db.py kallithea/model/repo.py kallithea/model/validators.py
diffstat 4 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/utils.py	Sat Nov 16 16:43:25 2019 +0100
+++ b/kallithea/lib/utils.py	Sat Nov 16 16:49:04 2019 +0100
@@ -322,7 +322,7 @@
                 '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 @@
                       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)
--- a/kallithea/model/db.py	Sat Nov 16 16:43:25 2019 +0100
+++ b/kallithea/model/db.py	Sat Nov 16 16:49:04 2019 +0100
@@ -1190,7 +1190,7 @@
         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):
--- a/kallithea/model/repo.py	Sat Nov 16 16:43:25 2019 +0100
+++ b/kallithea/model/repo.py	Sat Nov 16 16:49:04 2019 +0100
@@ -290,7 +290,7 @@
                 # 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 @@
             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 @@
         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'):
--- a/kallithea/model/validators.py	Sat Nov 16 16:43:25 2019 +0100
+++ b/kallithea/model/validators.py	Sat Nov 16 16:49:04 2019 +0100
@@ -412,7 +412,7 @@
 
             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)