Mercurial > evolve
changeset 6384:afd252e8f6e6
topic: wrap revbranchcache._branchinfo() too
This method can be used as a direct replacement for branchinfo() if on-disk
cache cannot be read, so we need to wrap it as well. However, branchinfo() can
call _branchinfo(), so we need to make sure that we do the branch-to-FQBN
conversion only once. For this, we check if revbranchcache.branchinfo is
actually _branchinfo.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 03 Feb 2023 16:25:59 +0400 |
parents | c6e3d2dbbeb0 |
children | 0bc90758f613 |
files | hgext3rd/topic/discovery.py |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/discovery.py Thu Feb 02 10:41:52 2023 +0400 +++ b/hgext3rd/topic/discovery.py Fri Feb 03 16:25:59 2023 +0400 @@ -325,6 +325,7 @@ return caps def wrapbranchinfo(orig, self, rev): + # NOTE: orig can be either branchinfo() or _branchinfo()! b, close = orig(self, rev) if common.hastopicext(self._repo): if self._repo.ui.configbool(b'_internal', b'tns-disable-fqbn'): @@ -340,6 +341,15 @@ b = ctx.fqbn() return b, close +def wrapslowbranchinfo(orig, self, rev): + if self.branchinfo == self._branchinfo: + # _branchinfo() gets called directly and needs to do the conversion + return wrapbranchinfo(orig, self, rev) + else: + # _branchinfo() gets called through branchinfo(), the latter will need + # to do the conversion + return orig(self, rev) + def modsetup(ui): """run at uisetup time to install all destinations wrapping""" extensions.wrapfunction(discovery, '_headssummary', _headssummary) @@ -350,6 +360,9 @@ wirepeer.branchmaptns = wirepeer.branchmap wireprotov1server.wireprotocommand(b'branchmaptns', permission=b'pull')(wireprotobranchmaptns) extensions.wrapfunction(branchmap.revbranchcache, 'branchinfo', wrapbranchinfo) + # branchinfo method can get replaced by _branchinfo method directly when + # on-disk revbranchcache is not available, see revbranchcache.__init__() + extensions.wrapfunction(branchmap.revbranchcache, '_branchinfo', wrapslowbranchinfo) # we need a proper wrap b2 part stuff extensions.wrapfunction(bundle2, 'handlecheckheads', handlecheckheads) bundle2.handlecheckheads.params = frozenset()