Changeset - 8eda7bc543cd
[Not reviewed]
default
0 3 0
Mads Kiilerich - 9 years ago 2017-04-07 04:21:38
mads@kiilerich.com
lib: move special Mercurial HTTP listkey exception out of _check_locking_state

Prepare for use with SSH.
3 files changed with 10 insertions and 16 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/base.py
Show inline comments
 
@@ -324,7 +324,7 @@ class BaseVCSController(object):
 
    def _get_ip_addr(self, environ):
 
        return _get_ip_addr(environ)
 

	
 
    def _check_locking_state(self, environ, action, repo, user_id):
 
    def _check_locking_state(self, action, repo, user_id):
 
        """
 
        Checks locking on this repository, if locking is enabled, and if lock
 
        is present. Returns a tuple of make_lock, locked, locked_by. make_lock
 
@@ -337,13 +337,8 @@ class BaseVCSController(object):
 
        repo = Repository.get_by_repo_name(repo)
 
        user = User.get(user_id)
 

	
 
        # this is kind of hacky, but due to how mercurial handles client-server
 
        # server see all operation on changeset; bookmarks, phases and
 
        # obsolescence marker in different transaction, we don't want to check
 
        # locking on those
 
        obsolete_call = environ['QUERY_STRING'] in ['cmd=listkeys',]
 
        locked_by = repo.locked
 
        if repo and repo.enable_locking and not obsolete_call:
 
        if repo and repo.enable_locking:
 
            if action == 'push':
 
                # Check if repo already is locked !, if it is compare users
 
                user_id, _date = locked_by
kallithea/lib/middleware/simplegit.py
Show inline comments
 
@@ -126,10 +126,7 @@ class SimpleGit(BaseVCSController):
 
            log.debug('Checking locking on repository')
 
            (make_lock,
 
             locked,
 
             locked_by) = self._check_locking_state(
 
                            environ=environ, action=action,
 
                            repo=repo_name, user_id=user.user_id
 
                       )
 
             locked_by) = self._check_locking_state(action, repo_name, user.user_id)
 
            # store the make_lock for later evaluation in hooks
 
            extras.update({'make_lock': make_lock,
 
                           'locked_by': locked_by})
kallithea/lib/middleware/simplehg.py
Show inline comments
 
@@ -126,15 +126,17 @@ class SimpleHg(BaseVCSController):
 
        repo_path = os.path.join(safe_str(self.basepath), str_repo_name)
 
        log.debug('Repository path is %s', repo_path)
 

	
 
        # A Mercurial HTTP server will see listkeys operations (bookmarks,
 
        # phases and obsolescence marker) in a different request - we don't
 
        # want to check locking on those
 
        if environ['QUERY_STRING'] == 'cmd=listkeys':
 
            pass
 
        # CHECK LOCKING only if it's not ANONYMOUS USER
 
        if not user.is_default_user:
 
        elif not user.is_default_user:
 
            log.debug('Checking locking on repository')
 
            (make_lock,
 
             locked,
 
             locked_by) = self._check_locking_state(
 
                            environ=environ, action=action,
 
                            repo=repo_name, user_id=user.user_id
 
                       )
 
             locked_by) = self._check_locking_state(action, repo_name, user.user_id)
 
            # store the make_lock for later evaluation in hooks
 
            extras.update({'make_lock': make_lock,
 
                           'locked_by': locked_by})
0 comments (0 inline, 0 general)