# HG changeset patch # User Marcin Kuzminski # Date 2019-03-05 10:19:22 # Node ID 5ee2c1152b16684bd94ca512bff7e94301af6674 # Parent c4153b0f64b81d7194888cb4c55f4b24b0336f92 gists: define and use explicit Mercurial backend to speed up creation and fetching of backend repo diff --git a/rhodecode/apps/gist/views.py b/rhodecode/apps/gist/views.py --- a/rhodecode/apps/gist/views.py +++ b/rhodecode/apps/gist/views.py @@ -67,7 +67,6 @@ class GistView(BaseAppView): (Gist.ACL_LEVEL_PUBLIC, _("Can be accessed by anonymous users")) ] - return c @LoginRequired() diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -4260,9 +4260,16 @@ class Gist(Base, BaseModel): # SCM functions def scm_instance(self, **kwargs): + """ + Get explicit Mercurial repository used + :param kwargs: + :return: + """ + from rhodecode.model.gist import GistModel full_repo_path = os.path.join(self.base_path(), self.gist_access_id) return get_vcs_instance( - repo_path=safe_str(full_repo_path), create=False) + repo_path=safe_str(full_repo_path), create=False, + _vcs_alias=GistModel.vcs_backend) class ExternalIdentity(Base, BaseModel): diff --git a/rhodecode/model/gist.py b/rhodecode/model/gist.py --- a/rhodecode/model/gist.py +++ b/rhodecode/model/gist.py @@ -47,6 +47,7 @@ GIST_METADATA_FILE = '.rc_gist_metadata' class GistModel(BaseModel): cls = Gist + vcs_backend = 'hg' def _get_gist(self, gist): """ @@ -145,7 +146,7 @@ class GistModel(BaseModel): gist_repo_path = os.path.join(GIST_STORE_LOC, gist_id) log.debug('Creating new %s GIST repo in %s', gist_type, gist_repo_path) repo = RepoModel()._create_filesystem_repo( - repo_name=gist_id, repo_type='hg', repo_group=GIST_STORE_LOC, + repo_name=gist_id, repo_type=self.vcs_backend, repo_group=GIST_STORE_LOC, use_global_config=True) # now create single multifile commit