Submitter | Matt Mackall |
---|---|
Date | June 15, 2015, 10:30 p.m. |
Message ID | <d038b92c51d91c99b50f.1434407449@ruin.waste.org> |
Download | mbox | patch |
Permalink | /patch/9653/ |
State | Accepted |
Headers | show |
Comments
On Mon, Jun 15, 2015 at 05:30:49PM -0500, Matt Mackall wrote: > # HG changeset patch > # User Matt Mackall <mpm@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) Queued for topics, thanks. > > 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 > + $ 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@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel
On Mon, Jun 15, 2015 at 05:30:49PM -0500, Matt Mackall wrote: > # HG changeset patch > # User Matt Mackall <mpm@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@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel
On 06/15/2015 03:30 PM, Matt Mackall wrote: > # HG changeset patch > # User Matt Mackall <mpm@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. I do want the amend feature, but I'm not sure if allowing it for plain commit make sense. Matching the behavior for named branches do not make so much sense as this could result in plain empty commit when they become public.
On Tue, 2015-06-16 at 10:12 -0700, Pierre-Yves David wrote: > > On 06/15/2015 03:30 PM, Matt Mackall wrote: > > # HG changeset patch > > # User Matt Mackall <mpm@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. > > I do want the amend feature, but I'm not sure if allowing it for plain > commit make sense. Matching the behavior for named branches do not make > so much sense as this could result in plain empty commit when they > become public. Perhaps we can require that the commit already has a topic set (and is thus non-empty for other reasons).
Patch
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 + $ 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 + |