Bug 3445 - amending with --close-branch a commit that created a new head should fail
Summary: amending with --close-branch a commit that created a new head should fail
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: earlier
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords: easy
Depends on:
Blocks:
 
Reported: 2012-05-11 10:28 UTC by Idan Kamara
Modified: 2017-11-01 18:05 UTC (History)
5 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Idan Kamara 2012-05-11 10:28 UTC
This shouldn't be possible:

  $ hg init a
  $ cd a
  $ echo a >> a
  $ hg ci -Am.
  adding a
  $ echo a >> a
  $ hg branch foo
  marked working directory as branch foo
  (branches are permanent and global, did you want a bookmark?)
  $ hg ci -Am..
  $ hg ci --amend --close-branch -m 'closing'
  saved backup bundle to $TESTTMP/a/.hg/strip-backup/450e0eae1f4b-amend-
backup.hg
Comment 1 Pierre-Yves David 2012-05-11 13:29 UTC
Why would it make sense. Is is denied by plain commit ?
Comment 2 Idan Kamara 2012-05-11 15:03 UTC
Is what denied?
Comment 3 Matt Mackall 2012-05-11 15:21 UTC
This silliness fails:

$ hg branch newbranch
$ hg ci --close -m'open and close'
abort: can only close branch heads

..so doing it with commit + commit --amend should probably fail too.
Comment 4 Idan Kamara 2012-05-11 15:24 UTC
Yes, this is what the bug report is about.

There's at least one other edge case with --close which I'll get to tomorrow.
Comment 5 Bugzilla 2012-05-13 06:23 UTC

--- Bug imported by bugzilla@selenic.com 2012-05-13 06:23 EDT  ---

This bug was previously known as _bug_ 3441 at http://mercurial.selenic.com/bts/issue3441
Comment 6 HG Bot 2013-06-07 18:00 UTC
Fixed by http://selenic.com/repo/hg/rev/b500a663a2c7
Iulian Stana <julian.stana@gmail.com>
commit: amending with --close-branch (issue3445)

You can't close a branch that hasn't got a head.
newbranch + commit --close-branch must fail
newbranch + commit + commit --amend --close-branch must fail

You must not be allowed to close a branch that is not defined.

(please test the fix)