changeset 6738:cf37748874f4 stable

topic: add a simple debug command to list changesets with problematic tns The following topic namespaces are considered problematic: - "none", which currently represents an empty topic namespace and should never appear in commit extras - "default", which previously was representing an empty topic namespace and now might confuse some code
author Anton Shestakov <av6@dwimlabs.net>
date Wed, 06 Mar 2024 16:46:44 -0300
parents 08a9113a15ee
children c94690f59bea
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	Wed Mar 13 15:54:01 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Wed Mar 06 16:46:44 2024 -0300
@@ -179,6 +179,7 @@
     hg,
     localrepo,
     lock as lockmod,
+    logcmdutil,
     merge,
     namespaces,
     node,
@@ -1903,6 +1904,14 @@
     for tns in repo.topic_namespaces:
         ui.write(b'%s\n' % (tns,))
 
+@command(b'debug-default-topic-namespace', commands.formatteropts)
+def debugdefaulttns(ui, repo, **opts):
+    """list changesets with the default topic namespace in commit extras"""
+    opts = pycompat.byteskwargs(opts)
+    revs = repo.revs(b'not public() and not obsolete() and extra("topic-namespace", "re:^(default|none)$")')
+    displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
+    logcmdutil.displayrevs(ui, repo, revs, displayer, None)
+
 @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	Wed Mar 13 15:54:01 2024 -0300
+++ b/tests/test-namespaces.t	Wed Mar 06 16:46:44 2024 -0300
@@ -286,6 +286,29 @@
   abort: topic namespace 'nonsense' does not exist
   [10]
 
+Debug command related to the default/empty topic namespace
+
+  $ hg debug-topic-namespace --clear
+
+  $ echo none > none
+  $ hg ci -qAm 'tns=none' \
+  >    --config extensions.topic=! \
+  >    --config extensions.commitextras= \
+  >    --extra topic-namespace=none
+
+
+  $ echo default > default
+  $ hg ci -qAm 'tns=default' \
+  >   --config extensions.topic=! \
+  >   --config extensions.commitextras= \
+  >   --extra topic-namespace=default
+
+
+  $ hg debug-default-topic-namespace \
+  >   -T '{rev}:{node|short} {join(extras, " ")}\n'
+  4:29a2d0acd473 branch=stable topic-namespace=none
+  5:16d6061fce0c branch=stable topic-namespace=default
+
 Parsing
 
   $ hg debugparsefqbn foo/bar//user26/feature -T '[{branch}] <{topic_namespace}> ({topic})\n'