mercurial/commands.py
changeset 49365 79b2c98ab7b4
parent 49327 5bc3e76f919d
parent 49320 3d3d7fc6035a
child 49410 2bbd7bc7d6c4
--- 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
             )