changeset 6746:094fa826f60b

topic: drop branchmap.updatecache() compatibility for hg 4.9
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 11 Jan 2024 15:26:49 -0300
parents 71c4b6c2bcdc
children 61a356e23921
files hgext3rd/topic/topicmap.py
diffstat 1 files changed, 7 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/topicmap.py	Thu Jan 11 15:31:13 2024 -0300
+++ b/hgext3rd/topic/topicmap.py	Thu Jan 11 15:26:49 2024 -0300
@@ -127,22 +127,14 @@
         pass
     branchmap.branchcache = topiccache
 
-    try:
-        # Mercurial 5.0
-        class remotetopiccache(_topiccache, branchmap.remotebranchcache):
-            pass
-        branchmap.remotebranchcache = remotetopiccache
+    class remotetopiccache(_topiccache, branchmap.remotebranchcache):
+        pass
+    branchmap.remotebranchcache = remotetopiccache
 
-        def _wrapupdatebmcachemethod(orig, self, repo):
-            # pass in the bound method as the original
-            return _wrapupdatebmcache(functools.partial(orig, self), repo)
-        extensions.wrapfunction(branchmap.BranchMapCache, 'updatecache', _wrapupdatebmcachemethod)
-    except AttributeError:
-        # hg <= 4.9 (3461814417f3)
-        extensions.wrapfunction(branchmap, 'updatecache', _wrapupdatebmcache)
-        # branchcache in hg <= 4.9 doesn't have load method, instead there's a
-        # module-level function to read on-disk cache and return a branchcache
-        extensions.wrapfunction(branchmap, 'read', _wrapbmread)
+    def _wrapupdatebmcachemethod(orig, self, repo):
+        # pass in the bound method as the original
+        return _wrapupdatebmcache(functools.partial(orig, self), repo)
+    extensions.wrapfunction(branchmap.BranchMapCache, 'updatecache', _wrapupdatebmcachemethod)
 
 def _wrapupdatebmcache(orig, repo):
     previous = getattr(repo, '_autobranchmaptopic', False)
@@ -252,21 +244,3 @@
 
         super(_topiccache, self).update(repo, revgen)
         self.phaseshash = _phaseshash(repo, self.tiprev)
-
-def _wrapbmread(orig, repo):
-    """call branchmap.read(), and then transform branch names to be in the
-    new "//" format
-    """
-    partial = orig(repo)
-    if partial is None:
-        # because of IOError or OSError
-        return partial
-
-    entries = compat.bcentries(partial)
-
-    for branch in tuple(entries):
-        formatted = common.formatfqbn(branch=branch)
-        if branch != formatted:
-            entries[formatted] = entries.pop(branch)
-
-    return partial