changeset 5701:5cbf9c2189fd

topic: fix the newly added cache for repository without topic The context method might be wrapped without topic being installer. So we need to deal with that case. This might happen in some case where topic is loaded but not enabled (eg: two repository in the same process).
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 23 Dec 2020 23:54:25 +0100
parents 15534a82f2cb
children b56d07c41044
files hgext3rd/topic/__init__.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Tue Jan 12 02:03:43 2021 +0800
+++ b/hgext3rd/topic/__init__.py	Wed Dec 23 23:54:25 2020 +0100
@@ -294,7 +294,11 @@
 def _contexttopic(self, force=False):
     if not (force or self.mutable()):
         return b''
-    topic = self._repo._topiccache.get(self.rev())
+    cache = getattr(self._repo, '_topiccache', None)
+    # topic loaded, but not enabled (eg: multiple repo in the same process)
+    if cache is None:
+        return b''
+    topic = cache.get(self.rev())
     if topic is None:
         topic = self.extra().get(constants.extrakey, b'')
         self._repo._topiccache[self.rev()] = topic