changeset 6418:50c4ed02ac6d stable

topic: make hg split preserve topic namespace
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 21 Feb 2023 16:54:29 +0400
parents c37754bb02d4
children 73b20136eceb
files hgext3rd/topic/__init__.py tests/test-split.t
diffstat 2 files changed, 41 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Tue Feb 21 16:51:52 2023 +0400
+++ b/hgext3rd/topic/__init__.py	Tue Feb 21 16:54:29 2023 +0400
@@ -1606,7 +1606,10 @@
 
 def wrappresplitupdate(original, repo, ui, prev, ctx):
     # Save topic of revision
+    tns = None
     topic = None
+    if util.safehasattr(ctx, 'topic_namespace'):
+        tns = ctx.topic_namespace()
     if util.safehasattr(ctx, 'topic'):
         topic = ctx.topic()
 
@@ -1614,6 +1617,8 @@
     original(repo, ui, prev, ctx)
 
     # Restore the topic if need
+    if tns:
+        _changecurrenttns(repo, tns)
     if topic:
         _changecurrenttopic(repo, topic)
 
--- a/tests/test-split.t	Tue Feb 21 16:51:52 2023 +0400
+++ b/tests/test-split.t	Tue Feb 21 16:54:29 2023 +0400
@@ -411,6 +411,8 @@
 
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "topic=$(echo $(dirname $TESTDIR))/hgext3rd/topic/" >> $HGRCPATH
+  $ hg debug-topic-namespace mynamespace
+  marked working directory as topic namespace: mynamespace
   $ hg topic mytopic
   marked working directory as topic: mytopic
   $ echo babar > babar
@@ -419,8 +421,8 @@
   $ hg commit -m "Works on mytopic" babar celeste --user victor
   active topic 'mytopic' grew its first changeset
   (see 'hg help topics' for more information)
-  $ hg log -r . 
-  changeset:   18:cdda6d69812b
+  $ hg log -r .
+  changeset:   18:4f0e158045aa
   branch:      double//slash
   tag:         tip
   topic:       mytopic
@@ -429,14 +431,17 @@
   summary:     Works on mytopic
   
   $ hg summary
-  parent: 18:cdda6d69812b tip
+  parent: 18:4f0e158045aa tip
    Works on mytopic
-  branch: double//slash//mytopic
+  branch: double//slash//mynamespace/mytopic
   commit: (clean)
   update: (current)
   phases: 9 draft
   topic:  mytopic
 
+  $ hg log -r . -T '{rev}: {fqbn}\n'
+  18: double//slash//mynamespace/mytopic
+
 Split it
 
   $ hg split -U << EOF
@@ -470,7 +475,7 @@
 Check that the topic is still here
 
   $ hg log -r "tip~1::"
-  changeset:   19:a12d854b94a2
+  changeset:   19:d8d795e8424a
   branch:      double//slash
   topic:       mytopic
   parent:      17:db45bd0f0e52
@@ -478,7 +483,7 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     split7
   
-  changeset:   20:98274aae3990
+  changeset:   20:d6d47657e765
   branch:      double//slash
   tag:         tip
   topic:       mytopic
@@ -489,11 +494,15 @@
   $ hg topic
    * mytopic (2 changesets)
 
+  $ hg log -r "tip~1::" -T '{rev}: {fqbn}\n'
+  19: double//slash//mynamespace/mytopic
+  20: double//slash//mynamespace/mytopic
+
 Check commit extras
 
   $ hg log -r "tip~1::" -T '{rev}: {join(extras, " ")}\n'
-  19: branch=double//slash topic=mytopic
-  20: branch=double//slash topic=mytopic
+  19: branch=double//slash topic=mytopic topic-namespace=mynamespace
+  20: branch=double//slash topic=mytopic topic-namespace=mynamespace
 
 Test split the first commit on a branch
 
@@ -503,7 +512,7 @@
   marked working directory as branch another-branch
   $ hg commit -m "To be split"
   $ hg log -G -l 3
-  @  changeset:   21:1b89fbf4d770
+  @  changeset:   21:94981e5d988e
   |  branch:      another-branch
   |  tag:         tip
   |  topic:       mytopic
