diff -r 258821f2d465 -r 8d14d91584f1 mercurial/commands.py --- a/mercurial/commands.py Tue Apr 16 01:19:58 2019 +0530 +++ b/mercurial/commands.py Tue Apr 16 02:06:20 2019 +0530 @@ -1675,6 +1675,8 @@ if not bheads: raise error.Abort(_('can only close branch heads')) + elif branch == repo['.'].branch() and repo['.'].node() not in bheads: + raise error.Abort(_('can only close branch heads')) elif opts.get('amend'): if (repo['.'].p1().branch() != branch and repo['.'].p2().branch() != branch):