Patchwork [4,of,4,topic-ext] amend: allow clearing topics on amend

login
register
mail settings
Submitter Matt Mackall
Date June 19, 2015, 9:47 p.m.
Message ID <18b7daeadb9293605605.1434750474@ruin.waste.org>
Download mbox | patch
Permalink /patch/9722/
State Accepted
Headers show

Comments

Matt Mackall - June 19, 2015, 9:47 p.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1434749009 18000
#      Fri Jun 19 16:23:29 2015 -0500
# Node ID 18b7daeadb92936056053e67973800a8ba426887
# Parent  9b6c69769f78d7bc2338cb1f000d738df13234fe
amend: allow clearing topics on amend
Augie Fackler - June 22, 2015, 2:44 p.m.
On Fri, Jun 19, 2015 at 04:47:54PM -0500, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm@selenic.com>
> # Date 1434749009 18000
> #      Fri Jun 19 16:23:29 2015 -0500
> # Node ID 18b7daeadb92936056053e67973800a8ba426887
> # Parent  9b6c69769f78d7bc2338cb1f000d738df13234fe
> amend: allow clearing topics on amend

Queued for topics, thanks!

>
> diff -r 9b6c69769f78 -r 18b7daeadb92 src/topic/__init__.py
> --- 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
> diff -r 9b6c69769f78 -r 18b7daeadb92 tests/test-topic.t
> --- 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?
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r 9b6c69769f78 -r 18b7daeadb92 src/topic/__init__.py
--- 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
diff -r 9b6c69769f78 -r 18b7daeadb92 tests/test-topic.t
--- 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?
+