Mercurial > evolve
changeset 6651:e9650b5616ac
branching: merge with stable
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 17 Jan 2024 14:27:57 -0300 |
parents | 9c329a7a5922 (current diff) 4443117fdf94 (diff) |
children | 92fd4581f569 |
files | hgext3rd/topic/__init__.py hgext3rd/topic/server.py |
diffstat | 2 files changed, 42 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Sat Jan 06 13:26:13 2024 -0300 +++ b/hgext3rd/topic/__init__.py Wed Jan 17 14:27:57 2024 -0300 @@ -516,6 +516,30 @@ if tr.changes[b'tns']: repo.ui.status(b'topic namespaces affected: %s\n' % b' '.join(sorted(tr.changes[b'tns']))) +def wrapmakebundlerepository(orig, ui, repopath, bundlepath): + repo = orig(ui, repopath, bundlepath) + + # We want bundle repos to also have caches for topic extension, because we + # want to, for example, see topic and topic namespaces in `hg incoming` + # regardless if the bundle repo has topic extension, as long as local repo + # has topic enabled. + class topicbundlerepo(repo.__class__): + @util.propertycache + def _tnscache(self): + return {} + + @util.propertycache + def _topiccache(self): + return {} + + def invalidatecaches(self): + self._tnscache.clear() + self._topiccache.clear() + super(topicbundlerepo, self).invalidatecaches() + + repo.__class__ = topicbundlerepo + return repo + def uisetup(ui): destination.modsetup(ui) discovery.modsetup(ui) @@ -590,27 +614,9 @@ except (KeyError, AttributeError): pass - server.setupserver(ui) - - # We want bundle repos to also have caches for topic extension, because we - # want to, for example, see topic and topic namespaces in `hg incoming` - # regardless if the bundle repo has topic extension, as long as local repo - # has topic enabled. - class topicbundlerepo(bundlerepo.bundlerepository): - @util.propertycache - def _tnscache(self): - return {} + extensions.wrapfunction(bundlerepo, 'makebundlerepository', wrapmakebundlerepository) - @util.propertycache - def _topiccache(self): - return {} - - def invalidatecaches(self): - self._tnscache.clear() - self._topiccache.clear() - super(topicbundlerepo, self).invalidatecaches() - - bundlerepo.bundlerepository = topicbundlerepo + server.setupserver(ui) def reposetup(ui, repo): if not isinstance(repo, localrepo.localrepository):
--- a/hgext3rd/topic/server.py Sat Jan 06 13:26:13 2024 -0300 +++ b/hgext3rd/topic/server.py Wed Jan 17 14:27:57 2024 -0300 @@ -109,31 +109,27 @@ if util.safehasattr(wireprotov1peer, 'future'): # hg <= 5.9 (c424ff4807e6) - class tnspeer(wireprotov1peer.wirepeer): - """ wirepeer that uses `future` class from before c424ff4807e6 """ - @wireprotov1peer.batchable - def tns_heads(self, namespaces): - f = wireprotov1peer.future() # pytype: disable=module-attr - yield {b'namespaces': wireprototypes.encodelist(namespaces)}, f - d = f.value + @wireprotov1peer.batchable + def wp_tns_heads(self, namespaces): + f = wireprotov1peer.future() # pytype: disable=module-attr + yield {b'namespaces': wireprototypes.encodelist(namespaces)}, f + d = f.value + try: + yield wireprototypes.decodelist(d[:-1]) + except ValueError: + self._abort(error.ResponseError(_(b"unexpected response:"), d)) + else: + @wireprotov1peer.batchable + def wp_tns_heads(self, namespaces): + def decode(d): try: - yield wireprototypes.decodelist(d[:-1]) + return wireprototypes.decodelist(d[:-1]) except ValueError: self._abort(error.ResponseError(_(b"unexpected response:"), d)) - else: - class tnspeer(wireprotov1peer.wirepeer): - """ wirepeer that uses newer batchable scheme from c424ff4807e6 """ - @wireprotov1peer.batchable - def tns_heads(self, namespaces): - def decode(d): - try: - return wireprototypes.decodelist(d[:-1]) - except ValueError: - self._abort(error.ResponseError(_(b"unexpected response:"), d)) - return {b'namespaces': wireprototypes.encodelist(namespaces)}, decode + return {b'namespaces': wireprototypes.encodelist(namespaces)}, decode - wireprotov1peer.wirepeer = tnspeer + wireprotov1peer.wirepeer.tns_heads = wp_tns_heads class topicpeerexecutor(wireprotov1peer.peerexecutor):