changeset 6739:c94690f59bea stable

topic: allow selecting a specific tns value in debug-default-topic-namespace
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 07 Mar 2024 14:56:50 -0300
parents cf37748874f4
children d959abd665fd
files hgext3rd/topic/__init__.py tests/test-namespaces.t
diffstat 2 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Wed Mar 06 16:46:44 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Thu Mar 07 14:56:50 2024 -0300
@@ -1904,11 +1904,21 @@
     for tns in repo.topic_namespaces:
         ui.write(b'%s\n' % (tns,))
 
-@command(b'debug-default-topic-namespace', commands.formatteropts)
+@command(b'debug-default-topic-namespace', [
+        (b'', b'none', True, b'find changesets with topic-namespace=none'),
+        (b'', b'default', False, b'find changesets with topic-namespace=default'),
+    ] + 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)$")')
+    condition = []
+    if opts[b'none']:
+        condition += [b'extra("topic-namespace", "none")']
+    if opts[b'default']:
+        condition += [b'extra("topic-namespace", "default")']
+    if not condition:
+        condition = [b'none()']
+    revs = repo.revs(b'not public() and not obsolete() and (%lr)', condition)
     displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
     logcmdutil.displayrevs(ui, repo, revs, displayer, None)
 
--- a/tests/test-namespaces.t	Wed Mar 06 16:46:44 2024 -0300
+++ b/tests/test-namespaces.t	Thu Mar 07 14:56:50 2024 -0300
@@ -303,8 +303,22 @@
   >   --config extensions.commitextras= \
   >   --extra topic-namespace=default
 
+  $ hg debug-default-topic-namespace \
+  >   --debug \
+  >   | grep extra
+  extra:       branch=stable
+  extra:       topic-namespace=none
 
   $ hg debug-default-topic-namespace \
+  >   --no-none \
+  >   --default \
+  >   --debug \
+  >   | grep extra
+  extra:       branch=stable
+  extra:       topic-namespace=default
+
+  $ hg debug-default-topic-namespace \
+  >   --default \
   >   -T '{rev}:{node|short} {join(extras, " ")}\n'
   4:29a2d0acd473 branch=stable topic-namespace=none
   5:16d6061fce0c branch=stable topic-namespace=default