changeset 6333:f4ffe1e67a9b

topic: move compatibility for branchcache._entries to topic/compat.py
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 12 Nov 2022 15:47:57 +0400
parents 58ba40d1f2c7
children ef8c1637321a
files hgext3rd/topic/__init__.py hgext3rd/topic/compat.py hgext3rd/topic/topicmap.py
diffstat 3 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Sun Nov 20 17:47:13 2022 +0400
+++ b/hgext3rd/topic/__init__.py	Sat Nov 12 15:47:57 2022 +0400
@@ -579,11 +579,7 @@
                 return super(topicrepo, self).branchmap()
             bm = self.filtered(topicfilter).branchmap()
             if convertbm:
-                if util.safehasattr(bm, '_entries'):
-                    entries = bm._entries
-                else:
-                    # hg <= 4.9 (624d6683c705+b137a6793c51)
-                    entries = bm
+                entries = compat.bcentries(bm)
                 for key in list(entries):
                     branch, tns, topic = common.parsefqbn(key)
                     if topic:
--- a/hgext3rd/topic/compat.py	Sun Nov 20 17:47:13 2022 +0400
+++ b/hgext3rd/topic/compat.py	Sat Nov 12 15:47:57 2022 +0400
@@ -25,6 +25,13 @@
         return branchmap.iteritems()
     # py3-transform: on
 
+def bcentries(branchcache):
+    if util.safehasattr(branchcache, '_entries'):
+        return branchcache._entries
+    else:
+        # hg <= 4.9 (624d6683c705+b137a6793c51)
+        return branchcache
+
 # nodemap.get and index.[has_node|rev|get_rev]
 # hg <= 5.2 (02802fa87b74)
 def getgetrev(cl):
--- a/hgext3rd/topic/topicmap.py	Sun Nov 20 17:47:13 2022 +0400
+++ b/hgext3rd/topic/topicmap.py	Sat Nov 12 15:47:57 2022 +0400
@@ -168,12 +168,8 @@
 
     def copy(self):
         """return an deep copy of the branchcache object"""
-        if util.safehasattr(self, '_entries'):
-            _entries = self._entries
-        else:
-            # hg <= 4.9 (624d6683c705+b137a6793c51)
-            _entries = self
-        args = (_entries, self.tipnode, self.tiprev, self.filteredhash,
+        entries = compat.bcentries(self)
+        args = (entries, self.tipnode, self.tiprev, self.filteredhash,
                 self._closednodes)
         if util.safehasattr(self, '_repo'):
             # hg <= 5.7 (6266d19556ad)