# HG changeset patch # User Anton Shestakov # Date 1696016273 10800 # Node ID d08590ce067dfac221465a9ad6fdeb477ef70bb9 # Parent abbba073aa88acdf9682d1e6ecb8b605231dd204 topic: also add topic and topic namespace caches to bundlerepository This allows ctx.topic() and ctx.topic_namespace() actually return something when ctx belongs to a bundle repository. This should in theory be safe to just do because we only expose already existing commit extras that we'd get from the repo on pull anyway. diff -r abbba073aa88 -r d08590ce067d hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Fri Sep 29 16:36:32 2023 -0300 +++ b/hgext3rd/topic/__init__.py Fri Sep 29 16:37:53 2023 -0300 @@ -165,6 +165,7 @@ from mercurial.i18n import _ from mercurial import ( bookmarks, + bundlerepo, changelog, cmdutil, commands, @@ -597,6 +598,26 @@ 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 {} + + @util.propertycache + def _topiccache(self): + return {} + + def invalidatecaches(self): + self._tnscache.clear() + self._topiccache.clear() + super(topicbundlerepo, self).invalidatecaches() + + bundlerepo.bundlerepository = topicbundlerepo + def reposetup(ui, repo): if not isinstance(repo, localrepo.localrepository): return # this can be a peer in the ssh case (puzzling)