diff hgext3rd/topic/__init__.py @ 6548:445240ccb701

topic: add experimental.tns-default-pull-namespaces config option This config option controls what topic namespaces get pulled by default. The current default option is '*', which means all namespaces get pulled.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 27 Jul 2023 16:39:43 -0300
parents 7b2bd0332b56
children e45bfd1e0588
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Wed Aug 30 15:08:35 2023 -0300
+++ b/hgext3rd/topic/__init__.py	Thu Jul 27 16:39:43 2023 -0300
@@ -279,6 +279,9 @@
 configitem(b'experimental', b'tns-allow-rewrite',
            default=configitems.dynamicdefault,
 )
+configitem(b'experimental', b'tns-default-pull-namespaces',
+           default=configitems.dynamicdefault,
+)
 configitem(b'experimental', b'topic-mode.server',
            default=configitems.dynamicdefault,
 )
@@ -624,6 +627,7 @@
             else:
                 mode = b'none'
             caps.add(b'ext-topics-publish=%s' % mode)
+            caps.add(b'ext-topics-tns-heads')
             return caps
 
         def commit(self, *args, **kwargs):
@@ -740,6 +744,19 @@
                     def branchmaptns(self):
                         usetopic = not self._repo.publishing()
                         return self._repo.branchmaptns(topic=usetopic)
+
+                    def tns_heads(self, namespaces):
+                        if b'*' in namespaces:
+                            # pulling all topic namespaces, all changesets are visible
+                            return self._repo.heads()
+                        else:
+                            # only changesets in the selected topic namespaces are visible
+                            h = []
+                            for branch, nodes in self._repo.branchmaptns().items():
+                                namedbranch, tns, topic = common.parsefqbn(branch)
+                                if tns == b'none' or tns in namespaces:
+                                    h.extend(nodes)
+                            return h
                 peer.__class__ = topicpeer
             return peer