Changeset - a349211f875e
[Not reviewed]
default
0 1 0
Mads Kiilerich (mads) - 5 years ago 2021-04-21 13:34:12
mads@kiilerich.com
Grafted from: 18106b927bd5
db: inline Repository._ui
1 file changed with 2 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/model/db.py
Show inline comments
 
@@ -1088,32 +1088,24 @@ class Repository(meta.Base, BaseDbModel)
 
        p += self.repo_name.split(kallithea.URL_SEP)
 
        return os.path.join(*p)
 

	
 
    def get_new_name(self, repo_name):
 
        """
 
        returns new full repository name based on assigned group and new new
 

	
 
        :param group_name:
 
        """
 
        path_prefix = self.group.full_path_splitted if self.group else []
 
        return kallithea.URL_SEP.join(path_prefix + [repo_name])
 

	
 
    @property
 
    def _ui(self):
 
        """
 
        Creates an db based ui object for this repository
 
        """
 
        from kallithea.lib.utils import make_ui
 
        return make_ui()
 

	
 
    @classmethod
 
    def is_valid(cls, repo_name):
 
        """
 
        returns True if given repo name is a valid filesystem repository
 

	
 
        :param cls:
 
        :param repo_name:
 
        """
 
        from kallithea.lib.utils import is_valid_repo
 

	
 
        return is_valid_repo(repo_name, kallithea.CONFIG['base_path'])
 

	
 
@@ -1315,25 +1307,26 @@ class Repository(meta.Base, BaseDbModel)
 

	
 
    _scm_instance = None  # caching inside lifetime of SA session
 

	
 
    @property
 
    def scm_instance(self):
 
        if self._scm_instance is None:
 
            return self.scm_instance_no_cache()  # will populate self._scm_instance
 
        return self._scm_instance
 

	
 
    def scm_instance_no_cache(self):
 
        repo_full_path = self.repo_full_path
 
        log.debug('Creating instance of repository at %s', repo_full_path)
 
        self._scm_instance = get_repo(repo_full_path, baseui=self._ui)
 
        from kallithea.lib.utils import make_ui
 
        self._scm_instance = get_repo(repo_full_path, baseui=make_ui())
 
        return self._scm_instance
 

	
 
    def __json__(self):
 
        return dict(
 
            repo_id=self.repo_id,
 
            repo_name=self.repo_name,
 
            landing_rev=self.landing_rev,
 
        )
 

	
 

	
 
class RepoGroup(meta.Base, BaseDbModel):
 
    __tablename__ = 'groups'
0 comments (0 inline, 0 general)