Changeset - cb733c39f658
[Not reviewed]
default
0 1 0
Mads Kiilerich (mads) - 5 years ago 2021-04-21 14:48:53
mads@kiilerich.com
Grafted from: ebb629c54eee
db: read hgrc in Repository.scm_instance_no_cache and Gist.scm_instance

This will make sure .hg/hgrc is read in some code paths where it was missing.
That might make a difference in some real world cases.
1 file changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/model/db.py
Show inline comments
 
@@ -1308,25 +1308,25 @@ 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)
 
        from kallithea.lib.utils import make_ui
 
        self._scm_instance = get_repo(repo_full_path, baseui=make_ui())
 
        self._scm_instance = get_repo(repo_full_path, baseui=make_ui(repo_full_path))
 
        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'
 
@@ -2232,25 +2232,27 @@ class Gist(meta.Base, BaseDbModel):
 

	
 
    def __json__(self):
 
        data = dict(
 
        )
 
        data.update(self.get_api_data())
 
        return data
 

	
 
    ## SCM functions
 

	
 
    @property
 
    def scm_instance(self):
 
        gist_base_path = os.path.join(kallithea.CONFIG['base_path'], self.GIST_STORE_LOC)
 
        return get_repo(os.path.join(gist_base_path, self.gist_access_id))
 
        repo_full_path = os.path.join(gist_base_path, self.gist_access_id)
 
        from kallithea.lib.utils import make_ui
 
        return get_repo(repo_full_path, baseui=make_ui(repo_full_path))
 

	
 

	
 
class UserSshKeys(meta.Base, BaseDbModel):
 
    __tablename__ = 'user_ssh_keys'
 
    __table_args__ = (
 
        Index('usk_fingerprint_idx', 'fingerprint'),
 
        _table_args_default_dict
 
    )
 
    __mapper_args__ = {}
 

	
 
    user_ssh_key_id = Column(Integer(), primary_key=True)
 
    user_id = Column(Integer(), ForeignKey('users.user_id'), nullable=False)
0 comments (0 inline, 0 general)