changeset 6561:d08590ce067d

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.
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 29 Sep 2023 16:37:53 -0300
parents abbba073aa88
children 703911d39f7a
files hgext3rd/topic/__init__.py
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)