diff -r c2092612c424 -r 79b2c98ab7b4 mercurial/commands.py --- a/mercurial/commands.py Sat Jun 11 00:26:25 2022 +0200 +++ b/mercurial/commands.py Thu Jun 16 15:20:48 2022 +0200 @@ -2086,10 +2086,17 @@ extra[b'close'] = b'1' if repo[b'.'].closesbranch(): - raise error.InputError( - _(b'current revision is already a branch closing head') - ) - elif not bheads: + # Not ideal, but let us do an extra status early to prevent early + # bail out. + matcher = scmutil.match(repo[None], pats, opts) + s = repo.status(match=matcher) + if s.modified or s.added or s.removed: + bheads = repo.branchheads(branch, closed=True) + else: + msg = _(b'current revision is already a branch closing head') + raise error.InputError(msg) + + if not bheads: raise error.InputError( _(b'branch "%s" has no heads to close') % branch )