changeset 6032:2800aa3c3dbf

topic: drop the old workaround for detecting amends by amend_source We don't need to have this workaround because amends are handled differently now. See previous commits, where the old code for handling amends in topic extension gets removed. Various commits now preserve amend_source when going through the _changetopics function (used when changing a topic via the hg topics command).
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 30 Aug 2021 12:05:14 +0300
parents c3d66af4cb07
children 182e2a1dbd1c
files hgext3rd/topic/__init__.py tests/test-amend-merge.t tests/test-evolve-topic.t tests/test-topic-change.t tests/test-topic-stack.t
diffstat 5 files changed, 27 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Mon Aug 30 12:55:00 2021 +0300
+++ b/hgext3rd/topic/__init__.py	Mon Aug 30 12:05:14 2021 +0300
@@ -1077,13 +1077,6 @@
         else:
             fixedextra[constants.extrakey] = newtopic
         fixedextra[constants.changekey] = c.hex()
-        if b'amend_source' in fixedextra:
-            # TODO: right now the commitctx wrapper in
-            # topicrepo overwrites the topic in extra if
-            # amend_source is set to support 'hg commit
-            # --amend'. Support for amend should be adjusted
-            # to not be so invasive.
-            del fixedextra[b'amend_source']
         ui.debug(b'changing topic of %s from %s to %s\n' % (
             c, oldtopic or b'<none>', newtopic or b'<none>'))
         ui.debug(b'fixedextra: %r\n' % fixedextra)
--- a/tests/test-amend-merge.t	Mon Aug 30 12:55:00 2021 +0300
+++ b/tests/test-amend-merge.t	Mon Aug 30 12:05:14 2021 +0300
@@ -83,15 +83,15 @@
   switching to topic foo
   changed topic on 1 changesets to "foo"
   $ hg log -r . -T '{rev}: {join(extras, " ")}\n'
-  6: _rewrite_noise=[0-9a-f]+ branch=default topic=foo (re)
+  6: _rewrite_noise=[0-9a-f]+ amend_source=[0-9a-f]+ branch=default topic=foo (re)
   $ hg diff -r 'p1(.)' -r '.'
-  diff -r 88a060ab6523 -r 52150b9639f7 banana
+  diff -r 88a060ab6523 -r 05be679ae1bd banana
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/banana	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
   +banana
   $ hg diff -r 'p2(.)' -r '.'
-  diff -r d8c7baf0ca58 -r 52150b9639f7 apple
+  diff -r d8c7baf0ca58 -r 05be679ae1bd apple
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/apple	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
--- a/tests/test-evolve-topic.t	Mon Aug 30 12:55:00 2021 +0300
+++ b/tests/test-evolve-topic.t	Mon Aug 30 12:05:14 2021 +0300
@@ -251,7 +251,7 @@
   4 new orphan changesets
   changed topic on 1 changesets to "bar"
   $ hg log -r 18 -T '{rev}: {join(extras, " ")}\n'
-  18: _rewrite_noise=[0-9a-f]+ branch=default rebase_source=[0-9a-f]+ topic=bar (re)
+  18: _rewrite_noise=[0-9a-f]+ amend_source=[0-9a-f]+ branch=default rebase_source=[0-9a-f]+ topic=bar (re)
   $ hg up 16d6f664b17c
   switching to topic bar
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -274,7 +274,7 @@
 ------------------------------------------------------------------------------
 
   $ hg log --graph
-  @  18 - {bar} 793eb6370b2d add fff (draft)
+  @  18 - {bar} c80027c7cda1 add fff (draft)
   |
   | *  17 - {bar} 9bf430c106b7 add jjj (draft)
   | |
@@ -343,7 +343,7 @@
   |
   *  19 - {bar} d834582d9ee3 add hhh (draft)
   |
-  | o  18 - {bar} 793eb6370b2d add fff (draft)
+  | o  18 - {bar} c80027c7cda1 add fff (draft)
   | |
   @ |  14 - {bar} 16d6f664b17c add ggg (draft)
   | |
@@ -357,7 +357,7 @@
   switching to topic foo
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   working directory parent is obsolete! (070c5573d8f9)
-  (use 'hg evolve' to update to its successor: 793eb6370b2d)
+  (use 'hg evolve' to update to its successor: c80027c7cda1)
 
   $ hg topic bar
 
@@ -392,17 +392,17 @@
   $ hg ci --amend
   4 new orphan changesets
   $ hg log -G
-  @  26 - {bar} 2c295936ac04 add fff (draft)
+  @  26 - {bar} 239dcab64bc0 add fff (draft)
   |
-  | *  25 - {bar} 38a82cbb794a add jjj (draft)
+  | *  25 - {bar} e49f8682fb23 add jjj (draft)
   | |
-  | *  24 - {bar} 4a44eba0fdb3 add iii (draft)
+  | *  24 - {bar} 318094e157e3 add iii (draft)
   | |
-  | *  23 - {bar} 7acd9ea5d677 add hhh (draft)
+  | *  23 - {bar} aa8b0df2da21 add hhh (draft)
   | |
