[PATCH 1 of 2 topic-ext] init: cache repo.topics

timeless timeless at fmr.im
Fri Aug 26 16:59:38 UTC 2016


# HG changeset patch
# User timeless at gmail.com
# Date 1472230322 0
#      Fri Aug 26 16:52:02 2016 +0000
# Node ID 81def069bd64c516610e507279070cef5ca72d7f
# Parent  cf9414f2b5cddd65d21041527981d15a6fb6fd67
init: cache repo.topics

diff -r cf9414f2b5cd -r 81def069bd64 hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Tue Aug 23 21:18:47 2016 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Aug 26 16:52:02 2016 +0000
@@ -144,10 +144,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
@@ -167,6 +170,7 @@
 
         def invalidatecaches(self):
             super(topicrepo, self).invalidatecaches()
+            self._topics = None
             if '_topiccaches' in vars(self.unfiltered()):
                 self.unfiltered()._topiccaches.clear()
 
@@ -181,6 +185,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,


More information about the Mercurial-devel mailing list