changeset 6497:4e0f760d332e

topic: also find and report topic namespace changes caused by bookmarks
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 05 Jun 2023 21:57:37 -0300
parents fba501baf5cb
children 7ecb0f9cc7f3
files hgext3rd/topic/__init__.py tests/test-namespaces-report.t
diffstat 2 files changed, 58 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Mon Jun 05 21:57:13 2023 -0300
+++ b/hgext3rd/topic/__init__.py	Mon Jun 05 21:57:37 2023 -0300
@@ -465,6 +465,14 @@
             tns = ctx.topic_namespace(force=True)
             affected.add(tns)
 
+    # We want to detect any bookmark movement, even within one topic namespace
+    for name, nodes in tr.changes[b'bookmarks'].items():
+        for n in nodes:
+            if n is not None and n in unfi:
+                ctx = unfi[n]
+                tns = ctx.topic_namespace()
+                affected.add(tns)
+
     # We don't care about changesets without topic namespace
     affected.discard(b'none')
 
--- a/tests/test-namespaces-report.t	Mon Jun 05 21:57:13 2023 -0300
+++ b/tests/test-namespaces-report.t	Mon Jun 05 21:57:37 2023 -0300
@@ -125,6 +125,56 @@
 
   $ cd ..
 
+5 bookmark movement that affect tns (like putting a bookmark on obsolete changesets)
+their topic namespaces reappear and are therefore reported
+
+  $ hg clone orig case-5 -q
+  $ cd orig
+
+  $ hg debug-topic-namespace dana
+  $ echo durian > d
+  $ hg ci -qAm 'durian'
+
+XXX: should not require --new-branch
+
+  $ hg push ../case-5 --new-branch
+  pushing to ../case-5
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  topic namespaces affected: dana
+  added 1 changesets with 1 changes to 1 files
+
+  $ hg debug-topic-namespace dave
+  $ echo dragonfruit > d
+  $ hg ci --amend -m 'dragonfruit'
+
+XXX: should not require --new-branch
+
+  $ hg push ../case-5 --new-branch
+  pushing to ../case-5
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  topic namespaces affected: dana dave
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+
+  $ hg bookmark --hidden -r 'desc("durian")' @
+  bookmarking hidden changeset ac97707e6b4a
+  (hidden revision 'ac97707e6b4a' was rewritten as: 822ac0064503)
+
+  $ hg push ../case-5 -B @
+  pushing to ../case-5
+  searching for changes
+  no changes found
+  topic namespaces affected: dana
+  exporting bookmark @
+  [1]
+
   $ cd ..
 
 6 phase movement: publishing secret changesets (that are known on the server)