Changeset - 82ed7ad0dc48
[Not reviewed]
Merge default
0 5 0
Mads Kiilerich - 10 years ago 2016-01-05 16:30:05
madski@unity3d.com
Merge stable
5 files changed with 33 insertions and 19 deletions:
0 comments (0 inline, 0 general)
kallithea/__init__.py
Show inline comments
 
@@ -93,3 +93,9 @@ if len(VERSION) > 3:
 
        __version__ += VERSION[4]
 
    else:
 
        __version__ += '0'
 

	
 
# Hack for making the celery dependency kombu==1.5.1 compatible with Python
 
# 2.7.11 which has https://hg.python.org/releases/2.7.11/rev/24bdc4940e81
 
import uuid
 
if not hasattr(uuid, '_uuid_generate_random'):
 
    uuid._uuid_generate_random = None
kallithea/lib/middleware/simplegit.py
Show inline comments
 
@@ -38,7 +38,7 @@ from webob.exc import HTTPNotFound, HTTP
 
    HTTPNotAcceptable
 
from kallithea.model.db import User, Ui
 

	
 
from kallithea.lib.utils2 import safe_str, fix_PATH, get_server_url, \
 
from kallithea.lib.utils2 import safe_str, safe_unicode, fix_PATH, get_server_url, \
 
    _set_extras
 
from kallithea.lib.base import BaseVCSController, WSGIResultCloseCallback
 
from kallithea.lib.utils import make_ui, is_valid_repo
 
@@ -79,9 +79,11 @@ class SimpleGit(BaseVCSController):
 
        # EXTRACT REPOSITORY NAME FROM ENV
 
        #======================================================================
 
        try:
 
            repo_name = self.__get_repository(environ)
 
            str_repo_name = self.__get_repository(environ)
 
            repo_name = safe_unicode(str_repo_name)
 
            log.debug('Extracted repo name is %s', repo_name)
 
        except Exception:
 
        except Exception as e:
 
            log.error('error extracting repo_name: %r', e)
 
            return HTTPInternalServerError()(environ, start_response)
 

	
 
        # quick check if that dir exists...
 
@@ -176,7 +178,6 @@ class SimpleGit(BaseVCSController):
 
        #===================================================================
 
        # GIT REQUEST HANDLING
 
        #===================================================================
 
        str_repo_name = safe_str(repo_name)
 
        repo_path = os.path.join(safe_str(self.basepath),str_repo_name)
 
        log.debug('Repository path is %s', repo_path)
 

	
kallithea/lib/middleware/simplehg.py
Show inline comments
 
@@ -37,7 +37,7 @@ from webob.exc import HTTPNotFound, HTTP
 
    HTTPNotAcceptable
 
from kallithea.model.db import User
 

	
 
from kallithea.lib.utils2 import safe_str, fix_PATH, get_server_url, \
 
from kallithea.lib.utils2 import safe_str, safe_unicode, fix_PATH, get_server_url, \
 
    _set_extras
 
from kallithea.lib.base import BaseVCSController, WSGIResultCloseCallback
 
from kallithea.lib.utils import make_ui, is_valid_repo, ui_sections
 
@@ -83,9 +83,13 @@ class SimpleHg(BaseVCSController):
 
        # EXTRACT REPOSITORY NAME FROM ENV
 
        #======================================================================
 
        try:
 
            repo_name = environ['REPO_NAME'] = self.__get_repository(environ)
 
            str_repo_name = environ['REPO_NAME'] = self.__get_repository(environ)
 
            assert isinstance(str_repo_name, str)
 
            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:
 
        except Exception as e:
 
            log.error('error extracting repo_name: %r', e)
 
            return HTTPInternalServerError()(environ, start_response)
 

	
 
        # quick check if that dir exists...
 
@@ -179,7 +183,6 @@ class SimpleHg(BaseVCSController):
 
        #======================================================================
 
        # MERCURIAL REQUEST HANDLING
 
        #======================================================================
 
        str_repo_name = safe_str(repo_name)
 
        repo_path = os.path.join(safe_str(self.basepath), str_repo_name)
 
        log.debug('Repository path is %s', repo_path)
 

	
kallithea/model/db.py
Show inline comments
 
@@ -34,6 +34,7 @@ import hashlib
 
import collections
 
import functools
 

	
 
import sqlalchemy
 
from sqlalchemy import *
 
from sqlalchemy.ext.hybrid import hybrid_property
 
from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
 
@@ -1457,7 +1458,7 @@ class Repository(Base, BaseModel):
 
    def __get_instance(self):
 
        repo_full_path = self.repo_full_path
 

	
 
        alias = get_scm(repo_full_path)[0]
 
        alias = get_scm(safe_str(repo_full_path))[0]
 
        log.debug('Creating instance of %s repository from %s',
 
                  alias, repo_full_path)
 
        backend = get_backend(alias)
 
@@ -2132,19 +2133,22 @@ class CacheInvalidation(Base, BaseModel)
 
            return True
 

	
 
        inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar()
 
        if not inv_obj:
 
        if inv_obj is None:
 
            inv_obj = CacheInvalidation(cache_key, repo_name)
 
        if inv_obj.cache_active:
 
        elif inv_obj.cache_active:
 
            return True
 
        inv_obj.cache_active = True
 
        Session().add(inv_obj)
 
        try:
 
            Session().commit()
 
        except exc.IntegrityError:
 
        except sqlalchemy.exc.IntegrityError:
 
            log.error('commit of CacheInvalidation failed - retrying')
 
            Session().rollback()
 
            inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar()
 
            if not inv_obj:
 
                raise
 
            # TOCTOU - another thread added the key at the same time; no further action required
 
            if inv_obj is None:
 
                log.error('failed to create CacheInvalidation entry')
 
                # TODO: fail badly?
 
            # else: TOCTOU - another thread added the key at the same time; no further action required
 
        return False
 

	
 
    @classmethod
kallithea/model/repo.py
Show inline comments
 
@@ -742,8 +742,8 @@ class RepoModel(BaseModel):
 
        """
 
        log.info('renaming repo from %s to %s', old, new)
 

	
 
        old_path = os.path.join(self.repos_path, old)
 
        new_path = os.path.join(self.repos_path, new)
 
        old_path = safe_str(os.path.join(self.repos_path, old))
 
        new_path = safe_str(os.path.join(self.repos_path, new))
 
        if os.path.isdir(new_path):
 
            raise Exception(
 
                'Was trying to rename to already existing dir %s' % new_path
 
@@ -758,7 +758,7 @@ class RepoModel(BaseModel):
 

	
 
        :param repo: repo object
 
        """
 
        rm_path = os.path.join(self.repos_path, repo.repo_name)
 
        rm_path = safe_str(os.path.join(self.repos_path, repo.repo_name))
 
        log.info("Removing %s", rm_path)
 

	
 
        _now = datetime.now()
 
@@ -768,4 +768,4 @@ class RepoModel(BaseModel):
 
        if repo.group:
 
            args = repo.group.full_path_splitted + [_d]
 
            _d = os.path.join(*args)
 
        shutil.move(rm_path, os.path.join(self.repos_path, _d))
 
        shutil.move(rm_path, safe_str(os.path.join(self.repos_path, _d)))
0 comments (0 inline, 0 general)