[PATCH topic-ext] topics: allow commits that only change topic (issue4725)

Augie Fackler raf at durin42.com
Tue Jun 16 11:11:54 CDT 2015


On Mon, Jun 15, 2015 at 05:30:49PM -0500, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm at selenic.com>
> # Date 1434407347 18000
> #      Mon Jun 15 17:29:07 2015 -0500
> # Node ID d038b92c51d91c99b50fd17c829e22212de051bb
> # Parent  ca2b4e5329fe018fc1279694cc89f74a7d6f4ccd
> topics: allow commits that only change topic (issue4725)
>
> This allows amend to change topics. It also matches the behavior of branches.
>
> diff -r ca2b4e5329fe -r d038b92c51d9 src/topic/__init__.py
> --- a/src/topic/__init__.py	Mon Jun 15 16:56:44 2015 -0500
> +++ b/src/topic/__init__.py	Mon Jun 15 17:29:07 2015 -0500
> @@ -43,6 +43,16 @@
>  def reposetup(ui, repo):
>      orig = repo.__class__
>      class topicrepo(repo.__class__):
> +        def commit(self, *args, **kwargs):
> +            backup = self.ui.backupconfig('ui', 'allowemptycommit')
> +            try:
> +                if repo.currenttopic != repo['.'].extra().get('topic'):
> +                    # bypass the core "nothing changed" logic
> +                    self.ui.setconfig('ui', 'allowemptycommit', True)
> +                return orig.commit(self, *args, **kwargs)
> +            finally:
> +                self.ui.restoreconfig(backup)
> +
>          def commitctx(self, ctx, error=None):
>              if isinstance(ctx, context.workingcommitctx):
>                  current = self.currenttopic
> diff -r ca2b4e5329fe -r d038b92c51d9 tests/test-topic.t
> --- a/tests/test-topic.t	Mon Jun 15 16:56:44 2015 -0500
> +++ b/tests/test-topic.t	Mon Jun 15 17:29:07 2015 -0500
> @@ -550,3 +550,24 @@
>    |  date:        Thu Jan 01 00:00:00 1970 +0000
>    |  summary:     start on fran
>    |
> +
> +Amend a topic
> +
> +  $ hg topic watwat
> +  $ hg ci --amend

And for some reason this doesn't work either:

   $ hg ci --amend
+  nothing changed
+  [1]
   $ hg log -Gr 'draft()'
-  @  changeset:   16:893ffcf66c1f
-  |  tag:         tip
-  |  topic:       watwat
-  |  parent:      13:d91cd8fd490e
+  @  changeset:   14:cf24ad8bbef5
+  |  tag:         tip
+  |  topic:       wat
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     fran?


> +  $ hg log -Gr 'draft()'
> +  @  changeset:   16:893ffcf66c1f
> +  |  tag:         tip
> +  |  topic:       watwat
> +  |  parent:      13:d91cd8fd490e
> +  |  user:        test
> +  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  summary:     fran?
> +  |
> +  o  changeset:   13:d91cd8fd490e
> +  |  topic:       wat
> +  |  parent:      3:a53952faf762
> +  |  user:        test
> +  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  summary:     start on fran
> +  |
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list