While closing branch from a changeset which is not a branch head
current implementation abort this action in every case but, there
can be the situations where the changeset is not a local head but
could be a remote head. This patch adds the functionality to bypass
the "abort: can only close branch heads" by introducing
--force-close-branch flag.
Test case changes demonstrate the new functionality added.
I didn't realize that --force wasn't already an option for commit, because it is an option to internal commit functions. I still like this idea, but maybe you need to remove this from opts after completing the check here (and also in the --no-close-branch case). Otherwise, it risks bypassing existing safeguards.
https://www.mercurial-scm.org/repo/hg/file/tip/mercurial/localrepo.py#l2498
(I have no idea why that's allowed at all. MQ maybe?)