Mercurial > evolve
changeset 6238:6bbd16579f0f
topic: list namespaces with debug-namespaces
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 03 May 2022 21:45:59 +0400 |
parents | 0b9042408809 |
children | 8861e33f3bb2 |
files | hgext3rd/topic/__init__.py tests/test-namespaces.t |
diffstat | 2 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Tue May 03 21:46:23 2022 +0400 +++ b/hgext3rd/topic/__init__.py Tue May 03 21:45:59 2022 +0400 @@ -504,6 +504,24 @@ return super(topicrepo, self).commitctx(ctx, *args, **kwargs) @util.propertycache + def _tnscache(self): + return {} + + @property + def topic_namespaces(self): + if self._topic_namespaces is not None: + return self._topic_namespaces + namespaces = set([self.currenttns]) + for c in self.set(b'not public()'): + namespaces.add(c.topic_namespace()) + self._topic_namespaces = namespaces + return namespaces + + @property + def currenttns(self): + return self.vfs.tryread(b'topic-namespace') or b'default' + + @util.propertycache def _topiccache(self): return {} @@ -545,6 +563,7 @@ def invalidatevolatilesets(self): # XXX we might be able to move this to something invalidated less often super(topicrepo, self).invalidatevolatilesets() + self._topic_namespaces = None self._topics = None def peer(self): @@ -691,6 +710,7 @@ return tr repo.__class__ = topicrepo + repo._topic_namespaces = None repo._topics = None if util.safehasattr(repo, 'names'): repo.names.addnamespace(namespaces.namespace( @@ -1501,6 +1521,12 @@ if topic: _changecurrenttopic(repo, topic) +@command(b'debug-topic-namespaces', []) +def debugtopicnamespaces(ui, repo, **opts): + """list repository namespaces""" + for tns in repo.topic_namespaces: + ui.write(b'%s\n' % (tns,)) + @command(b'debug-parse-fqbn', commands.formatteropts, _(b'FQBN'), optionalrepo=True) def debugparsefqbn(ui, repo, fqbn, **opts): """parse branch//namespace/topic string into its components"""
--- a/tests/test-namespaces.t Tue May 03 21:46:23 2022 +0400 +++ b/tests/test-namespaces.t Tue May 03 21:45:59 2022 +0400 @@ -2,6 +2,12 @@ $ . "$TESTDIR/testlib/topic_setup.sh" + $ hg init repo + $ cd repo + + $ hg debug-topic-namespaces + default + Parsing $ hg debugparsefqbn foo/bar//user26/feature -T '[{branch}] <{topic_namespace}> ({topic})\n'