@@ -511,14 +520,14 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     To be split
   |
-  o  changeset:   20:98274aae3990
+  o  changeset:   20:d6d47657e765
   |  branch:      double//slash
   |  topic:       mytopic
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     split8
   |
-  o  changeset:   19:a12d854b94a2
+  o  changeset:   19:d8d795e8424a
   |  branch:      double//slash
   ~  topic:       mytopic
      parent:      17:db45bd0f0e52
@@ -532,8 +541,8 @@
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
   # Branch another-branch
-  # Node ID 1b89fbf4d770c8fad85b73aada92425c00ad3a58
-  # Parent  98274aae39908fc11c1cf42c381935cfbe94695e
+  # Node ID 94981e5d988ea23cf2b17f6c07c39edc0f174b01
+  # Parent  d6d47657e765570283ec03fc68836d9eb297c4b3
   # EXP-Topic mytopic
   To be split
   
@@ -571,7 +580,7 @@
 
 The split changesets should be on the 'another-branch'
   $ hg log -G -l 3
-  @  changeset:   23:492ea8acc08d
+  @  changeset:   23:61661257a937
   |  branch:      another-branch
   |  tag:         tip
   |  topic:       mytopic
@@ -579,15 +588,15 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     split10
   |
-  o  changeset:   22:35c3b7b7f830
+  o  changeset:   22:a05395d0b421
   |  branch:      another-branch
   |  topic:       mytopic
-  |  parent:      20:98274aae3990
+  |  parent:      20:d6d47657e765
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     split9
   |
-  o  changeset:   20:98274aae3990
+  o  changeset:   20:d6d47657e765
   |  branch:      double//slash
   ~  topic:       mytopic
      user:        test
@@ -607,7 +616,7 @@
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
 
   $ hg log -G -l 2
-  o  changeset:   24:5e7c5b766d1e
+  o  changeset:   24:cffbaf700768
   |  branch:      yet-another-branch
   |  tag:         tip
   |  topic:       mytopic
@@ -615,7 +624,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     To be split again
   |
-  @  changeset:   23:492ea8acc08d
+  @  changeset:   23:61661257a937
   |  branch:      another-branch
   ~  topic:       mytopic
      user:        test
@@ -649,7 +658,7 @@
   another-branch
 
   $ hg log -G -l 2
-  o  changeset:   24:5e7c5b766d1e
+  o  changeset:   24:cffbaf700768
   |  branch:      yet-another-branch
   |  tag:         tip
   |  topic:       mytopic
@@ -657,7 +666,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     To be split again
   |
-  @  changeset:   23:492ea8acc08d
+  @  changeset:   23:61661257a937
   |  branch:      another-branch
   ~  topic:       mytopic
      user:        test
@@ -728,8 +737,8 @@
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
   # Branch another-branch
-  # Node ID 492ea8acc08dae0fce72cc459218dba9043e0481
-  # Parent  35c3b7b7f83057a63307bb44ec59aebbba33c0f1
+  # Node ID 61661257a93759374255a4c05fcd9b8a78bbe399
+  # Parent  a05395d0b42120af8bfb222d19f01008b1342c15
   # EXP-Topic mytopic
   split10
   
@@ -744,8 +753,8 @@
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
   # Branch another-branch
-  # Node ID 1110f02dec0746d3b0493e7a09051816f7bc3179
-  # Parent  35c3b7b7f83057a63307bb44ec59aebbba33c0f1
+  # Node ID e6ca7ba1372dc452769c51a56d853c8ede26d9fa
+  # Parent  a05395d0b42120af8bfb222d19f01008b1342c15
   # EXP-Topic mytopic
   split10
   
@@ -780,8 +789,8 @@
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
   # Branch another-branch
-  # Node ID 5aa51c542c1b03435a7b5b602a4953bbe3321511
-  # Parent  35c3b7b7f83057a63307bb44ec59aebbba33c0f1
+  # Node ID bb8f1c282ddf89515bd07bd63a84962ab51ac277
+  # Parent  a05395d0b42120af8bfb222d19f01008b1342c15
   # EXP-Topic mytopic
   split12