# HG changeset patch # User Matt Mackall # Date 1434407347 18000 # Node ID 4ab1b854ce4ea43cd788b01933670fa54f138817 # Parent a506ed8ab8daae40f500cdb147d5201f7a9175bc topics: allow commits that only change topic (issue4725) This allows amend to change topics. It also matches the behavior of branches. diff --git a/src/topic/__init__.py b/src/topic/__init__.py --- a/src/topic/__init__.py +++ b/src/topic/__init__.py @@ -44,6 +44,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 --git a/tests/test-topic.t b/tests/test-topic.t --- a/tests/test-topic.t +++ b/tests/test-topic.t @@ -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 + $ 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 + |