-  | *  22 - {bar} 735c7bd8f133 add ggg (draft)
+  | *  22 - {bar} 310e9f9bceb1 add ggg (draft)
   | |
-  | x  18 - {bar} 793eb6370b2d add fff (draft)
+  | x  18 - {bar} c80027c7cda1 add fff (draft)
   |/
   o  12 - {foo} 42b49017ff90 add eee (draft)
   |
@@ -428,7 +428,7 @@
   (no more unresolved files)
   continue: hg evolve --continue
   $ hg evolve --continue
-  evolving 23:7acd9ea5d677 "add hhh"
+  evolving 23:aa8b0df2da21 "add hhh"
   move:[s4] add iii
   atop:[s3] add hhh
   move:[s5] add jjj
@@ -441,13 +441,13 @@
   switching to topic foo
   2 files updated, 0 files merged, 1 files removed, 0 files unresolved
   updated to hidden changeset 6a6b7365c751
-  (hidden revision '6a6b7365c751' was rewritten as: 2c295936ac04)
+  (hidden revision '6a6b7365c751' was rewritten as: 239dcab64bc0)
   working directory parent is obsolete! (6a6b7365c751)
-  (use 'hg evolve' to update to its successor: 2c295936ac04)
+  (use 'hg evolve' to update to its successor: 239dcab64bc0)
 
 Evolve:
   $ hg evolve
   update:[26] add fff
   switching to topic bar
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 2c295936ac04
+  working directory is now at 239dcab64bc0
--- a/tests/test-topic-change.t	Mon Aug 30 12:55:00 2021 +0300
+++ b/tests/test-topic-change.t	Mon Aug 30 12:05:14 2021 +0300
@@ -303,9 +303,9 @@
   cleared topic on 1 changesets
 
   $ hg log -r . -T '{rev}: {join(extras, " ")}\n'
-  31: _rewrite_noise=[0-9a-f]+ branch=default rebase_source=[0-9a-f]+ (re)
+  31: _rewrite_noise=[0-9a-f]+ amend_source=[0-9a-f]+ branch=default rebase_source=[0-9a-f]+ (re)
   $ hg glog
-  @  31:c48d6d71b2d9 {}
+  @  31:fb090538b75b {}
   |  Added h  (book)
   |
   o  26:7c76c271395f {bar}
@@ -337,9 +337,9 @@
   switching to topic movebook
   changed topic on 1 changesets to "movebook"
   $ hg log -r . -T '{rev}: {join(extras, " ")}\n'
-  32: _rewrite_noise=[0-9a-f]+ branch=default rebase_source=[0-9a-f]+ topic=movebook (re)
+  32: _rewrite_noise=[0-9a-f]+ amend_source=[0-9a-f]+ branch=default rebase_source=[0-9a-f]+ topic=movebook (re)
   $ hg glog
-  @  32:1b83d11095b9 {movebook}
+  @  32:3955a85a6349 {movebook}
   |  Added h  (book bookboo)
   |
   o  26:7c76c271395f {bar}
@@ -384,7 +384,7 @@
   @  33:894983f69e69 {watwat}
   |  Added g  ()
   |
-  | *  32:1b83d11095b9 {movebook}
+  | *  32:3955a85a6349 {movebook}
   | |  Added h  (book bookboo)
   | |
   | x  26:7c76c271395f {bar}
--- a/tests/test-topic-stack.t	Mon Aug 30 12:55:00 2021 +0300
+++ b/tests/test-topic-stack.t	Mon Aug 30 12:05:14 2021 +0300
@@ -626,7 +626,7 @@
   o  0 default {} public c_a
   
   $ hg log -r 'desc("c_D")' -T '{rev}: {join(extras, " ")}\n'
-  17: _rewrite_noise=[0-9a-f]+ branch=default topic=foobar (re)
+  17: _rewrite_noise=[0-9a-f]+ amend_source=[0-9a-f]+ branch=default topic=foobar (re)
 
 XXX: The following should show single heads
 XXX: The behind count is weird, because the topic are interleaved.
@@ -642,17 +642,17 @@
   $ hg stack -v
   ### topic: foobar
   ### target: default (branch), 3 behind
-  s2(ea0f882ce093)@ c_e (current)
+  s2(5985c9f0df93)@ c_e (current)
                   ^ c_h
-  s1(d2f548af67ab): c_D
+  s1(cab9d344b7b5): c_D
   s0(8522f9e3fee9)^ c_c (base)
 
   $ hg stack --debug
   ### topic: foobar
   ### target: default (branch), 3 behind
-  s2(ea0f882ce093a2ad63db49083c5cb98a24a9470e)@ c_e (current)
+  s2(5985c9f0df9331630a4f003f01d320303b8dcae1)@ c_e (current)
                                               ^ c_h
-  s1(d2f548af67ab55b08452a3e00a539319490fcd5b): c_D
+  s1(cab9d344b7b582ae7c125f0eae77c18c771c508d): c_D
   s0(8522f9e3fee92d4ec4e688ac3fbd2ee0f8fd5036)^ c_c (base)
 
   $ hg stack foo