# HG changeset patch # User Sushil khanchi # Date 2019-04-15 21:03:54 # Node ID 9f7cb777b6540b55703940c26bf05d666164c1dd # Parent 4bcabb5ae9b677c5f3a9896b40a046058985f00e commit: add a check if it is trying to close an already closed branch head It would check if the revision we are going to close is already a closed branch head and print the error message accordingly. Differential Revision: https://phab.mercurial-scm.org/D6491 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1673,7 +1673,10 @@ def _docommit(ui, repo, *pats, **opts): if opts.get('close_branch'): extra['close'] = '1' - if not bheads: + if repo['.'].closesbranch(): + raise error.Abort(_('current revision is already a branch closing' + ' head')) + elif 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')) diff --git a/tests/test-branches.t b/tests/test-branches.t --- a/tests/test-branches.t +++ b/tests/test-branches.t @@ -280,7 +280,7 @@ verify update will accept invalid legacy 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' - abort: can only close branch heads + abort: current revision is already a branch closing head [255] $ hg log -r tip --debug