Changeset - 61bd3efe4a6c
[Not reviewed]
default
0 2 0
Mads Kiilerich - 7 years ago 2018-08-15 00:17:24
mads@kiilerich.com
middleware: align hg and git implementations - make it more clear that we have code duplication and something probably should be reused
2 files changed with 12 insertions and 15 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/middleware/simplegit.py
Show inline comments
 
@@ -15,7 +15,7 @@
 
kallithea.lib.middleware.simplegit
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
SimpleGit middleware for handling git protocol request (push/clone etc.)
 
SimpleGit middleware for handling Git protocol requests (push/clone etc.)
 
It's implemented with basic auth function
 

	
 
This file was forked by the Kallithea project in July 2014.
 
@@ -44,7 +44,6 @@ from kallithea.lib.base import BaseVCSCo
 
from kallithea.lib.utils import make_ui, is_valid_repo
 
from kallithea.lib.exceptions import HTTPLockedRC
 
from kallithea.lib.hooks import pull_lock_handling
 
from kallithea.lib import auth_modules
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -100,8 +99,8 @@ class SimpleGit(BaseVCSController):
 
        if response_app is not None:
 
            return response_app(environ, start_response)
 

	
 
        # extras are injected into UI object and later available
 
        # in hooks executed by kallithea
 
        # extras are injected into Mercurial UI object and later available
 
        # in hooks executed by Kallithea
 
        from kallithea import CONFIG
 
        server_url = get_server_url(environ)
 
        extras = {
 
@@ -119,10 +118,9 @@ class SimpleGit(BaseVCSController):
 
        #===================================================================
 
        # GIT REQUEST HANDLING
 
        #===================================================================
 
        repo_path = os.path.join(safe_str(self.basepath),str_repo_name)
 
        repo_path = os.path.join(safe_str(self.basepath), str_repo_name)
 
        log.debug('Repository path is %s', repo_path)
 

	
 
        # CHECK LOCKING only if it's not ANONYMOUS USER
 
        if not user.is_default_user:
 
            log.debug('Checking locking on repository')
 
            make_lock, locked, locked_by = check_locking_state(action, repo_name, user)
 
@@ -181,7 +179,7 @@ class SimpleGit(BaseVCSController):
 

	
 
    def __get_action(self, environ):
 
        """
 
        Maps git request commands into a pull or push command.
 
        Maps Git request commands into a pull or push command.
 

	
 
        :param environ:
 
        """
kallithea/lib/middleware/simplehg.py
Show inline comments
 
@@ -15,8 +15,8 @@
 
kallithea.lib.middleware.simplehg
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
SimpleHg middleware for handling mercurial protocol request
 
(push/clone etc.). It's implemented with basic auth function
 
SimpleHg middleware for handling Mercurial protocol requests (push/clone etc.).
 
It's implemented with basic auth function
 

	
 
This file was forked by the Kallithea project in July 2014.
 
Original author and date, and relevant copyright and licensing information is below:
 
@@ -77,10 +77,8 @@ class SimpleHg(BaseVCSController):
 
        # EXTRACT REPOSITORY NAME FROM ENV
 
        #======================================================================
 
        try:
 
            str_repo_name = environ['REPO_NAME'] = self.__get_repository(environ)
 
            assert isinstance(str_repo_name, str), str_repo_name
 
            str_repo_name = self.__get_repository(environ)
 
            repo_name = safe_unicode(str_repo_name)
 
            assert safe_str(repo_name) == str_repo_name, (str_repo_name, repo_name)
 
            log.debug('Extracted repo name is %s', repo_name)
 
        except Exception as e:
 
            log.error('error extracting repo_name: %r', e)
 
@@ -105,8 +103,8 @@ class SimpleHg(BaseVCSController):
 
        if response_app is not None:
 
            return response_app(environ, start_response)
 

	
 
        # extras are injected into mercurial UI object and later available
 
        # in hg hooks executed by kallithea
 
        # extras are injected into Mercurial UI object and later available
 
        # in hooks executed by Kallithea
 
        from kallithea import CONFIG
 
        server_url = get_server_url(environ)
 
        extras = {
 
@@ -148,6 +146,7 @@ class SimpleHg(BaseVCSController):
 
        try:
 
            log.info('%s action on Mercurial repo "%s" by "%s" from %s',
 
                     action, str_repo_name, safe_str(user.username), ip_addr)
 
            environ['REPO_NAME'] = str_repo_name # used by hgweb_mod.hgweb
 
            app = self.__make_app(repo_path, baseui, extras)
 
            return app(environ, start_response)
 
        except RepoError as e:
 
@@ -206,7 +205,7 @@ class SimpleHg(BaseVCSController):
 

	
 
    def __get_action(self, environ):
 
        """
 
        Maps mercurial request commands into a pull or push command.
 
        Maps Mercurial request commands into a pull or push command.
 

	
 
        Raises HTTPBadRequest if the request environment doesn't look like a hg client.
 
        """
0 comments (0 inline, 0 general)