Mercurial > evolve
changeset 6645:4443117fdf94 stable
topic: wrap makebundlerepository() to wrap bundlerepository class (issue6856)
Previously we just tried to wrap bundlerepo.bundlerepository class globally,
but it looks like in some situations it leads to an infinite recursion or
similar issues. This patch tries to fix this by moving the class-wrapping logic
inside a function that is used for creating bundlerepository.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 05 Jan 2024 13:35:27 -0300 |
parents | 23cad1a872b6 |
children | e9650b5616ac a93758f6f937 |
files | hgext3rd/topic/__init__.py |
diffstat | 1 files changed, 26 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Tue Jan 09 17:01:13 2024 +0100 +++ b/hgext3rd/topic/__init__.py Fri Jan 05 13:35:27 2024 -0300 @@ -516,6 +516,30 @@ if tr.changes[b'tns']: repo.ui.status(b'topic namespaces affected: %s\n' % b' '.join(sorted(tr.changes[b'tns']))) +def wrapmakebundlerepository(orig, ui, repopath, bundlepath): + repo = orig(ui, repopath, bundlepath) + + # We want bundle repos to also have caches for topic extension, because we + # want to, for example, see topic and topic namespaces in `hg incoming` + # regardless if the bundle repo has topic extension, as long as local repo + # has topic enabled. + class topicbundlerepo(repo.__class__): + @util.propertycache + def _tnscache(self): + return {} + + @util.propertycache + def _topiccache(self): + return {} + + def invalidatecaches(self): + self._tnscache.clear() + self._topiccache.clear() + super(topicbundlerepo, self).invalidatecaches() + + repo.__class__ = topicbundlerepo + return repo + def uisetup(ui): destination.modsetup(ui) discovery.modsetup(ui) @@ -601,27 +625,9 @@ except (KeyError, AttributeError): pass - server.setupserver(ui) - - # We want bundle repos to also have caches for topic extension, because we - # want to, for example, see topic and topic namespaces in `hg incoming` - # regardless if the bundle repo has topic extension, as long as local repo - # has topic enabled. - class topicbundlerepo(bundlerepo.bundlerepository): - @util.propertycache - def _tnscache(self): - return {} + extensions.wrapfunction(bundlerepo, 'makebundlerepository', wrapmakebundlerepository) - @util.propertycache - def _topiccache(self): - return {} - - def invalidatecaches(self): - self._tnscache.clear() - self._topiccache.clear() - super(topicbundlerepo, self).invalidatecaches() - - bundlerepo.bundlerepository = topicbundlerepo + server.setupserver(ui) def reposetup(ui, repo): if not isinstance(repo, localrepo.localrepository):