# HG changeset patch # User Anton Shestakov # Date 1705512477 10800 # Node ID e9650b5616aceea066dc2feb1832e7ac88b8dc81 # Parent 9c329a7a59229f79d25af943c1bbef0dbdb0ff9a# Parent 4443117fdf9427420d00b8723ec219930eb8e6a6 branching: merge with stable diff -r 9c329a7a5922 -r e9650b5616ac hgext3rd/topic/__init__.py --- 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): diff -r 9c329a7a5922 -r e9650b5616ac hgext3rd/topic/server.py --- 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):