diff --git a/heptapod/wsgi.py b/heptapod/wsgi.py index 7c73031ac5e393f988adf947a2e22478e1ae4415_aGVwdGFwb2Qvd3NnaS5weQ==..2f8a596c2ee8eb03bb277a800dce37873d6694ff_aGVwdGFwb2Qvd3NnaS5weQ== 100644 --- a/heptapod/wsgi.py +++ b/heptapod/wsgi.py @@ -16,7 +16,6 @@ import logging import gc import os -import weakref from mercurial.i18n import _ @@ -31,7 +30,6 @@ from mercurial import ( error, extensions, - hg, profiling, pycompat, ui as uimod, @@ -41,5 +39,4 @@ hgweb_mod, request as requestmod, ) -from mercurial.repoview import _filteredrepotypes @@ -45,4 +42,5 @@ +from hgext3rd.heptapod import repo_cache logger = logging.getLogger(__name__) # logging configuration will be initialized from the Mercurial global @@ -66,9 +64,7 @@ 'PROJECT_NAMESPACE_FULL_PATH', ) - -def clear_repo_class(repo_class): - _filteredrepotypes.pop(repo_class, None) +_repo_instance_cache = dict() # TODO some appropriate kind of LRU class HgServe(object): @@ -150,8 +146,7 @@ # the message) raise ErrorResponse(HTTP_NOT_FOUND, "Not Found") logger.info("loading repo at %r", repo_path) - repo = hg.repository(self.ui, repo_path) - weakref.finalize(repo, clear_repo_class, repo.unfiltered().__class__) + repo = repo_cache.get_repo(_repo_instance_cache, self.ui, repo_path) # setting native mode, as a string so that standard hg boolean # synonyms (yes, true, etc.) just work as usual.