# HG changeset patch # User Anton Shestakov # Date 1704997609 10800 # Node ID 094fa826f60b5a2da63cb6227be80a2679872024 # Parent 71c4b6c2bcdcd3be6e6736c6b8d49885054cfd04 topic: drop branchmap.updatecache() compatibility for hg 4.9 diff -r 71c4b6c2bcdc -r 094fa826f60b hgext3rd/topic/topicmap.py --- 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