init: cache repo.topics
authortimeless@gmail.com
Fri, 26 Aug 2016 16:52:02 +0000
changeset 1999 fe76e9c92fff
parent 1998 302be26a3fd8
child 2000 c413e7c96265
init: cache repo.topics
hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Fri Aug 26 21:57:48 2016 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Aug 26 16:52:02 2016 +0000
@@ -149,10 +149,13 @@
 
         @property
         def topics(self):
+            if self._topics is not None:
+                return self._topics
             topics = set(['', self.currenttopic])
             for c in self.set('not public()'):
                 topics.add(c.topic())
             topics.remove('')
+            self._topics = topics
             return topics
 
         @property
@@ -170,8 +173,10 @@
             with topicmap.usetopicmap(self):
                 return super(topicrepo, self).destroyed(*args, **kwargs)
 
-        def invalidatecaches(self):
-            super(topicrepo, self).invalidatecaches()
+        def invalidatevolatilesets(self):
+            # XXX we might be able to move this to something invalidated less often
+            super(topicrepo, self).invalidatevolatilesets()
+            self._topics = None
             if '_topiccaches' in vars(self.unfiltered()):
                 self.unfiltered()._topiccaches.clear()
 
@@ -186,6 +191,7 @@
             return peer
 
     repo.__class__ = topicrepo
+    repo._topics = None
     if util.safehasattr(repo, 'names'):
         repo.names.addnamespace(namespaces.namespace(
             'topics', 'topic', namemap=_namemap, nodemap=_nodemap,