amend: allow clearing topics on amend
authorMatt Mackall <mpm@selenic.com>
Fri, 19 Jun 2015 16:23:29 -0500
changeset 1862 565f057bdc08
parent 1861 972d4e0c3d44
child 1863 29fc43f24948
amend: allow clearing topics on amend
src/topic/__init__.py
tests/test-topic.t
--- a/src/topic/__init__.py	Fri Jun 19 16:16:42 2015 -0500
+++ b/src/topic/__init__.py	Fri Jun 19 16:23:29 2015 -0500
@@ -63,6 +63,12 @@
                 current = self.currenttopic
                 if current:
                     ctx.extra()[constants.extrakey] = current
+            if (isinstance(ctx, context.memctx) and
+                ctx.extra().get('amend_source') and
+                ctx.topic() and
+                not self.currenttopic):
+                # we are amending and need to remove a topic
+                del ctx.extra()[constants.extrakey]
             return orig.commitctx(self, ctx, error=error)
 
         @property
--- a/tests/test-topic.t	Fri Jun 19 16:16:42 2015 -0500
+++ b/tests/test-topic.t	Fri Jun 19 16:23:29 2015 -0500
@@ -571,3 +571,16 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     start on fran
   |
+
+Clear and amend:
+
+  $ hg topic --clear
+  $ hg ci --amend
+  $ hg log -r .
+  changeset:   18:a13639e22b65
+  tag:         tip
+  parent:      13:d91cd8fd490e
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     fran?
+