changeset 6498:7ecb0f9cc7f3

topic: report namespace changes in more cases of phase movements
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 09 Jun 2023 11:02:13 -0300
parents 4e0f760d332e
children b165d2bb5868
files hgext3rd/topic/__init__.py tests/test-namespaces-report.t
diffstat 2 files changed, 30 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Mon Jun 05 21:57:37 2023 -0300
+++ b/hgext3rd/topic/__init__.py	Fri Jun 09 11:02:13 2023 -0300
@@ -452,12 +452,15 @@
         tns = ctx.topic_namespace()
         affected.add(tns)
 
-    # Phase movements, we only care about changesets that move from or to
-    # public phase
+    # Phase movements, we only care about:
+    # - publishing changesets (since they lose topic namespace)
+    # - forcefully making changesets draft again
+    # - turning secret changesets draft and making them visible to peers
+    tnsphases = (phases.secret, phases.draft)
     for revs, (old, new) in tr.changes[b'phases']:
-        if old != phases.public and new != phases.public:
-            # new phase is public: publishing changesets
-            # old phase is public: e.g. hg phase --draft --force
+        if old not in tnsphases and new not in tnsphases:
+            # Skip phase movement if there is no phase (old or new) that has
+            # visible topic namespace (i.e. draft and secret)
             continue
         revs = [rev for rev in revs if rev < origrepolen]
         for rev in revs:
--- a/tests/test-namespaces-report.t	Mon Jun 05 21:57:37 2023 -0300
+++ b/tests/test-namespaces-report.t	Fri Jun 09 11:02:13 2023 -0300
@@ -206,6 +206,28 @@
 
   $ cd ..
 
+7 phase movement: secret->draft on the server
+changeset becomes visible to peers, so its topic namespace is affected
+
+  $ hg clone orig case-7 -q
+  $ cd orig
+
+  $ hg phase --draft --force -r tip
+  $ hg phase --secret --force -r tip -R ../case-7
+
+XXX: should not require --new-branch
+
+  $ hg push ../case-7 -r . --config 'devel.tns-report-transactions=*' --new-branch
+  pushing to ../case-7
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  topic namespaces affected: dave
+  added 0 changesets with 0 changes to 1 files
+
+  $ cd ..
+
 99 pushing obsmarker for an unknown changeset
 doesn't affect any topic namespace, we report nothing