Patchwork commit: allow closing "non-head" changesets

login
register
mail settings
Submitter Mads Kiilerich
Date April 11, 2013, 8:34 p.m.
Message ID <50c464441c03d2c568d8.1365712485@mk-desktop>
Download mbox | patch
Permalink /patch/1277/
State Superseded
Commit f3245f22771cc4d73dfcea0e8b65e95653949a95
Headers show

Comments

Mads Kiilerich - April 11, 2013, 8:34 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1365592344 -7200
#      Wed Apr 10 13:12:24 2013 +0200
# Node ID 50c464441c03d2c568d8ead7ab4f8a3a7c512d2f
# Parent  d4beb04d87b5bbd88870b6d1fd87a72e30d62cd3
commit: allow closing "non-head" changesets

Backout acd61dc44a39. The changeset prevented closing non-head changesets but
did not provide any rationale or test case and I don't see what value it adds.
Users might have their reasons to commit something anywhere - and close it
immediately.

And contrary to the comment that is removed: The topo heads set is _not_
included in the branch heads set of the current branch. It do not include
closed topological heads.

The change thus prevented closing commits on top of closing commits. A valid
usecase for that is to merge closed heads to reduce the number of topological
heads.

The only existing test coverage for this is the failing double close in
test-revset.t. It was added in 3cc2e34d7a7d and seems to not be intentional.
Pierre-Yves David - April 11, 2013, 11:08 p.m.
On 11 avr. 2013, at 22:34, Mads Kiilerich wrote:

> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1365592344 -7200
> #      Wed Apr 10 13:12:24 2013 +0200
> # Node ID 50c464441c03d2c568d8ead7ab4f8a3a7c512d2f
> # Parent  d4beb04d87b5bbd88870b6d1fd87a72e30d62cd3
> commit: allow closing "non-head" changesets
> 
> Backout acd61dc44a39. The changeset prevented closing non-head changesets but
> did not provide any rationale or test case and I don't see what value it adds.
> Users might have their reasons to commit something anywhere - and close it
> immediately.

Sound sensible in a world were your can have draft, secret or obsolete children.
Bryan O'Sullivan - April 12, 2013, 4:42 p.m.
On Thu, Apr 11, 2013 at 1:34 PM, Mads Kiilerich <mads@kiilerich.com> wrote:

> commit: allow closing "non-head" changesets
>

Makes sense.
Augie Fackler - April 12, 2013, 8:32 p.m.
On Fri, Apr 12, 2013 at 09:42:58AM -0700, Bryan O'Sullivan wrote:
> On Thu, Apr 11, 2013 at 1:34 PM, Mads Kiilerich <mads@kiilerich.com> wrote:
>
> > commit: allow closing "non-head" changesets
> >
>
> Makes sense.

+1

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1299,10 +1299,6 @@ 
 
     extra = {}
     if opts.get('close_branch'):
-        if repo['.'].node() not in repo.branchheads():
-            # The topo heads set is included in the branch heads set of the
-            # current branch, so it's sufficient to test branchheads
-            raise util.Abort(_('can only close branch heads'))
         extra['close'] = 1
 
     branch = repo[None].branch()
diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -256,6 +256,27 @@ 
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg commit -d '9 0' --close-branch -m 'close this part branch too'
 
+  $ hg commit -d '9 0' --close-branch -m 're-closing this branch'
+  $ hg log -r tip --debug
+  changeset:   13:c2601d54b1427e99506bee25a566ef3a5963af0b
+  branch:      b
+  tag:         tip
+  phase:       draft
+  parent:      12:e3d49c0575d8fc2cb1cd6859c747c14f5f6d499f
+  parent:      -1:0000000000000000000000000000000000000000
+  manifest:    8:6f9ed32d2b310e391a4f107d5f0f071df785bfee
+  user:        test
+  date:        Thu Jan 01 00:00:09 1970 +0000
+  extra:       branch=b
+  extra:       close=1
+  description:
+  re-closing this branch
+  
+  
+  $ hg rollback
+  repository tip rolled back to revision 12 (undo commit)
+  working directory now based on revision 12
+
 --- b branch should be inactive
 
   $ hg branches
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -78,9 +78,6 @@ 
   $ hg branch all
   marked working directory as branch all
   (branches are permanent and global, did you want a bookmark?)
-  $ hg ci --close-branch -Aqm8
-  abort: can only close branch heads
-  [255]
 
   $ hg co 4
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved