changeset 6745:71c4b6c2bcdc

topic: drop branchmap._entries compatibility for hg 4.9
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 11 Jan 2024 15:31:13 -0300
parents 3076dba01b86
children 094fa826f60b
files hgext3rd/topic/__init__.py hgext3rd/topic/compat.py hgext3rd/topic/discovery.py hgext3rd/topic/server.py hgext3rd/topic/topicmap.py
diffstat 5 files changed, 11 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Thu Mar 14 15:12:18 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Thu Jan 11 15:31:13 2024 -0300
@@ -751,14 +751,13 @@
                 return super(topicrepo, self).branchmap()
             bm = self.filtered(topicfilter).branchmap()
             if convertbm:
-                entries = compat.bcentries(bm)
-                for key in list(entries):
+                for key in list(bm._entries):
                     branch, tns, topic = common.parsefqbn(key)
                     if topic:
-                        value = entries.pop(key)
+                        value = bm._entries.pop(key)
                         # we lose namespace when converting to ":" format
                         key = b'%s:%s' % (branch, topic)
-                        entries[key] = value
+                        bm._entries[key] = value
             return bm
 
         def branchmaptns(self, topic=None):
@@ -815,7 +814,7 @@
                         else:
                             # only changesets in the selected topic namespaces are visible
                             h = []
-                            entries = compat.bcentries(self._repo.branchmaptns())
+                            entries = self._repo.branchmaptns()._entries
                             for branch, nodes in compat.branchmapitems(entries):
                                 namedbranch, tns, topic = common.parsefqbn(branch)
                                 if tns == b'none' or tns in namespaces:
--- a/hgext3rd/topic/compat.py	Thu Mar 14 15:12:18 2024 -0300
+++ b/hgext3rd/topic/compat.py	Thu Jan 11 15:31:13 2024 -0300
@@ -25,13 +25,6 @@
         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/discovery.py	Thu Mar 14 15:12:18 2024 -0300
+++ b/hgext3rd/topic/discovery.py	Thu Jan 11 15:31:13 2024 -0300
@@ -182,7 +182,7 @@
     if not common.hastopicext(repo):
         return wireprotov1server.branchmap(repo, proto)
     heads = []
-    entries = compat.bcentries(repo.branchmaptns())
+    entries = repo.branchmaptns()._entries
     for branch, nodes in compat.branchmapitems(entries):
         branchname = urlreq.quote(encoding.fromlocal(branch))
         branchnodes = wireprototypes.encodelist(nodes)
--- a/hgext3rd/topic/server.py	Thu Mar 14 15:12:18 2024 -0300
+++ b/hgext3rd/topic/server.py	Thu Jan 11 15:31:13 2024 -0300
@@ -77,7 +77,7 @@
     else:
         # only changesets in the selected topic namespaces are visible
         h = []
-        entries = compat.bcentries(repo.branchmaptns())
+        entries = repo.branchmaptns()._entries
         for branch, nodes in compat.branchmapitems(entries):
             namedbranch, tns, topic = common.parsefqbn(branch)
             if tns == b'none' or tns in namespaces:
--- a/hgext3rd/topic/topicmap.py	Thu Mar 14 15:12:18 2024 -0300
+++ b/hgext3rd/topic/topicmap.py	Thu Jan 11 15:31:13 2024 -0300
@@ -175,9 +175,8 @@
 
     def copy(self):
         """return an deep copy of the branchcache object"""
-        entries = compat.bcentries(self)
         assert isinstance(self, _oldbranchmap)  # help pytype
-        args = (entries, self.tipnode, self.tiprev, self.filteredhash,
+        args = (self._entries, self.tipnode, self.tiprev, self.filteredhash,
                 self._closednodes)
         if util.safehasattr(self, '_repo'):
             # hg <= 5.7 (6266d19556ad)
@@ -192,12 +191,11 @@
         """
         assert isinstance(self, _oldbranchmap)  # help pytype
         super(_topiccache, self).load(repo, lineiter)
-        entries = compat.bcentries(self)
 
-        for branch in tuple(entries):
+        for branch in tuple(self._entries):
             formatted = common.formatfqbn(branch=branch)
             if branch != formatted:
-                entries[formatted] = entries.pop(branch)
+                self._entries[formatted] = self._entries.pop(branch)
 
     def validfor(self, repo):
         """Is the cache content valid regarding a repo
@@ -227,12 +225,11 @@
         # the time will be fast enough
         if not istopicfilter(repo.filtername):
             cache = self.copy()
-            entries = compat.bcentries(cache)
 
-            for formatted in tuple(entries):
+            for formatted in tuple(cache._entries):
                 branch, tns, topic = common.parsefqbn(formatted)
                 if branch != formatted:
-                    entries[branch] = entries.pop(formatted)
+                    cache._entries[branch] = cache._entries.pop(formatted)
 
             super(_topiccache, cache).write(repo)