Mercurial > evolve
changeset 6385:0bc90758f613
topic: wrap branchmap.read() as well (compatibility for hg <= 4.9)
In hg 5.0+ this logic lives in branchcache.load method, but in older versions
there's a module-level function that loads on-disk cache and returns a
branchcache object. Since we need the cache to have branch names in the FQBN
format, we need to wrap branchmap.load() and do the conversion there as well.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 05 Feb 2023 19:01:32 +0400 |
parents | afd252e8f6e6 |
children | 9b5660737b52 |
files | hgext3rd/topic/topicmap.py |
diffstat | 1 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/topicmap.py Fri Feb 03 16:25:59 2023 +0400 +++ b/hgext3rd/topic/topicmap.py Sun Feb 05 19:01:32 2023 +0400 @@ -140,7 +140,9 @@ 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 _wrapupdatebmcache(orig, repo): previous = getattr(repo, '_autobranchmaptopic', False) @@ -249,3 +251,21 @@ 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