changeset 6552:81e89d943a4e

topic: pretend changeset has no topic namespace if it doesn't have a topic We only need this in case commit extras have topic namespace and no topic. Which is now prevented from happening by an earlier patch.
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 20 Jun 2023 12:30:24 -0300
parents 198b87917ba8
children 50f55918b417
files hgext3rd/topic/__init__.py tests/test-namespaces.t
diffstat 2 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Wed Sep 06 16:03:01 2023 -0300
+++ b/hgext3rd/topic/__init__.py	Tue Jun 20 12:30:24 2023 -0300
@@ -316,6 +316,9 @@
     # topic loaded, but not enabled (eg: multiple repo in the same process)
     if cache is None:
         return b'none'
+    # topic namespace is meaningless when topic is not set
+    if not self.topic(force):
+        return b'none'
     if self.rev() is None:
         # don't cache volatile ctx instances that aren't stored on-disk yet
         return self.extra().get(b'topic-namespace', b'none')
--- a/tests/test-namespaces.t	Wed Sep 06 16:03:01 2023 -0300
+++ b/tests/test-namespaces.t	Tue Jun 20 12:30:24 2023 -0300
@@ -5,22 +5,39 @@
   $ hg init repo
   $ cd repo
 
+Setting a topic namespace alone doesn't affect wdir()
+
   $ hg debug-topic-namespace space-name
   marked working directory as topic namespace: space-name
   $ hg debug-topic-namespaces
   space-name
 
   $ hg log -r 'wdir()' -T '{topic_namespace}\n'
+  none
+
+  $ hg log -r 'wdir()' -T '{fqbn}\n'
+  default
+
+But after setting a topic the already-set namespace is visible on wdir()
+
+  $ hg topic feature
+  marked working directory as topic: feature
+  $ hg topics
+   * feature (0 changesets)
+
+  $ hg log -r 'wdir()' -T '{topic_namespace}\n'
   space-name
 
   $ hg log -r 'wdir()' -T '{fqbn}\n'
-  default//space-name/
+  default//space-name/feature
 
   $ hg branches
 
   $ hg debug-topic-namespace --clear
   $ hg debug-topic-namespaces
 
+  $ hg topic --clear
+  clearing empty topic "feature"
   $ hg topics
 
   $ hg debugtopicnamespace --clear nonsense