Skip to content
Snippets Groups Projects
Commit 2f8a596c2ee8 authored by Georges Racinet's avatar Georges Racinet
Browse files

WIP Repository instance cache: using in HTTP serving

This is enough to launch functional tests and more generally
experiment on development instances, but must not come near a
production server, as it is essentially an infinitely growing
cache.
parent 7c73031ac5e3
No related branches found
No related tags found
No related merge requests found
Pipeline #22614 passed
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment